simonmenke-gm 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gmm ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__)+'/../lib/gm'
4
+
5
+ GM::App.instance.run
@@ -3,10 +3,16 @@ module GM
3
3
 
4
4
  class BuildCommand < Command
5
5
 
6
+ desc "Build the gem (gem will be in ./pkg)"
7
+
6
8
  def run
7
9
  app.emulate = true
8
10
  app.build_gemspec
9
- app.build_gem
11
+
12
+ builder = Gem::Builder.new app.gemspec
13
+ app.gem_file_name = builder.build
14
+ system("rm -f pkg/#{app.gem_file_name}")
15
+ system("mkdir -p pkg && mv #{app.gem_file_name} pkg/")
10
16
  end
11
17
 
12
18
  end
@@ -3,8 +3,10 @@ module GM
3
3
 
4
4
  class CleanCommand < Command
5
5
 
6
+ desc "Remove the build files."
7
+
6
8
  def run
7
- system("rm -rf pkg/* *.gemspec")
9
+ system("rm -rf pkg")
8
10
  end
9
11
 
10
12
  end
@@ -3,11 +3,10 @@ module GM
3
3
 
4
4
  class CreateCommand < Command
5
5
 
6
+ desc "Generate the basic directory tree for a new gem"
7
+
6
8
  def run
7
- @gen_options = ARGV
8
-
9
- RubiGen::Base.use_component_sources!(:gm)
10
- RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'gem')
9
+ Command.run(:gen, ['gem', *ARGV])
11
10
  end
12
11
 
13
12
  end
@@ -3,13 +3,15 @@ module GM
3
3
 
4
4
  class GenCommand < Command
5
5
 
6
+ desc "Use a generator"
7
+
6
8
  def run
7
- app.build_gemspec
8
- @gen_name = ARGV.shift
9
- @gen_options = ARGV
9
+ app.build_gemspec if File.exist?('./gmfile.yml')
10
+ @gen_name = self.argv.shift
11
+ @gen_options = self.argv
10
12
 
11
13
  RubiGen::Base.use_component_sources!(:gm)
12
- RubiGen::Scripts::Generate.new.run(ARGV, :generator => @gen_name)
14
+ RubiGen::Scripts::Generate.new.run(@gen_options, :generator => @gen_name)
13
15
  end
14
16
 
15
17
  end
@@ -3,10 +3,24 @@ module GM
3
3
 
4
4
  class HelpCommand < Command
5
5
 
6
+ desc "Display this help message"
7
+
6
8
  def run
7
9
  puts "#{File.basename($0)} <command> <options>"
8
- puts "Commands: #{App.instance.command_names.join(' ')}"
9
10
  puts options.to_s
11
+ puts "Commands:"
12
+ puts command_descriptions
13
+ end
14
+
15
+ def command_descriptions
16
+ descriptions = []
17
+ app.commands.collect do |name, cmd|
18
+ descriptions << [name.to_s.underscore.sub('_command', ''), cmd.description]
19
+ end
20
+ descriptions.sort { |a,b| a.first <=> b.first }
21
+ descriptions.collect do |(name, desc)|
22
+ "#{name+(" "*(17-name.length))} #{desc}"
23
+ end
10
24
  end
11
25
 
12
26
  end
@@ -3,10 +3,10 @@ module GM
3
3
 
4
4
  class InstallCommand < Command
5
5
 
6
+ desc "Install the gem localy"
7
+
6
8
  def run
7
- app.emulate = true
8
- app.build_gemspec
9
- app.build_gem
9
+ Command.run(:build)
10
10
  system("sudo gem install pkg/#{app.gem_file_name}")
11
11
  end
12
12
 
@@ -3,6 +3,8 @@ module GM
3
3
 
4
4
  class SpecCommand < Command
5
5
 
6
+ desc "Dump the gemspec file."
7
+
6
8
  def run
7
9
  app.build_gemspec
8
10
  File.open("#{app.gemspec.name}.gemspec", 'w+') do |f|
@@ -1,5 +1,5 @@
1
1
 
2
- pre_pass :configatron_defaults do |spec|
2
+ configuration_pass :configatron_defaults do |spec|
3
3
 
