Module: JumpStart
- Defined in:
- lib/jumpstart/base.rb,
lib/jumpstart.rb
Defined Under Namespace
Modules: FileTools, StringTools Classes: Base
Constant Summary collapse
- ROOT_PATH =
File.(File.join(File.dirname(__FILE__), '..'))
- LIB_PATH =
File.(File.dirname(__FILE__))
- CONFIG_PATH =
File.(File.join(File.dirname(__FILE__), '../config'))
- IGNORE_DIRS =
['.','..']
- LAUNCH_PATH =
FileUtils.pwd
Class Attribute Summary collapse
-
.default_template_name ⇒ Object
Returns the value of attribute default_template_name.
-
.version_major ⇒ Object
Returns the value of attribute version_major.
-
.version_minor ⇒ Object
Returns the value of attribute version_minor.
-
.version_patch ⇒ Object
Returns the value of attribute version_patch.
Class Method Summary collapse
-
.bump(version_type) ⇒ Object
Method for bumping version number types.
-
.const_missing(name) ⇒ Object
Handles calls to missing constants in the JumpStart module.
-
.dump_jumpstart_setup_yaml ⇒ Object
Method for writing to config/jumpstart_setup.yml.
-
.dump_jumpstart_version_yaml ⇒ Object
Method for writing to config/jumpstart_version.yml.
-
.existing_templates ⇒ Object
TODO JumpStart#lookup_existing_templates class instance method needs tests.
-
.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.
-
.templates_path ⇒ Object
Set the jumpstart templates path back to default if it has not been set.
- .templates_path=(value) ⇒ Object
-
.version ⇒ Object
Looks up the current version of JumpStart.
Class Attribute Details
.default_template_name ⇒ Object
Returns the value of attribute default_template_name.
44 45 46 |
# File 'lib/jumpstart.rb', line 44 def default_template_name @default_template_name end |
.version_major ⇒ Object
Returns the value of attribute version_major.
44 45 46 |
# File 'lib/jumpstart.rb', line 44 def version_major @version_major end |
.version_minor ⇒ Object
Returns the value of attribute version_minor.
44 45 46 |
# File 'lib/jumpstart.rb', line 44 def version_minor @version_minor end |
.version_patch ⇒ Object
Returns the value of attribute version_patch.
44 45 46 |
# File 'lib/jumpstart.rb', line 44 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
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/jumpstart.rb', line 97 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_jumpstart_version_yaml end |
.const_missing(name) ⇒ Object
Handles calls to missing constants in the JumpStart module. Calls JumpStart.version if JumpStart::VERSION is recognised.
119 120 121 122 123 124 125 |
# File 'lib/jumpstart.rb', line 119 def const_missing(name) if name.to_s =~ /^VERSION$/ version else super end end |
.dump_jumpstart_setup_yaml ⇒ Object
Method for writing to config/jumpstart_setup.yml
76 77 78 79 80 |
# File 'lib/jumpstart.rb', line 76 def dump_jumpstart_setup_yaml File.open( "#{JumpStart::CONFIG_PATH}/jumpstart_setup.yml", 'w' ) do |out| YAML.dump( {:jumpstart_templates_path => @templates_path, :jumpstart_default_template_name => @default_template_name}, out ) end end |
.dump_jumpstart_version_yaml ⇒ Object
Method for writing to config/jumpstart_version.yml
83 84 85 86 87 |
# File 'lib/jumpstart.rb', line 83 def dump_jumpstart_version_yaml File.open( "#{JumpStart::CONFIG_PATH}/jumpstart_version.yml", 'w' ) do |out| YAML.dump( {:jumpstart_version_major => @version_major, :jumpstart_version_minor => @version_minor, :jumpstart_version_patch => @version_patch}, out ) end end |
.existing_templates ⇒ Object
TODO JumpStart#lookup_existing_templates class instance method needs tests
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/jumpstart.rb', line 60 def existing_templates templates = [] template_dirs = Dir.entries(templates_path) - IGNORE_DIRS template_dirs.each do |x| if File.directory?(FileUtils.join_paths(templates_path, x)) if Dir.entries(FileUtils.join_paths(templates_path, x)).include? "jumpstart_config" if File.exists?(FileUtils.join_paths(templates_path, x, '/jumpstart_config/', "#{x}.yml")) templates << x end end end end templates 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.
109 110 111 112 113 114 115 116 |
# File 'lib/jumpstart.rb', line 109 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 |
.templates_path ⇒ Object
Set the jumpstart templates path back to default if it has not been set
47 48 49 50 51 52 53 |
# File 'lib/jumpstart.rb', line 47 def templates_path if @templates_path.nil? || @templates_path.empty? @templates_path = "#{JumpStart::ROOT_PATH}/jumpstart_templates" else @templates_path end end |
.templates_path=(value) ⇒ Object
55 56 57 |
# File 'lib/jumpstart.rb', line 55 def templates_path=(value) @templates_path = value end |
.version ⇒ Object
Looks up the current version of JumpStart
90 91 92 |
# File 'lib/jumpstart.rb', line 90 def version "#{version_major}.#{version_minor}.#{version_patch}" end |