tamplier 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79a872c3737faffc5396308e52e5176adaa17a1e
4
- data.tar.gz: a62a0d25f08c83f2e51ac480512e428a3187b722
3
+ metadata.gz: 045c00a47f540735abfd803b03a2f0d2157dacc9
4
+ data.tar.gz: 8a77d0403716941281047258a35ceb13c89a3e7e
5
5
  SHA512:
6
- metadata.gz: 205b88b519ac7a7f38ae74b8fe63a10708b3ace5fd57a7a0ae7ad2dfeb4bbd264e6112fb8ddb4011dc82775281e4641da08198a70dc530fbe24c88fffdcf5db7
7
- data.tar.gz: 4378f0a78fc6bf53ee9bf09f1e5a3a331d6a39ce977051ab0c47cd24a5ca189a2c7692327bb37e9dddb95fe4606b9941e20a0ecf86af032933474218da052677
6
+ metadata.gz: 1c818f8138d976f7636136a597b2846f6b858c0e832d2e4900069b25d1eda7b1a615976a1aa57259d11b9283456f373c5af7a25c040838e222d70547baece965
7
+ data.tar.gz: b95c801088a08f84615b5106d5a1db854cd3f64d64a1b11f55ccc35bb1175834bb756d457872a7cf53f679f7b6661e77b074b55a1efe1313752b8cc2fe332ba0
data/bin/tamplier CHANGED
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/tamplier'
4
+ require_relative '../lib/tamplier/iterator'
5
+ require_relative '../lib/tamplier/copy'
6
+ require_relative '../lib/tamplier/symlink'
7
+
4
8
 
5
9
  require 'commander'
6
10
 
@@ -22,4 +26,20 @@ Commander.configure do
22
26
  end
23
27
 
24
28
  default_command :check
29
+
30
+ command :copy do |c|
31
+ c.syntax = 'tamplier copy'
32
+ c.description = 'Creates copies of all .yml.sample files in config directory with .yml extension'
33
+ c.action do |args, options|
34
+ Tamplier::Copy.new.call(Pathname('.').join('config'))
35
+ end
36
+ end
37
+
38
+ command :symlink do |c|
39
+ c.syntax = 'tamplier copy'
40
+ c.description = 'Creates symbolic links with .yml extension pointing to .yml.sample files'
41
+ c.action do |args, options|
42
+ Tamplier::Symlink.new.call(Pathname('.').join('config'))
43
+ end
44
+ end
25
45
  end
@@ -0,0 +1,10 @@
1
+ module Tamplier
2
+ class Copy < Iterator
3
+ def call(*)
4
+ super do |sample_file, config_file|
5
+ FileUtils.cp(sample_file, config_file) unless config_file.exist?
6
+ puts "Made a copy of #{sample_file} to #{config_file}."
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module Tamplier
2
+ class Iterator
3
+ def call(root)
4
+ Pathname.glob(File.join(root, '*.yml.sample')).each do |sample_file|
5
+ config_file = sample_file.sub_ext('')
6
+
7
+ if config_file.exist? || config_file.symlink?
8
+ puts "#{config_file} already exist, skipping."
9
+ else
10
+ yield(sample_file, config_file)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module Tamplier
2
+ class Symlink < Iterator
3
+ def call(*)
4
+ super do |sample_file, config_file|
5
+ FileUtils.ln_s(sample_file, config_file)
6
+ puts "Made a symlink from #{sample_file} pointing to #{config_file}."
7
+ end
8
+ end
9
+ end
10
+ end
@@ -9,9 +9,12 @@ module Tamplier
9
9
  raise ConfigurationException.new("There is no #{environment} environment in the #{config_file} file.") unless YAML.load(config_file.read)[environment].present?
10
10
  end
11
11
 
12
+ sample_config = YAML.load(sample_file.read)
13
+ real_config = YAML.load(config_file.read)
14
+
12
15
  diff = environmental_file?(sample_file) ?
13
- flat_keys(YAML.load(sample_file.read)['development']) - flat_keys(YAML.load(config_file.read)[environment]) :
14
- flat_keys(YAML.load(sample_file.read)) - flat_keys(YAML.load(config_file.read))
16
+ flat_keys(sample_config['development']) - flat_keys(real_config[environment]) :
17
+ flat_keys(sample_config) - flat_keys(real_config)
15
18
 
16
19
  raise ConfigurationException.new("Several keys #{diff.inspect} from #{sample_file} are not in #{config_file} file.") unless diff.empty?
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module Tamplier
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tamplier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shestakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -136,8 +136,11 @@ extra_rdoc_files: []
136
136
  files:
137
137
  - bin/tamplier
138
138
  - lib/tamplier.rb
139
+ - lib/tamplier/copy.rb
139
140
  - lib/tamplier/exceptions/configuration_exception.rb
141
+ - lib/tamplier/iterator.rb
140
142
  - lib/tamplier/railtie.rb
143
+ - lib/tamplier/symlink.rb
141
144
  - lib/tamplier/validator.rb
142
145
  - lib/tamplier/version.rb
143
146
  - spec/dummy/config/environment.rb