templar 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tasks/templar_tasks.rake +1 -0
- data/lib/templar/processor.rb +22 -12
- data/lib/templar/version.rb +1 -1
- metadata +3 -3
data/lib/templar/processor.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "yaml"
|
1
2
|
require 'erubis'
|
2
3
|
require 'templar/config'
|
3
4
|
|
@@ -17,7 +18,7 @@ module Templar
|
|
17
18
|
##
|
18
19
|
# Get a new processor
|
19
20
|
# @param [Hash] config_overrides these values will be merged on top of the defaults.
|
20
|
-
def initialize(settings = {})
|
21
|
+
def initialize(settings = { })
|
21
22
|
defaults = {
|
22
23
|
:print_format => " templar: (update: %s) %s => %s"
|
23
24
|
}
|
@@ -38,9 +39,13 @@ module Templar
|
|
38
39
|
def process
|
39
40
|
if @use_environments
|
40
41
|
@environment ||= begin
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
if defined?(Rails)
|
43
|
+
Rails.env
|
44
|
+
elsif ENV['ENVIRONMENT']
|
45
|
+
ENV['ENVIRONMENT']
|
46
|
+
else
|
47
|
+
nil
|
48
|
+
end
|
44
49
|
end
|
45
50
|
raise "Use Environments option is true, but environment is not set (#{@config.inspect})" if @use_environments && !@environment
|
46
51
|
raise "Data is empty, missing environment?" unless @data[@environment.to_sym]
|
@@ -58,11 +63,11 @@ module Templar
|
|
58
63
|
# @param [String] file the file to load
|
59
64
|
# @param [Hash] overrides these values will be merged on top of the file data
|
60
65
|
# @return [Templar::Config] contains the file as a config object
|
61
|
-
def load_yaml_file(file, settings = {})
|
66
|
+
def load_yaml_file(file, settings = { })
|
62
67
|
raise "file #{file} does not exist" unless File.exists?(file)
|
63
|
-
data = settings[:defaults] || {}
|
64
|
-
data.merge!(YAML.load_file(file)||{})
|
65
|
-
data.merge!(settings[:overrides]||{})
|
68
|
+
data = settings[:defaults] || { }
|
69
|
+
data.merge!(YAML.load_file(file)||{ })
|
70
|
+
data.merge!(settings[:overrides]||{ })
|
66
71
|
Templar::Config.new(data)
|
67
72
|
end
|
68
73
|
|
@@ -71,11 +76,16 @@ module Templar
|
|
71
76
|
# If #{directory}/data.yml exists, use that, otherwise use #{directory}/data.sample.yml
|
72
77
|
# data.sample.yml should contain non-development template data.
|
73
78
|
def data_file
|
74
|
-
#@data_file ||= File.exists?("#{@directory}/data.yml") ? "#{@directory}/data.yml" : "#{@directory}/data.sample.yml"
|
75
79
|
@data_file ||= begin
|
76
|
-
|
77
|
-
|
78
|
-
"#@directory/
|
80
|
+
if @use_environments && File.exists?("#@directory/#@environment.yml")
|
81
|
+
"#@directory/#@environment.yml"
|
82
|
+
elsif File.exists?("#@directory/local.yml")
|
83
|
+
"#@directory/local.yml"
|
84
|
+
elsif File.exists?("#@directory/data.yml")
|
85
|
+
"#@directory/data.yml"
|
86
|
+
else
|
87
|
+
"#@directory/data.sample.yml"
|
88
|
+
end
|
79
89
|
end
|
80
90
|
end
|
81
91
|
|
data/lib/templar/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: templar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
segments:
|
146
146
|
- 0
|
147
|
-
hash:
|
147
|
+
hash: -1269285896644966509
|
148
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
segments:
|
155
155
|
- 0
|
156
|
-
hash:
|
156
|
+
hash: -1269285896644966509
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
159
|
rubygems_version: 1.8.21
|