Module: I0n

Defined in:
lib/generators/i0n/i0n.rb,
lib/i0n_rails3_generators.rb,
lib/generators/i0n/layout/layout_generator.rb,
lib/generators/i0n/authentication/authentication_generator.rb

Defined Under Namespace

Modules: Generators

Constant Summary collapse

ROOT_PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..'))
LIB_PATH =
File.expand_path(File.dirname(__FILE__))
CONFIG_PATH =
File.expand_path(File.join(File.dirname(__FILE__), '../config'))
IGNORE_DIRS =
['.','..']
LAUNCH_PATH =
FileUtils.pwd

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.version_majorObject

Returns the value of attribute version_major.



21
22
23
# File 'lib/i0n_rails3_generators.rb', line 21

def version_major
  @version_major
end

.version_minorObject

Returns the value of attribute version_minor.



21
22
23
# File 'lib/i0n_rails3_generators.rb', line 21

def version_minor
  @version_minor
end

.version_patchObject

Returns the value of attribute version_patch.



21
22
23
# File 'lib/i0n_rails3_generators.rb', line 21

def version_patch
  @version_patch
end

Class Method Details

.bump(version_type) ⇒ Object

Method for bumping version number types. Resets @version_minor and @version_patch to 0 if bumping @version_major. Resets @version_pacth to 0 if bumping @version_minor



38
39
40
41
42
43
44
45
46
47
# File 'lib/i0n_rails3_generators.rb', line 38

def bump(version_type)
  value = instance_variable_get("@#{version_type}")
  instance_variable_set("@#{version_type}", (value + 1))
  if version_type == "version_major"
    @version_minor, @version_patch = 0, 0
  elsif version_type == "version_minor"
    @version_patch = 0
  end
  dump_version_yaml
end

.const_missing(name) ⇒ Object

Handles calls to missing constants in the JumpStart module. Calls JumpStart.version if JumpStart::VERSION is recognised.



60
61
62
63
64
65
66
# File 'lib/i0n_rails3_generators.rb', line 60

def const_missing(name)
  if name.to_s =~ /^VERSION$/
    version
  else
    super
  end
end

.dump_version_yamlObject

Method for writing to config/jumpstart_version.yml



24
25
26
27
28
# File 'lib/i0n_rails3_generators.rb', line 24

def dump_version_yaml
  File.open( "#{I0n::CONFIG_PATH}/version.yml", 'w' ) do |out|
    YAML.dump( {:version_major => @version_major, :version_minor => @version_minor, :version_patch => @version_patch}, out )
  end
end

.method_missing(method, *args) ⇒ Object

Handles calls to JumpStart::Setup.bump_version_major, JumpStart::Setup.bump_version_minor and JumpStart::Setup.bump_version_patch class methods.



50
51
52
53
54
55
56
57
# File 'lib/i0n_rails3_generators.rb', line 50

def method_missing(method, *args)
  if method.to_s.match(/^bump_version_(major|minor|patch)$/)
    version_type = method.to_s.sub('bump_', '')
    self.send(:bump, "#{version_type}")
  else
    super
  end
end

.versionObject

Looks up the current version of JumpStart



31
32
33
# File 'lib/i0n_rails3_generators.rb', line 31

def version
  "#{version_major}.#{version_minor}.#{version_patch}"
end