simonmenke-gm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gm.rb +2 -0
- data/lib/gm/app.rb +11 -1
- data/lib/gm/configuration_pass.rb +1 -54
- data/lib/gm/configuration_pass_queue.rb +33 -0
- data/lib/gm/dsl.rb +31 -0
- data/lib/passes/configatron.rb +11 -2
- data/lib/passes/defaults.rb +1 -1
- data/lib/passes/executables.rb +0 -1
- data/lib/passes/files.rb +0 -1
- data/lib/passes/github.rb +0 -1
- data/lib/passes/rails.rb +1 -1
- data/lib/passes/specs.rb +6 -0
- data/lib/passes/tests.rb +6 -0
- metadata +6 -2
data/lib/gm.rb
CHANGED
data/lib/gm/app.rb
CHANGED
@@ -5,8 +5,18 @@ module GM
|
|
5
5
|
class App
|
6
6
|
include Singleton
|
7
7
|
|
8
|
+
attr_accessor :configuration_passes
|
9
|
+
|
8
10
|
COMMANDS = %w( help build spec install clean )
|
9
11
|
|
12
|
+
def initialize
|
13
|
+
@configuration_passes = Hash.new { |h, k| h[k] = {} }
|
14
|
+
end
|
15
|
+
|
16
|
+
def exclude_pass(name, fase=:normal)
|
17
|
+
@configuration_passes[fase.to_sym].delete(name.to_sym)
|
18
|
+
end
|
19
|
+
|
10
20
|
def parse_options
|
11
21
|
@command = ARGV.shift unless ARGV.empty?
|
12
22
|
@command = nil unless COMMANDS.include? @command
|
@@ -57,7 +67,7 @@ module GM
|
|
57
67
|
|
58
68
|
def load_passes
|
59
69
|
Dir.glob(File.dirname(__FILE__)+'/../passes/*.rb') do |path|
|
60
|
-
|
70
|
+
GM::DSL.load_pass path
|
61
71
|
end
|
62
72
|
end
|
63
73
|
|
@@ -1,59 +1,6 @@
|
|
1
1
|
|
2
2
|
module GM
|
3
3
|
|
4
|
-
class << self
|
5
|
-
attr_accessor :configuration_passes
|
6
|
-
end
|
7
|
-
self.configuration_passes = Hash.new { |h, k| h[k] = {} }
|
8
|
-
|
9
|
-
def self.exclude_pass(name, fase=:normal)
|
10
|
-
self.configuration_passes[fase.to_sym].delete(name.to_sym)
|
11
|
-
end
|
12
|
-
|
13
|
-
module DSL
|
14
|
-
def init_pass(name, dependencies=[], &proc)
|
15
|
-
ConfigurationPass.new(name, dependencies, &proc).register(:init)
|
16
|
-
end
|
17
|
-
def pre_pass(name, dependencies=[], &proc)
|
18
|
-
ConfigurationPass.new(name, dependencies, &proc).register(:pre)
|
19
|
-
end
|
20
|
-
def pass(name, dependencies=[], &proc)
|
21
|
-
ConfigurationPass.new(name, dependencies, &proc).register(:normal)
|
22
|
-
end
|
23
|
-
def post_pass(name, dependencies=[], &proc)
|
24
|
-
ConfigurationPass.new(name, dependencies, &proc).register(:post)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class ConfigurationPassQueue
|
29
|
-
attr_accessor :queue
|
30
|
-
attr_accessor :passes
|
31
|
-
attr_accessor :processed_passes
|
32
|
-
|
33
|
-
def initialize(fase)
|
34
|
-
@passes = GM.configuration_passes[fase.to_sym].dup
|
35
|
-
@processed_passes = []
|
36
|
-
@queue = @passes.values
|
37
|
-
end
|
38
|
-
|
39
|
-
def run(spec)
|
40
|
-
until @queue.empty?
|
41
|
-
@queue.each do |pass|
|
42
|
-
if run_pass(pass, spec)
|
43
|
-
@queue.delete(pass)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def run_pass(pass, spec)
|
50
|
-
return false unless (pass.dependencies - @processed_passes).empty?
|
51
|
-
pass.run spec
|
52
|
-
@processed_passes << pass.name
|
53
|
-
return true
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
4
|
class ConfigurationPass
|
58
5
|
|
59
6
|
attr_accessor :proc
|
@@ -67,7 +14,7 @@ module GM
|
|
67
14
|
end
|
68
15
|
|
69
16
|
def register(fase)
|
70
|
-
GM.configuration_passes[fase.to_sym][@name] = self
|
17
|
+
GM::App.instance.configuration_passes[fase.to_sym][@name] = self
|
71
18
|
end
|
72
19
|
|
73
20
|
def run(spec)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module GM
|
3
|
+
|
4
|
+
class ConfigurationPassQueue
|
5
|
+
attr_accessor :queue
|
6
|
+
attr_accessor :passes
|
7
|
+
attr_accessor :processed_passes
|
8
|
+
|
9
|
+
def initialize(fase)
|
10
|
+
@passes = GM::App.instance.configuration_passes[fase.to_sym].dup
|
11
|
+
@processed_passes = []
|
12
|
+
@queue = @passes.values
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(spec)
|
16
|
+
until @queue.empty?
|
17
|
+
@queue.each do |pass|
|
18
|
+
if run_pass(pass, spec)
|
19
|
+
@queue.delete(pass)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_pass(pass, spec)
|
26
|
+
return false unless (pass.dependencies - @processed_passes).empty?
|
27
|
+
pass.run spec
|
28
|
+
@processed_passes << pass.name
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/gm/dsl.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module GM
|
3
|
+
|
4
|
+
module DSL
|
5
|
+
def load_pass(path)
|
6
|
+
if File.exist? path
|
7
|
+
mod = Module.new
|
8
|
+
mod.send :extend, DSL
|
9
|
+
mod.module_eval IO.read(path)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
module_function :load_pass
|
13
|
+
|
14
|
+
def init_pass(name, dependencies=[], &proc)
|
15
|
+
ConfigurationPass.new(name, dependencies, &proc).register(:init)
|
16
|
+
end
|
17
|
+
def pre_pass(name, dependencies=[], &proc)
|
18
|
+
ConfigurationPass.new(name, dependencies, &proc).register(:pre)
|
19
|
+
end
|
20
|
+
def pass(name, dependencies=[], &proc)
|
21
|
+
ConfigurationPass.new(name, dependencies, &proc).register(:normal)
|
22
|
+
end
|
23
|
+
def post_pass(name, dependencies=[], &proc)
|
24
|
+
ConfigurationPass.new(name, dependencies, &proc).register(:post)
|
25
|
+
end
|
26
|
+
def exclude_pass(name, fase=:normal)
|
27
|
+
GM::App.instance.exclude_pass(name, fase)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/passes/configatron.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
include GM::DSL
|
2
1
|
|
3
2
|
pre_pass :configatron_defaults do |spec|
|
4
3
|
|
@@ -11,6 +10,12 @@ pre_pass :configatron_defaults do |spec|
|
|
11
10
|
},
|
12
11
|
:dependencies => [],
|
13
12
|
|
13
|
+
:rdoc => {
|
14
|
+
:enabled => true,
|
15
|
+
:extra_files => [],
|
16
|
+
:options => []
|
17
|
+
},
|
18
|
+
|
14
19
|
:author => {
|
15
20
|
:name => nil,
|
16
21
|
:email => nil
|
@@ -55,7 +60,7 @@ end
|
|
55
60
|
pre_pass :configatron_exclude_passes, :configatron_local do |s|
|
56
61
|
c = configatron
|
57
62
|
c.excluded_passes.each do |pass|
|
58
|
-
|
63
|
+
exclude_pass(pass)
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
@@ -71,6 +76,10 @@ pass :configatron do |s|
|
|
71
76
|
|
72
77
|
s.rubyforge_project = c.rubyforge.project
|
73
78
|
|
79
|
+
s.has_rdoc = c.rdoc.enabled
|
80
|
+
s.extra_rdoc_files = c.rdoc.extra_files
|
81
|
+
s.rdoc_options = c.rdoc.options
|
82
|
+
|
74
83
|
c.dependencies.each do |dependency|
|
75
84
|
gem, requirement = dependency.strip.split(/\s+/, 2)
|
76
85
|
s.add_dependency gem.strip, requirement.strip
|
data/lib/passes/defaults.rb
CHANGED
data/lib/passes/executables.rb
CHANGED
data/lib/passes/files.rb
CHANGED
data/lib/passes/github.rb
CHANGED
data/lib/passes/rails.rb
CHANGED
data/lib/passes/specs.rb
ADDED
data/lib/passes/tests.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simonmenke-gm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -33,6 +33,8 @@ files:
|
|
33
33
|
- bin/gm
|
34
34
|
- lib/gm/app.rb
|
35
35
|
- lib/gm/configuration_pass.rb
|
36
|
+
- lib/gm/configuration_pass_queue.rb
|
37
|
+
- lib/gm/dsl.rb
|
36
38
|
- lib/gm.rb
|
37
39
|
- lib/passes/configatron.rb
|
38
40
|
- lib/passes/defaults.rb
|
@@ -40,8 +42,10 @@ files:
|
|
40
42
|
- lib/passes/files.rb
|
41
43
|
- lib/passes/github.rb
|
42
44
|
- lib/passes/rails.rb
|
45
|
+
- lib/passes/specs.rb
|
46
|
+
- lib/passes/tests.rb
|
43
47
|
- README.textile
|
44
|
-
has_rdoc:
|
48
|
+
has_rdoc: true
|
45
49
|
homepage: http://github.com/simonmenke/gm
|
46
50
|
post_install_message:
|
47
51
|
rdoc_options: []
|