tamplier 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/tamplier +20 -0
- data/lib/tamplier/copy.rb +10 -0
- data/lib/tamplier/iterator.rb +15 -0
- data/lib/tamplier/symlink.rb +10 -0
- data/lib/tamplier/validator.rb +5 -2
- data/lib/tamplier/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 045c00a47f540735abfd803b03a2f0d2157dacc9
|
4
|
+
data.tar.gz: 8a77d0403716941281047258a35ceb13c89a3e7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,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
|
data/lib/tamplier/validator.rb
CHANGED
@@ -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(
|
14
|
-
flat_keys(
|
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
|
data/lib/tamplier/version.rb
CHANGED
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.
|
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-
|
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
|