templar 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  require 'templar'
2
2
 
3
3
  namespace :templar do
4
+ desc "use templar to update all templates"
4
5
  task :update do
5
6
  templar = Templar::Processor.new(:overrides => {:always_update => true})
6
7
  end
@@ -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
- return Rails.env if defined?(Rails)
42
- return ENV['ENVIRONMENT'] if ENV['ENVIRONMENT']
43
- nil
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
- return "#@directory/#@environment.yml" if @use_environments && File.exists?("#@directory/#@environment.yml")
77
- return "#@directory/data.yml" if File.exists?("#@directory/data.yml")
78
- "#@directory/data.sample.yml"
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
 
@@ -3,7 +3,7 @@ if !defined?(Templar::VERSION)
3
3
  module Version #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- TINY = 5
6
+ TINY = 6
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
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.5
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: 2792798898732996790
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: 2792798898732996790
156
+ hash: -1269285896644966509
157
157
  requirements: []
158
158
  rubyforge_project:
159
159
  rubygems_version: 1.8.21