4
4
  configatron.configure_from_hash({
5
5
  :general => {
@@ -35,17 +35,17 @@ pre_pass :configatron_defaults do |spec|
35
35
 
36
36
  end
37
37
 
38
- pre_pass :configatron_global, :configatron_defaults do |s|
38
+ configuration_pass :configatron_global, :configatron_defaults do |s|
39
39
  c = configatron
40
40
  c.configure_from_yaml(File.expand_path('~/.gmrc.yml'))
41
41
  end
42
42
 
43
- pre_pass :configatron_local, :configatron_global do |s|
43
+ configuration_pass :configatron_local, :configatron_global do |s|
44
44
  c = configatron
45
45
  c.configure_from_yaml(File.expand_path('gmfile.yml'))
46
46
  end
47
47
 
48
- pre_pass :configatron_normalize, :configatron_local do |s|
48
+ configuration_pass :configatron_normalize, :configatron_local do |s|
49
49
  c = configatron
50
50
 
51
51
  if c.rubyforge.project.nil?
@@ -57,7 +57,7 @@ pre_pass :configatron_normalize, :configatron_local do |s|
57
57
  end
58
58
  end
59
59
 
60
- pre_pass :configatron_exclude_passes, :configatron_local do |s|
60
+ configuration_pass :configatron_exclude_passes, :configatron_local do |s|
61
61
  c = configatron
62
62
  c.excluded_passes.each do |pass|
63
63
  exclude_pass(pass)
@@ -1,5 +1,5 @@
1
1
 
2
- init_pass :defaults do |spec|
2
+ initialization_pass :defaults do |spec|
3
3
 
4
4
  spec.platform = Gem::Platform::RUBY
5
5
  spec.files = []
data/gm_passes/github.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- post_pass :emulate_github do |spec|
2
+ finalization_pass :emulate_github do |spec|
3
3
 
4
4
  if GM::App.emulate?
5
5
  spec.name = "#{configatron.github.username}-#{configatron.github.project}"
data/lib/gm/app.rb CHANGED
@@ -30,14 +30,7 @@ module GM
30
30
  def run
31
31
  load_passes
32
32
  load_commands
33
- Command.build(self).run
34
- end
35
-
36
- # ge a list of all the command names
37
- def command_names
38
- commands.keys.collect do |name|
39
- name.to_s.gsub(/[A-Z]/){|m|'_'+m.downcase}.sub(/^_/, '').sub('_command', '')
40
- end.sort
33
+ Command.run
41
34
  end
42
35
 
43
36
  # should we emulate github?
@@ -47,21 +40,14 @@ module GM
47
40
 
48
41
  def build_gemspec
49
42
  @gemspec = Gem::Specification.new do |s|
50
- ConfigurationPassQueue.new(:init).run(s)
51
- ConfigurationPassQueue.new(:pre).run(s)
43
+ ConfigurationPassQueue.new(:initialization).run(s)
44
+ ConfigurationPassQueue.new(:configuration).run(s)
52
45
  ConfigurationPassQueue.new(:normal).run(s)
53
- ConfigurationPassQueue.new(:post).run(s)
46
+ ConfigurationPassQueue.new(:finalization).run(s)
54
47
  end
55
48
  @gemspec.validate
56
49
  end
57
50
 
58
- def build_gem
59
- builder = Gem::Builder.new @gemspec
60
- @gem_file_name = builder.build
61
- system("rm -f pkg/#{@gem_file_name}")
62
- system("mkdir -p pkg && mv #{@gem_file_name} pkg/")
63
- end
64
-
65
51
  private
66
52
 
67
53
  # load all passes
data/lib/gm/command.rb CHANGED
@@ -4,8 +4,19 @@ module GM
4
4
  class Command
5
5
 
6
6
  attr_accessor :app
7
+ attr_accessor :argv
7
8
  attr_accessor :options
8
9
 
10
+ def self.desc(text)
11
+ module_eval %{
12
+ def self.description
13
+ #{text.inspect}
14
+ end
15
+ }
16
+ end
17
+
18
+ desc ""
19
+
9
20
  # load a command from a file
10
21
  def self.load_command(path)
11
22
  cmd_name = File.basename(path, '.rb')
@@ -22,21 +33,32 @@ module GM
22
33
  end
23
34
 
24
35
  # build a command
25
- def self.build(app)
26
- cmd_name = (ARGV.detect {|i| not i =~ /^--?/ } || 'help')
27
- ARGV.delete(cmd_name)
28
- cmd_name = cmd_name + '_command'
29
- cmd_name = cmd_name.gsub(/(^|_)([a-z])/i) { |m| $2.upcase }
30
- cmd_class = GM::App.instance.commands[cmd_name.to_sym] || GM::App.instance.commands[:HelpCommand]
31
- cmd = cmd_class.new
36
+ def self.run(cmd_name=nil, argv=ARGV)
37
+ app = GM::App.instance
38
+ cmd = self.build(cmd_name, argv)
32
39
  cmd.app = app
33
- cmd.options = app.options = Clip do |p|
40
+ cmd.options = app.options = Clip(argv) do |p|
34
41
  app.extra_options(p)
35
42
  cmd.extra_options(p)
36
43
  end
37
- ARGV.clear
38
- ARGV.concat(cmd.options.remainder)
39
- cmd
44
+ argv.clear
45
+ argv.concat(cmd.options.remainder)
46
+ cmd.argv = argv
47
+ cmd.run
48
+ argv
49
+ end
50
+
51
+ # build a command
52
+ def self.build(cmd_name=nil, argv=ARGV)
53
+ if cmd_name.nil?
54
+ cmd_name = (argv.detect {|i| not i =~ /^--?/ } || 'help')
55
+ argv.delete(cmd_name)
56
+ end
57
+ app = GM::App.instance
58
+ cmd_name = "#{cmd_name}_command".camelize
59
+ cmd_class = app.commands[cmd_name.to_sym]
60
+ cmd_class ||= app.commands[:HelpCommand]
61
+ cmd_class.new
40
62
  end
41
63
 
42
64
  # A command can overwrite this method in order to add extra command line options.
data/lib/gm/dsl.rb CHANGED
@@ -11,18 +11,19 @@ module GM
11
11
  end
12
12
  module_function :load_pass
13
13
 
14
- def init_pass(name, dependencies=[], &proc)
15
- ConfigurationPass.new(name, dependencies, &proc).register(:init)
14
+ def initialization_pass(name, dependencies=[], &proc)
15
+ ConfigurationPass.new(name, dependencies, &proc).register(:initialization)
16
16
  end
17
- def pre_pass(name, dependencies=[], &proc)
18
- ConfigurationPass.new(name, dependencies, &proc).register(:pre)
17
+ def configuration_pass(name, dependencies=[], &proc)
18
+ ConfigurationPass.new(name, dependencies, &proc).register(:configuration)
19
19
  end
20
20
  def pass(name, dependencies=[], &proc)
21
21
  ConfigurationPass.new(name, dependencies, &proc).register(:normal)
22
22
  end
23
- def post_pass(name, dependencies=[], &proc)
24
- ConfigurationPass.new(name, dependencies, &proc).register(:post)
23
+ def finalization_pass(name, dependencies=[], &proc)
24
+ ConfigurationPass.new(name, dependencies, &proc).register(:finalization)
25
25
  end
26
+
26
27
  def exclude_pass(name, fase=:normal)
27
28
  GM::App.instance.exclude_pass(name, fase)
28
29
  end
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
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -10,7 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
 
12
12
  date: 2009-01-14 00:00:00 -08:00
13
- default_executable: gm
13
+ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: configatron
@@ -52,12 +52,14 @@ description:
52
52
  email: simon.menke@gmail.com
53
53
  executables:
54
54
  - gm
55
+ - gmm
55
56
  extensions: []
56
57
 
57
58
  extra_rdoc_files: []
58
59
 
59
60
  files:
60
61
  - bin/gm
62
+ - bin/gmm
61
63
  - lib/extentions/gem.rb
62
64
  - lib/gm/app.rb
63
65
  - lib/gm/command.rb
@@ -67,19 +69,6 @@ files:
67
69
  - lib/gm.rb
68
70
  - LICENSE.txt
69
71
  - README.textile
70
- - gm_generators/bin/bin_generator.rb
71
- - gm_generators/bin/templates/bin/bin.rb
72
- - gm_generators/gem/gem_generator.rb
73
- - gm_generators/gem/templates/gmfile.yml
74
- - gm_generators/gem/templates/lib/module.rb
75
- - gm_generators/gem/templates/README.textile
76
- - gm_generators/mit_license/mit_license_generator.rb
77
- - gm_generators/mit_license/templates/LICENSE.txt
78
- - gm_generators/rails/rails_generator.rb
79
- - gm_generators/rails/templates/rails/init.rb
80
- - gm_generators/test/templates/test/test_case.rb
81
- - gm_generators/test/templates/test/test_helper.rb
82
- - gm_generators/test/test_generator.rb
83
72
  - gm_commands/build_command.rb
84
73
  - gm_commands/clean_command.rb
85
74
  - gm_commands/create_command.rb
@@ -97,6 +86,19 @@ files:
97
86
  - gm_passes/rubigen.rb
98
87
  - gm_passes/specs.rb
99
88
  - gm_passes/test.rb
89
+ - gm_generators/bin/bin_generator.rb
90
+ - gm_generators/bin/templates/bin/bin.rb
91
+ - gm_generators/gem/gem_generator.rb
92
+ - gm_generators/gem/templates/README.textile
93
+ - gm_generators/gem/templates/gmfile.yml
94
+ - gm_generators/gem/templates/lib/module.rb
95
+ - gm_generators/mit_license/mit_license_generator.rb
96
+ - gm_generators/mit_license/templates/LICENSE.txt
97
+ - gm_generators/rails/rails_generator.rb
98
+ - gm_generators/rails/templates/rails/init.rb
99
+ - gm_generators/test/templates/test/test_case.rb
100
+ - gm_generators/test/templates/test/test_helper.rb
101
+ - gm_generators/test/test_generator.rb
100
102
  has_rdoc: true
101
103
  homepage: http://github.com/simonmenke/gm
102
104
  post_install_message: