simonmenke-gm 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +7 -1
- data/gm_commands/build_command.rb +1 -0
- data/gm_commands/help_command.rb +30 -3
- data/gm_commands/install_command.rb +2 -0
- data/gm_commands/spec_command.rb +1 -0
- data/gm_generators/gem/templates/Gmfile +4 -0
- data/gm_generators/test/test_generator.rb +1 -2
- data/gm_passes/clean_file_list.rb +11 -0
- data/gm_passes/configatron.rb +3 -3
- data/gm_passes/defaults.rb +2 -0
- data/gm_passes/executables.rb +1 -0
- data/gm_passes/files.rb +11 -10
- data/gm_passes/github.rb +1 -0
- data/gm_passes/gm.rb +3 -1
- data/gm_passes/rails.rb +1 -0
- data/gm_passes/rubigen.rb +1 -0
- data/gm_passes/specs.rb +1 -0
- data/gm_passes/test.rb +1 -0
- data/lib/extentions/gem.rb +22 -0
- data/lib/gm.rb +6 -0
- data/lib/gm/app.rb +17 -4
- data/lib/gm/configuration_pass.rb +35 -3
- data/lib/gm/configuration_pass_queue.rb +49 -14
- data/lib/gm/dsl.rb +19 -8
- metadata +34 -28
- data/gm_generators/gem/templates/gmfile.yml +0 -3
data/README.textile
CHANGED
@@ -2,4 +2,10 @@ h1. GM (GemMake)
|
|
2
2
|
|
3
3
|
GM is a gem and gemspec builder for use with github.
|
4
4
|
|
5
|
-
For more info/docs go to "http://simonmenke.github.com/gm":http://simonmenke.github.com/gm
|
5
|
+
For more info/docs go to "http://simonmenke.github.com/gm":http://simonmenke.github.com/gm
|
6
|
+
|
7
|
+
h2. Todo
|
8
|
+
|
9
|
+
* Document extendability
|
10
|
+
* Document architecture
|
11
|
+
* Implement CDN interfaces (rubyforge, github, your site, ...)
|
data/gm_commands/help_command.rb
CHANGED
@@ -8,18 +8,45 @@ module GM
|
|
8
8
|
def run
|
9
9
|
puts "#{File.basename($0)} <command> <options>"
|
10
10
|
puts options.to_s
|
11
|
+
puts ""
|
11
12
|
puts "Commands:"
|
12
|
-
|
13
|
+
command_descriptions
|
14
|
+
puts ""
|
15
|
+
puts "Passes:"
|
16
|
+
passes_in_running_order
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def passes_in_running_order
|
22
|
+
format = "% 3d %- 20s %s"
|
23
|
+
|
24
|
+
puts "- initialization"
|
25
|
+
ConfigurationPassQueue.new(:initialization).each_with_index do |pass, idx|
|
26
|
+
puts format % [idx, pass.name, pass.description]
|
27
|
+
end
|
28
|
+
puts "- configuration"
|
29
|
+
ConfigurationPassQueue.new(:configuration).each_with_index do |pass, idx|
|
30
|
+
puts format % [idx, pass.name, pass.description]
|
31
|
+
end
|
32
|
+
puts "- normal"
|
33
|
+
ConfigurationPassQueue.new(:normal).each_with_index do |pass, idx|
|
34
|
+
puts format % [idx, pass.name, pass.description]
|
35
|
+
end
|
36
|
+
puts "- finalization"
|
37
|
+
ConfigurationPassQueue.new(:finalization).each_with_index do |pass, idx|
|
38
|
+
puts format % [idx, pass.name, pass.description]
|
39
|
+
end
|
13
40
|
end
|
14
41
|
|
15
42
|
def command_descriptions
|
16
43
|
descriptions = []
|
17
|
-
app.commands.
|
44
|
+
app.commands.each do |name, cmd|
|
18
45
|
descriptions << [name.to_s.underscore.sub('_command', ''), cmd.description]
|
19
46
|
end
|
20
47
|
descriptions.sort { |a,b| a.first <=> b.first }
|
21
48
|
descriptions.collect do |(name, desc)|
|
22
|
-
"
|
49
|
+
puts "%- 17s %s" % [name, desc]
|
23
50
|
end
|
24
51
|
end
|
25
52
|
|
data/gm_commands/spec_command.rb
CHANGED
@@ -12,11 +12,10 @@ class TestGenerator < RubiGen::Base
|
|
12
12
|
|
13
13
|
def manifest
|
14
14
|
record do |m|
|
15
|
-
|
16
15
|
m.directory ''
|
17
16
|
%w( test ).each { |path| m.directory path }
|
18
17
|
|
19
|
-
m.template "test/test_helper.rb", "test/test_helper.rb"
|
18
|
+
m.template "test/test_helper.rb", "test/test_helper.rb" unless File.exist? "test/test_helper.rb"
|
20
19
|
m.template "test/test_case.rb", "test/#{@file_name}_test.rb" unless @file_name.nil?
|
21
20
|
end
|
22
21
|
end
|
data/gm_passes/configatron.rb
CHANGED
@@ -37,12 +37,12 @@ end
|
|
37
37
|
|
38
38
|
configuration_pass :configatron_global, :configatron_defaults do |s|
|
39
39
|
c = configatron
|
40
|
-
c.configure_from_yaml(File.expand_path('~/.gmrc
|
40
|
+
c.configure_from_yaml(File.expand_path('~/.gmrc'))
|
41
41
|
end
|
42
42
|
|
43
43
|
configuration_pass :configatron_local, :configatron_global do |s|
|
44
44
|
c = configatron
|
45
|
-
c.configure_from_yaml(File.expand_path('
|
45
|
+
c.configure_from_yaml(File.expand_path('Gmfile'))
|
46
46
|
end
|
47
47
|
|
48
48
|
configuration_pass :configatron_normalize, :configatron_local do |s|
|
@@ -64,7 +64,7 @@ configuration_pass :configatron_exclude_passes, :configatron_local do |s|
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
configuration_pass :configatron, :configatron_exclude_passes do |s|
|
68
68
|
c = configatron
|
69
69
|
s.name = c.general.name
|
70
70
|
s.version = c.general.version
|
data/gm_passes/defaults.rb
CHANGED
data/gm_passes/executables.rb
CHANGED
data/gm_passes/files.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
files
|
5
|
-
files += Dir.glob('bin/*')
|
6
|
-
files += Dir.glob('lib/**/*.rb')
|
7
|
-
files += Dir.glob('*.{txt,rdoc,textile}')
|
8
|
-
spec.files += files
|
9
|
-
|
2
|
+
desc "Collect lib files"
|
3
|
+
pass :lib_files do |spec|
|
4
|
+
spec.files += Dir.glob('lib/**/*.rb')
|
10
5
|
end
|
11
6
|
|
12
|
-
|
13
|
-
|
7
|
+
desc "Collect bin files"
|
8
|
+
pass :bin_files, :before => :executables do |spec|
|
9
|
+
spec.files += Dir.glob('bin/*')
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Collect text files"
|
13
|
+
pass :text_files do |spec|
|
14
|
+
spec.files += Dir.glob('*.{txt,rdoc,textile}')
|
14
15
|
end
|
data/gm_passes/github.rb
CHANGED
data/gm_passes/gm.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
desc "Collect all GM related files (generators, commands, passes)"
|
3
|
+
pass :gm_files do |spec|
|
3
4
|
|
4
5
|
spec.files += Dir.glob('gm_commands/*_command.rb')
|
5
6
|
spec.files += Dir.glob('gm_passes/*.rb')
|
7
|
+
spec.files += Dir.glob('gm_generators/**/*')
|
6
8
|
|
7
9
|
end
|
data/gm_passes/rails.rb
CHANGED
data/gm_passes/rubigen.rb
CHANGED
data/gm_passes/specs.rb
CHANGED
data/gm_passes/test.rb
CHANGED
data/lib/extentions/gem.rb
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
|
2
2
|
module Gem # :nodoc:
|
3
3
|
|
4
|
+
def self.find_recent_files(path)
|
5
|
+
specs = searcher.find_all path
|
6
|
+
specs = specs.inject({}) do |s, spec|
|
7
|
+
if s[spec.name].nil?
|
8
|
+
s[spec.name] = spec
|
9
|
+
elsif (s[spec.name] <=> spec) == -1
|
10
|
+
s[spec.name] = spec
|
11
|
+
end
|
12
|
+
s
|
13
|
+
end.values
|
14
|
+
|
15
|
+
specs.map do |spec|
|
16
|
+
searcher.matching_files spec, path
|
17
|
+
end.flatten
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find_recent_resources(path)
|
21
|
+
find_recent_files(File.join('..',path)).map do |gem_path|
|
22
|
+
File.expand_path(gem_path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
4
26
|
class Specification # :nodoc:
|
5
27
|
|
6
28
|
alias_method :ruby_code_old, :ruby_code
|
data/lib/gm.rb
CHANGED
@@ -10,8 +10,14 @@ rescue LoadError
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module GM
|
13
|
+
|
14
|
+
def self.app
|
15
|
+
GM::App.instance
|
16
|
+
end
|
17
|
+
|
13
18
|
end
|
14
19
|
|
20
|
+
require File.dirname(__FILE__)+'/extentions/gem'
|
15
21
|
require File.dirname(__FILE__)+'/gm/app'
|
16
22
|
require File.dirname(__FILE__)+'/gm/command'
|
17
23
|
require File.dirname(__FILE__)+'/gm/configuration_pass'
|
data/lib/gm/app.rb
CHANGED
@@ -24,6 +24,7 @@ module GM
|
|
24
24
|
# extra options provided by the app.
|
25
25
|
def extra_options(options)
|
26
26
|
options.flag 'v', 'verbose', :desc => 'Print more information.'
|
27
|
+
options.flag 'd', 'debug', :desc => 'Print debugging information.'
|
27
28
|
end
|
28
29
|
|
29
30
|
# run the app
|
@@ -39,6 +40,7 @@ module GM
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def build_gemspec
|
43
|
+
self.info "Generating your gemspec..."
|
42
44
|
@gemspec = Gem::Specification.new do |s|
|
43
45
|
ConfigurationPassQueue.new(:initialization).run(s)
|
44
46
|
ConfigurationPassQueue.new(:configuration).run(s)
|
@@ -48,20 +50,31 @@ module GM
|
|
48
50
|
@gemspec.validate
|
49
51
|
end
|
50
52
|
|
53
|
+
def info(msg)
|
54
|
+
puts msg if ARGV.include? '-v' or @options.verbose?
|
55
|
+
end
|
56
|
+
|
57
|
+
def debug(msg)
|
58
|
+
puts msg if ARGV.include? '-d' or @options.debug?
|
59
|
+
end
|
60
|
+
|
51
61
|
private
|
52
62
|
|
53
63
|
# load all passes
|
54
64
|
def load_passes
|
55
|
-
|
56
|
-
Gem.find_resources('gm_passes/*.rb').uniq.each do |path|
|
65
|
+
Gem.find_recent_resources('gm_passes/*.rb').uniq.each do |path|
|
57
66
|
GM::DSL.load_pass path
|
58
67
|
end
|
68
|
+
@configuration_passes.each do |fase, passes|
|
69
|
+
passes.each do |name, pass|
|
70
|
+
pass.dependencies
|
71
|
+
end
|
72
|
+
end
|
59
73
|
end
|
60
74
|
|
61
75
|
# load all commands
|
62
76
|
def load_commands
|
63
|
-
|
64
|
-
Gem.find_resources('gm_commands/*_command.rb').uniq.each do |path|
|
77
|
+
Gem.find_recent_resources('gm_commands/*_command.rb').uniq.each do |path|
|
65
78
|
GM::Command.load_command path
|
66
79
|
end
|
67
80
|
end
|
@@ -5,22 +5,54 @@ module GM
|
|
5
5
|
|
6
6
|
attr_accessor :proc
|
7
7
|
attr_accessor :name
|
8
|
+
attr_accessor :fase
|
9
|
+
attr_accessor :description
|
8
10
|
attr_accessor :dependencies
|
11
|
+
attr_accessor :run_before
|
12
|
+
attr_accessor :run_after
|
9
13
|
|
10
|
-
def initialize(name,
|
14
|
+
def initialize(name, description, options={}, &proc)
|
11
15
|
@name = name.to_sym
|
12
|
-
@
|
16
|
+
@description = description || ""
|
13
17
|
@proc = proc || Proc.new { |spec| }
|
18
|
+
@dependencies = nil
|
19
|
+
|
20
|
+
case options
|
21
|
+
when Hash
|
22
|
+
@run_after = options.delete(:after)
|
23
|
+
@run_before = options.delete(:before)
|
24
|
+
else @run_after = [options]
|
25
|
+
end
|
26
|
+
@run_after = [@run_after].flatten.compact.collect { |dep| dep.to_sym }
|
27
|
+
@run_before = [@run_before].flatten.compact.collect { |dep| dep.to_sym }
|
14
28
|
end
|
15
29
|
|
16
30
|
def register(fase)
|
17
|
-
|
31
|
+
@fase = fase.to_sym
|
32
|
+
GM.app.configuration_passes[@fase][@name] = self
|
18
33
|
end
|
19
34
|
|
20
35
|
def run(spec)
|
36
|
+
GM.app.debug "Running #{@name} pass."
|
21
37
|
@proc.call spec
|
22
38
|
end
|
23
39
|
|
40
|
+
def dependencies
|
41
|
+
return @dependencies unless @dependencies.nil?
|
42
|
+
@dependencies = @run_after.dup
|
43
|
+
@run_before.each do |dep|
|
44
|
+
pass = GM.app.configuration_passes[@fase][dep]
|
45
|
+
pass.add_dependency(@name) unless pass.nil?
|
46
|
+
end
|
47
|
+
@dependencies
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_dependency(dep)
|
51
|
+
return if dep.nil?
|
52
|
+
@run_after << dep
|
53
|
+
@dependencies << dep unless @dependencies.nil?
|
54
|
+
end
|
55
|
+
|
24
56
|
end
|
25
57
|
|
26
58
|
end
|
@@ -2,32 +2,67 @@
|
|
2
2
|
module GM
|
3
3
|
|
4
4
|
class ConfigurationPassQueue
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
attr_accessor :fase
|
5
8
|
attr_accessor :queue
|
6
9
|
attr_accessor :passes
|
7
|
-
attr_accessor :processed_passes
|
8
10
|
|
9
11
|
def initialize(fase)
|
10
|
-
@
|
11
|
-
|
12
|
-
@queue = @passes.values
|
12
|
+
@fase = fase
|
13
|
+
reset!
|
13
14
|
end
|
14
15
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def order
|
17
|
+
return false unless @queue.nil?
|
18
|
+
|
19
|
+
unordered_passes = @passes.values.dup
|
20
|
+
ordered_passes = []
|
21
|
+
|
22
|
+
dependencies = Hash.new { |h,k| h[k.to_sym] = [] }
|
23
|
+
unordered_passes.each do |pass|
|
24
|
+
dependencies[pass.name].concat pass.dependencies.dup
|
25
|
+
end
|
26
|
+
|
27
|
+
dependencies.each do |k,v|
|
28
|
+
v.delete(k) if v.include? k
|
29
|
+
v.dup.each do |n|
|
30
|
+
v.delete(n) if dependencies[n].nil?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
until unordered_passes.empty?
|
35
|
+
unordered_passes.each do |pass|
|
36
|
+
if dependencies[pass.name].empty?
|
37
|
+
unordered_passes.delete(pass)
|
38
|
+
ordered_passes << pass
|
39
|
+
dependencies.each do |k,v|
|
40
|
+
v.delete pass.name
|
41
|
+
end
|
20
42
|
end
|
21
43
|
end
|
22
44
|
end
|
45
|
+
|
46
|
+
@queue = ordered_passes
|
47
|
+
return true
|
23
48
|
end
|
24
49
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
50
|
+
def run(spec)
|
51
|
+
each do |pass|
|
52
|
+
pass.run spec
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def reset!
|
57
|
+
@passes = GM::App.instance.configuration_passes[@fase.to_sym].dup
|
58
|
+
@queue = nil
|
30
59
|
end
|
60
|
+
|
61
|
+
def each(&block)
|
62
|
+
order
|
63
|
+
@queue.each(&block)
|
64
|
+
end
|
65
|
+
|
31
66
|
end
|
32
67
|
|
33
68
|
end
|
data/lib/gm/dsl.rb
CHANGED
@@ -11,17 +11,28 @@ module GM
|
|
11
11
|
end
|
12
12
|
module_function :load_pass
|
13
13
|
|
14
|
-
def
|
15
|
-
|
14
|
+
def desc(msg)
|
15
|
+
@description = msg
|
16
16
|
end
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
def initialization_pass(name, options={}, &proc)
|
19
|
+
ConfigurationPass.new(name, @description, options, &proc).register(:initialization)
|
20
|
+
@description = nil
|
19
21
|
end
|
20
|
-
|
21
|
-
|
22
|
+
|
23
|
+
def configuration_pass(name, options={}, &proc)
|
24
|
+
ConfigurationPass.new(name, @description, options, &proc).register(:configuration)
|
25
|
+
@description = nil
|
22
26
|
end
|
23
|
-
|
24
|
-
|
27
|
+
|
28
|
+
def pass(name, options={}, &proc)
|
29
|
+
ConfigurationPass.new(name, @description, options, &proc).register(:normal)
|
30
|
+
@description = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def finalization_pass(name, options={}, &proc)
|
34
|
+
ConfigurationPass.new(name, @description, options, &proc).register(:finalization)
|
35
|
+
@description = nil
|
25
36
|
end
|
26
37
|
|
27
38
|
def exclude_pass(name, fase=:normal)
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-15 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,15 +39,6 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.5.1
|
41
41
|
version:
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: reverse-require
|
44
|
-
version_requirement:
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 0.3.1
|
50
|
-
version:
|
51
42
|
description:
|
52
43
|
email: simon.menke@gmail.com
|
53
44
|
executables:
|
@@ -58,8 +49,6 @@ extensions: []
|
|
58
49
|
extra_rdoc_files: []
|
59
50
|
|
60
51
|
files:
|
61
|
-
- bin/gm
|
62
|
-
- bin/gmm
|
63
52
|
- lib/extentions/gem.rb
|
64
53
|
- lib/gm/app.rb
|
65
54
|
- lib/gm/command.rb
|
@@ -67,8 +56,19 @@ files:
|
|
67
56
|
- lib/gm/configuration_pass_queue.rb
|
68
57
|
- lib/gm/dsl.rb
|
69
58
|
- lib/gm.rb
|
70
|
-
-
|
71
|
-
-
|
59
|
+
- gm_generators/bin/bin_generator.rb
|
60
|
+
- gm_generators/bin/templates/bin/bin.rb
|
61
|
+
- gm_generators/gem/gem_generator.rb
|
62
|
+
- gm_generators/gem/templates/Gmfile
|
63
|
+
- gm_generators/gem/templates/lib/module.rb
|
64
|
+
- gm_generators/gem/templates/README.textile
|
65
|
+
- gm_generators/mit_license/mit_license_generator.rb
|
66
|
+
- gm_generators/mit_license/templates/LICENSE.txt
|
67
|
+
- gm_generators/rails/rails_generator.rb
|
68
|
+
- gm_generators/rails/templates/rails/init.rb
|
69
|
+
- gm_generators/test/templates/test/test_case.rb
|
70
|
+
- gm_generators/test/templates/test/test_helper.rb
|
71
|
+
- gm_generators/test/test_generator.rb
|
72
72
|
- gm_commands/build_command.rb
|
73
73
|
- gm_commands/clean_command.rb
|
74
74
|
- gm_commands/create_command.rb
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- gm_commands/help_command.rb
|
77
77
|
- gm_commands/install_command.rb
|
78
78
|
- gm_commands/spec_command.rb
|
79
|
+
- gm_passes/clean_file_list.rb
|
79
80
|
- gm_passes/configatron.rb
|
80
81
|
- gm_passes/defaults.rb
|
81
82
|
- gm_passes/executables.rb
|
@@ -86,19 +87,24 @@ files:
|
|
86
87
|
- gm_passes/rubigen.rb
|
87
88
|
- gm_passes/specs.rb
|
88
89
|
- gm_passes/test.rb
|
89
|
-
- gm_generators/bin
|
90
|
-
- gm_generators/bin/templates
|
91
|
-
- gm_generators/
|
92
|
-
- gm_generators/gem
|
93
|
-
- gm_generators/gem/templates
|
94
|
-
- gm_generators/gem/templates/lib
|
95
|
-
- gm_generators/mit_license
|
96
|
-
- gm_generators/mit_license/templates
|
97
|
-
- gm_generators/rails
|
98
|
-
- gm_generators/rails/templates
|
99
|
-
- gm_generators/
|
100
|
-
- gm_generators/test
|
101
|
-
- gm_generators/test/
|
90
|
+
- gm_generators/bin
|
91
|
+
- gm_generators/bin/templates
|
92
|
+
- gm_generators/bin/templates/bin
|
93
|
+
- gm_generators/gem
|
94
|
+
- gm_generators/gem/templates
|
95
|
+
- gm_generators/gem/templates/lib
|
96
|
+
- gm_generators/mit_license
|
97
|
+
- gm_generators/mit_license/templates
|
98
|
+
- gm_generators/rails
|
99
|
+
- gm_generators/rails/templates
|
100
|
+
- gm_generators/rails/templates/rails
|
101
|
+
- gm_generators/test
|
102
|
+
- gm_generators/test/templates
|
103
|
+
- gm_generators/test/templates/test
|
104
|
+
- bin/gm
|
105
|
+
- bin/gmm
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.textile
|
102
108
|
has_rdoc: true
|
103
109
|
homepage: http://github.com/simonmenke/gm
|
104
110
|
post_install_message:
|