Module: Noid::Rails

Defined in:
lib/noid-rails.rb,
lib/noid/rails/rspec.rb,
lib/noid/rails/config.rb,
lib/noid/rails/engine.rb,
lib/noid/rails/service.rb,
lib/noid/rails/version.rb,
lib/noid/rails/minter/db.rb,
lib/noid/rails/minter/base.rb,
lib/noid/rails/minter/file.rb,
lib/generators/noid/rails/seed_generator.rb,
lib/generators/noid/rails/install_generator.rb

Overview

A package to integrate Noid identifers with Rails projects

Defined Under Namespace

Modules: Minter, RSpec Classes: Config, Engine, InstallGenerator, SeedGenerator, Service

Constant Summary collapse

VERSION =
'3.0.1'

Class Method Summary collapse

Class Method Details

.configObject


17
18
19
# File 'lib/noid-rails.rb', line 17

def config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:


13
14
15
# File 'lib/noid-rails.rb', line 13

def configure
  yield config
end

.treeify(identifier) ⇒ Object

Raises:

  • (ArgumentError)

21
22
23
24
25
26
# File 'lib/noid-rails.rb', line 21

def treeify(identifier)
  raise ArgumentError, 'Identifier must be a string of size > 0 in order to be treeified' if identifier.blank?
  head = identifier.split('/').first
  head.gsub!(/#.*/, '')
  (head.scan(/..?/).first(4) + [identifier]).join('/')
end