simonmenke-gm 0.1.3 → 0.1.4

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.
Files changed (53) hide show
  1. data/gm_behaviors/author_behavior.rb +29 -0
  2. data/gm_behaviors/bin_files_behavior.rb +10 -0
  3. data/gm_behaviors/dependencies_behavior.rb +22 -0
  4. data/gm_behaviors/executables_behavior.rb +13 -0
  5. data/gm_behaviors/general_behavior.rb +41 -0
  6. data/gm_behaviors/github_behavior.rb +11 -0
  7. data/gm_behaviors/gm_files_behavior.rb +13 -0
  8. data/gm_behaviors/lib_files_behavior.rb +10 -0
  9. data/gm_behaviors/rails_behavior.rb +11 -0
  10. data/gm_behaviors/rdoc_behavior.rb +34 -0
  11. data/gm_behaviors/rspec_behavior.rb +10 -0
  12. data/gm_behaviors/rubigen_behavior.rb +13 -0
  13. data/gm_behaviors/rubyforge_behavior.rb +12 -0
  14. data/gm_behaviors/test_behavior.rb +10 -0
  15. data/gm_behaviors/text_files_behavior.rb +10 -0
  16. data/gm_commands/build_command.rb +1 -1
  17. data/gm_commands/build_gemspec_command.rb +30 -0
  18. data/gm_commands/config_command.rb +2 -2
  19. data/gm_commands/gen_command.rb +1 -1
  20. data/gm_commands/publish_command.rb +2 -2
  21. data/gm_commands/spec_command.rb +1 -1
  22. data/gm_generators/mit_license/templates/LICENSE.txt +1 -1
  23. data/gm_networks/github_network.rb +25 -3
  24. data/gm_networks/rubyforge_network.rb +18 -0
  25. data/lib/extentions/gem.rb +0 -11
  26. data/lib/gm.rb +4 -5
  27. data/lib/gm/app.rb +29 -18
  28. data/lib/gm/behavior.rb +23 -0
  29. data/lib/gm/command.rb +3 -7
  30. data/lib/gm/configuration.rb +20 -0
  31. data/lib/gm/helpers.rb +20 -0
  32. data/lib/gm/loader.rb +1 -1
  33. data/lib/gm/network.rb +2 -6
  34. data/test/gem_extentions_test.rb +0 -15
  35. metadata +45 -46
  36. data/gm_passes/clean_file_list.rb +0 -15
  37. data/gm_passes/configatron.rb +0 -92
  38. data/gm_passes/defaults.rb +0 -10
  39. data/gm_passes/executables.rb +0 -10
  40. data/gm_passes/files.rb +0 -15
  41. data/gm_passes/github.rb +0 -9
  42. data/gm_passes/gm.rb +0 -10
  43. data/gm_passes/rails.rb +0 -8
  44. data/gm_passes/rubigen.rb +0 -10
  45. data/gm_passes/specs.rb +0 -7
  46. data/gm_passes/test.rb +0 -7
  47. data/lib/extentions/configatron.rb +0 -17
  48. data/lib/gm/configuration_pass.rb +0 -58
  49. data/lib/gm/configuration_pass_queue.rb +0 -70
  50. data/lib/gm/dsl.rb +0 -45
  51. data/test/configatron_test.rb +0 -15
  52. data/test/configuration_pass_queue_test.rb +0 -56
  53. data/test/configuration_pass_test.rb +0 -24
