Class: Jack::Settings
- Inherits:
-
Object
- Object
- Jack::Settings
- Defined in:
- lib/jack/settings.rb
Instance Method Summary collapse
- #app_name_pattern ⇒ Object
- #conventions ⇒ Object
- #create ⇒ Object
- #create_flags ⇒ Object
-
#data ⇒ Object
The options from the files get merged with the following precedence:.
- #home ⇒ Object
-
#initialize(root = nil) ⇒ Settings
constructor
A new instance of Settings.
Constructor Details
Instance Method Details
#app_name_pattern ⇒ Object
42 43 44 |
# File 'lib/jack/settings.rb', line 42 def app_name_pattern conventions["app_name_pattern"] end |
#conventions ⇒ Object
46 47 48 |
# File 'lib/jack/settings.rb', line 46 def conventions data["conventions"] end |
#create ⇒ Object
38 39 40 |
# File 'lib/jack/settings.rb', line 38 def create data["create"] end |
#create_flags ⇒ Object
34 35 36 |
# File 'lib/jack/settings.rb', line 34 def create_flags create.inject("") {|s,(k,v)| s << %{--#{k} "#{v}" } ; s }.strip end |
#data ⇒ Object
The options from the files get merged with the following precedence:
current folder - The current folder’s jack/settings.yml values take the highest precedence. user - The user’s ~/.jack/settings.yml values take the second highest precedence. default - The default settings bundled with the tool takes the lowest precedence.
More info: jack-eb.com/docs/settings/
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jack/settings.rb', line 14 def data return @settings_yaml if @settings_yaml project_file = "#{@root}/jack/settings.yml" project = File.exist?(project_file) ? YAML.load_file(project_file) : {} user_file = "#{home}/.jack/settings.yml" user = File.exist?(user_file) ? YAML.load_file(user_file) : {} default_file = File.("../default/settings.yml", __FILE__) default = YAML.load_file(default_file) @settings_yaml = default.merge(user.merge(project)) end |
#home ⇒ Object
29 30 31 32 |
# File 'lib/jack/settings.rb', line 29 def home # hack but fast ENV['TEST'] ? "spec/fixtures/home" : ENV['HOME'] end |