cog-rb 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cogrb +16 -0
- data/cog-rb.gemspec +2 -1
- data/lib/cog/config.rb +36 -3
- data/lib/cog/version.rb +1 -1
- data/lib/tasks/cog.rake +35 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c483003f31da134986c41e6df9652376d87c6122
|
4
|
+
data.tar.gz: 0b2b8f28dc88324a64e17a2f58cb78581d8d8122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0dbb6591fbaaf73e42a5819d17141c25495781070628dd86aa83a9f61d34f20927b9485e8efcfc8a8a3f2eb425b2749ab9e876bfb8c9d5cc1185bc360cfbe10
|
7
|
+
data.tar.gz: 41a471f281608c8075565f212f76988fcca892647201950ff2b25a8b436aec8a1aaee71310637caf209e82440af3713d8d1f928da7311d4605ea304d52ad7cb0
|
data/bin/cogrb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'cog/config'
|
5
|
+
|
6
|
+
rake = Rake::Application.new
|
7
|
+
rake.init('cogrb')
|
8
|
+
Rake.application = rake
|
9
|
+
|
10
|
+
rake.standard_exception_handling do
|
11
|
+
task_dir = File.join(File.dirname(__FILE__), '..', 'lib', 'tasks')
|
12
|
+
task_files = FileList.new(File.join(task_dir, '*.rake'))
|
13
|
+
task_files.each { |file| rake.add_import(file) }
|
14
|
+
rake.load_imports
|
15
|
+
rake.top_level
|
16
|
+
end
|
data/cog-rb.gemspec
CHANGED
@@ -14,8 +14,9 @@ Gem::Specification.new do |spec|
|
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
spec.bindir = "bin"
|
17
|
-
spec.executables =
|
17
|
+
spec.executables = ["cogrb"]
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_dependency "rake", "~> 11.2"
|
20
21
|
spec.add_development_dependency "bundler", "~> 1.11"
|
21
22
|
end
|
data/lib/cog/config.rb
CHANGED
@@ -3,16 +3,49 @@ require "yaml"
|
|
3
3
|
|
4
4
|
class Cog
|
5
5
|
class Config
|
6
|
+
attr_reader :config_file, :data, :stale
|
7
|
+
|
6
8
|
def initialize(config_file)
|
7
|
-
@
|
9
|
+
@config_file = config_file
|
10
|
+
@data = YAML.load(File.read(@config_file))
|
11
|
+
@stale = false
|
8
12
|
end
|
9
13
|
|
10
14
|
def dump
|
11
|
-
YAML.dump(@
|
15
|
+
YAML.dump(@data)
|
12
16
|
end
|
13
17
|
|
14
18
|
def [](key)
|
15
|
-
@
|
19
|
+
@data[key.to_s]
|
20
|
+
end
|
21
|
+
|
22
|
+
def []=(key, value)
|
23
|
+
@data[key.to_s] = value
|
24
|
+
@stale = true
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_version(version = nil)
|
28
|
+
if !version.nil?
|
29
|
+
@data[version] = version
|
30
|
+
else
|
31
|
+
segments = @data['version'].split('.')
|
32
|
+
segments[-1] = segments.last.to_i + 1
|
33
|
+
@data['version'] = segments.join('.')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def save
|
38
|
+
return unless @stale
|
39
|
+
|
40
|
+
contents = YAML.dump(@data)
|
41
|
+
File.open(@config_file, 'w') do |out|
|
42
|
+
out.write(contents)
|
43
|
+
@stale = false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def stale?
|
48
|
+
@stale
|
16
49
|
end
|
17
50
|
end
|
18
51
|
end
|
data/lib/cog/version.rb
CHANGED
data/lib/tasks/cog.rake
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
namespace :template do
|
2
|
+
desc "Update templates in configuration file"
|
3
|
+
task :update do
|
4
|
+
config_file = FileList.new('config.y?ml').first
|
5
|
+
config = Cog::Config.new(config_file)
|
6
|
+
|
7
|
+
puts "Current bundle configuration version is #{config['version']}."
|
8
|
+
|
9
|
+
templates = FileList.new('templates/*/*.mustache')
|
10
|
+
return if templates.nil? || templates.size == 0
|
11
|
+
|
12
|
+
config['templates'] ||= {}
|
13
|
+
templates.each do |file|
|
14
|
+
(provider, template) = file.split('/')[-2..-1]
|
15
|
+
template.gsub!(/\.mustache\z/, '')
|
16
|
+
template_content = File.read(file)
|
17
|
+
|
18
|
+
config['templates'][provider] ||= {}
|
19
|
+
prev_content = config['templates'][provider][template]
|
20
|
+
|
21
|
+
if template_content != prev_content
|
22
|
+
puts "Updating bundle configuration for template #{provider}/#{template}."
|
23
|
+
config['templates'][provider][template] = template_content
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if config.stale?
|
28
|
+
config.update_version
|
29
|
+
puts "Writing new configuration file for version #{config['version']}."
|
30
|
+
config.save
|
31
|
+
else
|
32
|
+
puts "No updated templates found. Configuration not updated."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cog-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Imbriaco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '11.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '11.2'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -28,8 +42,7 @@ description:
|
|
28
42
|
email:
|
29
43
|
- mark@operable.io
|
30
44
|
executables:
|
31
|
-
-
|
32
|
-
- setup
|
45
|
+
- cogrb
|
33
46
|
extensions: []
|
34
47
|
extra_rdoc_files: []
|
35
48
|
files:
|
@@ -41,6 +54,7 @@ files:
|
|
41
54
|
- LICENSE
|
42
55
|
- README.md
|
43
56
|
- Rakefile
|
57
|
+
- bin/cogrb
|
44
58
|
- bin/console
|
45
59
|
- bin/setup
|
46
60
|
- cog-rb.gemspec
|
@@ -58,6 +72,7 @@ files:
|
|
58
72
|
- lib/rspec/cog.rb
|
59
73
|
- lib/rspec/cog/matchers.rb
|
60
74
|
- lib/rspec/cog/setup.rb
|
75
|
+
- lib/tasks/cog.rake
|
61
76
|
homepage: https://github.com/cog-bundles/cog-rb
|
62
77
|
licenses: []
|
63
78
|
metadata: {}
|