@@ -1,92 +0,0 @@
1
-
2
- configuration_pass :configatron_defaults do |spec|
3
-
4
- configatron.configure_from_hash({
5
- :general => {
6
- :name => nil,
7
- :version => nil,
8
- :summary => nil,
9
- :homepage => nil
10
- },
11
- :dependencies => [],
12
-
13
- :rdoc => {
14
- :enabled => true,
15
- :extra_files => [],
16
- :options => []
17
- },
18
-
19
- :author => {
20
- :name => nil,
21
- :email => nil
22
- },
23
-
24
- :github => {
25
- :project => nil,
26
- :username => nil
27
- },
28
-
29
- :rubyforge => {
30
- :project => nil
31
- },
32
-
33
- :excluded_passes => [],
34
-
35
- :gpg => {
36
- :key => nil
37
- }
38
- })
39
-
40
- end
41
-
42
- configuration_pass :configatron_global, :configatron_defaults do |s|
43
- c = configatron
44
- c.configure_from_yaml(File.expand_path('~/.gmrc'))
45
- end
46
-
47
- configuration_pass :configatron_local, :configatron_global do |s|
48
- c = configatron
49
- c.configure_from_yaml(File.expand_path('Gmfile'))
50
- end
51
-
52
- configuration_pass :configatron_normalize, { :before => :configatron,
53
- :after => :configatron_local } do |s|
54
- c = configatron
55
-
56
- if c.rubyforge.project.blank?
57
- c.rubyforge.project = c.general.name
58
- end
59
-
60
- if c.github.project.blank?
61
- c.github.project = c.general.name
62
- end
63
- end
64
-
65
- configuration_pass :configatron_exclude_passes, :configatron_local do |s|
66
- c = configatron
67
- c.excluded_passes.each do |pass|
68
- exclude_pass(pass)
69
- end
70
- end
71
-
72
- configuration_pass :configatron, :configatron_exclude_passes do |s|
73
- c = configatron
74
- s.name = c.general.name
75
- s.version = c.general.version
76
- s.summary = c.general.summary
77
- s.homepage = c.general.homepage
78
-
79
- s.author = c.author.name
80
- s.email = c.author.email
81
-
82
- s.rubyforge_project = c.rubyforge.project
83
-
84
- s.has_rdoc = c.rdoc.enabled
85
- s.extra_rdoc_files = c.rdoc.extra_files
86
- s.rdoc_options = c.rdoc.options
87
-
88
- c.dependencies.each do |dependency|
89
- gem, requirement = dependency.strip.split(/\s+/, 2)
90
- s.add_dependency gem.strip, requirement.strip
91
- end
92
- end
@@ -1,10 +0,0 @@
1
-
2
- desc "Initiate default values for the gemspec"
3
- initialization_pass :defaults do |spec|
4
-
5
- spec.platform = Gem::Platform::RUBY
6
- spec.files = []
7
- spec.test_files = []
8
- spec.require_paths = ['lib']
9
-
10
- end
@@ -1,10 +0,0 @@
1
-
2
- desc "Discover exceutables in bin/"
3
- pass :executables do |spec|
4
-
5
- paths = Dir.glob('bin/*')
6
- spec.executables = paths.collect do |path|
7
- File.basename(path)
8
- end
9
-
10
- end
data/gm_passes/files.rb DELETED
@@ -1,15 +0,0 @@
1
-
2
- desc "Collect lib files"
3
- pass :lib_files do |spec|
4
- spec.files += Dir.glob('lib/**/*.rb')
5
- end
6
-
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}')
15
- end
data/gm_passes/github.rb DELETED
@@ -1,9 +0,0 @@
1
-
2
- desc "Rename the gem in emulation mode (build, install) so it resembles a GitHub gem."
3
- finalization_pass :emulate_github do |spec|
4
-
5
- if GM::App.emulate?
6
- spec.name = "#{configatron.github.username}-#{configatron.github.project}"
7
- end
8
-
9
- end
data/gm_passes/gm.rb DELETED
@@ -1,10 +0,0 @@
1
-
2
- desc "Collect all GM related files (generators, commands, passes)"
3
- pass :gm_files do |spec|
4
-
5
- spec.files += Dir.glob('gm_commands/*_command.rb')
6
- spec.files += Dir.glob('gm_passes/*.rb')
7
- spec.files += Dir.glob('gm_networks/*_network.rb')
8
- spec.files += Dir.glob('gm_generators/**/*')
9
-
10
- end
data/gm_passes/rails.rb DELETED
@@ -1,8 +0,0 @@
1
-
2
- desc "Collect all Rails related files (rails/init.rb, tasks/*.rake)"
3
- pass :rails do |spec|
4
-
5
- spec.files += Dir.glob('rails/init.rb')
6
- spec.files += Dir.glob('tasks/*.rake')
7
-
8
- end
data/gm_passes/rubigen.rb DELETED
@@ -1,10 +0,0 @@
1
-
2
- desc "Collect rubigen files"
3
- pass :rubigen do |spec|
4
-
5
- paths = Dir.glob('*generators/**/*')
6
- paths.reject! { |path| File.directory? path }
7
- paths.reject! { |path| File.basename(path)[0,1] == "." }
8
- spec.files += paths
9
-
10
- end
data/gm_passes/specs.rb DELETED
@@ -1,7 +0,0 @@
1
-
2
- desc "Collect rspec files"
3
- pass :specs do |spec|
4
-
5
- spec.test_files += Dir.glob('spec/**/*.rb')
6
-
7
- end
data/gm_passes/test.rb DELETED
@@ -1,7 +0,0 @@
1
-
2
- desc "Collect Test::Unit files"
3
- pass :tests do |spec|
4
-
5
- spec.test_files += Dir.glob('test/**/*.rb')
6
-
7
- end
@@ -1,17 +0,0 @@
1
-
2
- class Configatron # :nodoc:
3
- class Store # :nodoc:
4
-
5
- def to_hash2
6
- @_store.inject({}) do |m, (k, v)|
7
- if v.is_a?(Configatron::Store)
8
- m[k.to_s] = v.to_hash2
9
- else
10
- m[k.to_s] = v
11
- end
12
- m
13
- end
14
- end
15
-
16
- end
17
- end
@@ -1,58 +0,0 @@
1
-
2
- module GM
3
-
4
- class ConfigurationPass
5
-
6
- attr_accessor :proc
7
- attr_accessor :name
8
- attr_accessor :fase
9
- attr_accessor :description
10
- attr_accessor :dependencies
11
- attr_accessor :run_before
12
- attr_accessor :run_after
13
-
14
- def initialize(name, description, options={}, &proc)
15
- @name = name.to_sym
16
- @description = description || ""
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 }
28
- end
29
-
30
- def register(fase)
31
- @fase = fase.to_sym
32
- GM.app.configuration_passes[@fase][@name] = self
33
- end
34
-
35
- def run(spec)
36
- GM.app.debug "Running #{@name} pass."
37
- @proc.call spec
38
- end
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
-
56
- end
57
-
58
- end
@@ -1,70 +0,0 @@
1
-
2
- module GM
3
-
4
- class ConfigurationPassQueue
5
- include Enumerable
6
-
7
- attr_accessor :fase
8
- attr_accessor :queue
9
- attr_accessor :passes
10
-
11
- def initialize(fase)
12
- @fase = fase
13
- reset!
14
- end
15
-
16
- def order
17
- return false unless @queue.nil?
18
-
19
- unordered_passes = @passes.values.dup
20
- ordered_passes = []
21
-
22
- unordered_passes.each { |pass| pass.dependencies }
23
-
24
- dependencies = Hash.new { |h,k| h[k.to_sym] = [] }
25
- unordered_passes.each do |pass|
26
- dependencies[pass.name].concat pass.dependencies.dup
27
- end
28
-
29
- dependencies.each do |k,v|
30
- v.delete(k) if v.include? k
31
- v.dup.each do |n|
32
- v.delete(n) if dependencies[n].nil?
33
- end
34
- end
35
-
36
- until unordered_passes.empty?
37
- unordered_passes.each do |pass|
38
- if dependencies[pass.name].empty?
39
- unordered_passes.delete(pass)
40
- ordered_passes << pass
41
- dependencies.each do |k,v|
42
- v.delete pass.name
43
- end
44
- end
45
- end
46
- end
47
-
48
- @queue = ordered_passes
49
- return true
50
- end
51
-
52
- def run(spec)
53
- each do |pass|
54
- pass.run spec
55
- end
56
- end
57
-
58
- def reset!
59
- @passes = GM.app.configuration_passes[@fase.to_sym].dup
60
- @queue = nil
61
- end
62
-
63
- def each(&block)
64
- order
65
- @queue.each(&block)
66
- end
67
-
68
- end
69
-
70
- end
data/lib/gm/dsl.rb DELETED
@@ -1,45 +0,0 @@
1
-
2
- module GM
3
-
4
- module DSL
5
-
6
- include GM::Loader
7
-
8
- loads :passes, :extends => GM::DSL, :only_eval => true
9
-
10
- def load_pass(path)
11
- GM::DSL.load_pass(path)
12
- end
13
-
14
- def desc(msg)
15
- @description = msg
16
- end
17
-
18
- def initialization_pass(name, options={}, &proc)
19
- register_pass(:initialization, name, options, &proc)
20
- end
21
-
22
- def configuration_pass(name, options={}, &proc)
23
- register_pass(:configuration, name, options, &proc)
24
- end
25
-
26
- def pass(name, options={}, &proc)
27
- register_pass(:normal, name, options, &proc)
28
- end
29
-
30
- def finalization_pass(name, options={}, &proc)
31
- register_pass(:finalization, name, options, &proc)
32
- end
33
-
34
- def exclude_pass(name, fase=:normal)
35
- GM.app.exclude_pass(name, fase)
36
- end
37
-
38
- def register_pass(fase, name, options, &proc) # :nodoc:
39
- pass = ConfigurationPass.new(name, @description, options, &proc).register(fase)
40
- @description = nil
41
- pass
42
- end
43
- end
44
-
45
- end
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class ConfigatronTest < Test::Unit::TestCase
4
-
5
- setup do
6
- @hash = { 'hello' => 'world', 'bye' => { 'kind' => 'moon', 'name' => 'Moon' } }
7
- configatron.reset!
8
- configatron.configure_from_hash(@hash)
9
- end
10
-
11
- should "#to_hash2 should return equivalent hash" do
12
- assert_equal @hash, configatron.to_hash2
13
- end
14
-
15
- end
@@ -1,56 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class ConfigurationPassQueueTest < Test::Unit::TestCase
4
-
5
- include GM::DSL
6
-
7
- before do
8
- GM.app.reset!
9
- pass(:pass_a) { |s| }
10
- pass(:pass_b) { |s| }
11
- pass(:pass_c, :before => :pass_a, :after => :pass_b) { |s| }
12
- pass(:pass_d, :pass_a) { |s| }
13
- end
14
-
15
- should "find passes in app" do
16
- queue = GM::ConfigurationPassQueue.new(:normal)
17
- assert_equal ["pass_a", "pass_b", "pass_c", "pass_d"], queue.passes.collect{ |n,v| n.to_s}.sort
18
- end
19
-
20
- should "be in dependency order" do
21
- queue = GM::ConfigurationPassQueue.new(:normal)
22
- queue.order
23
- assert_equal [:pass_b, :pass_c, :pass_a, :pass_d], queue.queue.collect { |pass| pass.name }
24
- end
25
-
26
- should "not find excluded passes in app" do
27
- exclude_pass(:pass_d)
28
- queue = GM::ConfigurationPassQueue.new(:normal)
29
- assert_equal ["pass_a", "pass_b", "pass_c"], queue.passes.collect{ |n,v| n.to_s}.sort
30
- end
31
-
32
- context "pass_c" do
33
- before { GM.app.configuration_passes[:normal].each { |n, p| p.dependencies } }
34
- should "depend on pass_b" do
35
- deps = GM.app.configuration_passes[:normal][:pass_c].dependencies
36
- assert_equal [:pass_b], deps
37
- end
38
- end
39
-
40
- context "pass_d" do
41
- before { GM.app.configuration_passes[:normal].each { |n, p| p.dependencies } }
42
- should "depend on pass_b" do
43
- deps = GM.app.configuration_passes[:normal][:pass_d].dependencies
44
- assert_equal [:pass_a], deps
45
- end
46
- end
47
-
48
- context "pass_d" do
49
- before { GM.app.configuration_passes[:normal].each { |n, p| p.dependencies } }
50
- should "depend on pass_b" do
51
- deps = GM.app.configuration_passes[:normal][:pass_a].dependencies
52
- assert_equal [:pass_c], deps
53
- end
54
- end
55
-
56
- end