gm 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/gm_behaviors/github_behavior.rb +4 -1
- data/gm_commands/build_command.rb +5 -5
- data/gm_commands/build_gemspec_command.rb +2 -3
- data/gm_commands/config_command.rb +1 -1
- data/gm_commands/gen_command.rb +1 -1
- data/gm_commands/help_command.rb +1 -1
- data/gm_commands/install_command.rb +1 -1
- data/gm_commands/publish_command.rb +2 -1
- data/gm_commands/spec_command.rb +3 -3
- data/gm_networks/github_network.rb +1 -1
- data/gm_networks/rubyforge_network.rb +1 -1
- data/lib/gm/app.rb +28 -25
- data/lib/gm/behavior.rb +2 -0
- data/lib/gm/command.rb +2 -6
- data/lib/gm/helpers.rb +5 -1
- data/test/command_test.rb +4 -4
- metadata +44 -10
@@ -2,7 +2,10 @@
|
|
2
2
|
class GithubBehavior < GM::Behavior
|
3
3
|
|
4
4
|
def run
|
5
|
-
|
5
|
+
emulate = !command.options.no_emulation?
|
6
|
+
emulate &= (config[:github] != nil) && (config[:github][:emulate] == true)
|
7
|
+
|
8
|
+
if emulate
|
6
9
|
name = config[:github][:project] || config[:general][:name]
|
7
10
|
spec.name = "#{config[:github][:username]}-#{name}"
|
8
11
|
end
|
@@ -7,7 +7,7 @@ class BuildCommand < GM::Command
|
|
7
7
|
build a gem and put the result in pkg/
|
8
8
|
DOC
|
9
9
|
|
10
|
-
def
|
10
|
+
def add_options(p)
|
11
11
|
p.flag 'E', 'no-emulation', :desc => 'Don\'t emulate any network'
|
12
12
|
end
|
13
13
|
|
@@ -15,11 +15,11 @@ class BuildCommand < GM::Command
|
|
15
15
|
GM::Command.run(:build_gemspec, [(options.no_emulation? ? '-E' : nil)].compact)
|
16
16
|
|
17
17
|
app.info "Building your gem..."
|
18
|
-
builder = Gem::Builder.new app.
|
19
|
-
|
20
|
-
sh("rm -f pkg/#{
|
18
|
+
builder = Gem::Builder.new app.spec
|
19
|
+
builder.build
|
20
|
+
sh("rm -f pkg/#{gem_file_name}",
|
21
21
|
"mkdir -p pkg",
|
22
|
-
"mv #{
|
22
|
+
"mv #{gem_file_name} pkg/")
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
|
2
2
|
class BuildGemspecCommand < GM::Command
|
3
3
|
|
4
|
-
def
|
4
|
+
def add_options(p)
|
5
5
|
p.flag 'E', 'no-emulation', :desc => 'Don\'t emulate any network'
|
6
6
|
end
|
7
7
|
|
8
8
|
def run
|
9
9
|
app.info "Generating your gemspec..."
|
10
|
-
app.emulate = !options.no_emulation?
|
11
|
-
app.gemspec = Gem::Specification.new
|
12
10
|
|
13
11
|
GM::Behavior.behaviors.each do |name,klass|
|
14
12
|
behavior = klass.new
|
13
|
+
behavior.command = self
|
15
14
|
behavior.run
|
16
15
|
end
|
17
16
|
|
data/gm_commands/gen_command.rb
CHANGED
data/gm_commands/help_command.rb
CHANGED
@@ -11,9 +11,10 @@ class PublishCommand < GM::Command
|
|
11
11
|
DOC
|
12
12
|
|
13
13
|
def run
|
14
|
-
GM::Command.run(:build_gemspec)
|
15
14
|
|
16
15
|
networks = argv.collect do |network|
|
16
|
+
app.reset_spec!
|
17
|
+
GM::Command.run(:build_gemspec, ['-E'])
|
17
18
|
name = network.underscore.to_sym
|
18
19
|
klass = GM::Network.networks[name]
|
19
20
|
klass.new unless klass.nil?
|
data/gm_commands/spec_command.rb
CHANGED
@@ -4,10 +4,10 @@ class SpecCommand < GM::Command
|
|
4
4
|
desc "Dump the gemspec file."
|
5
5
|
|
6
6
|
def run
|
7
|
-
GM::Command.run(:build_gemspec)
|
7
|
+
GM::Command.run(:build_gemspec, ['-E'])
|
8
8
|
app.info "Writing your gemspec..."
|
9
|
-
File.open("#{app.
|
10
|
-
f.write app.
|
9
|
+
File.open("#{app.spec.name}.gemspec", 'w+') do |f|
|
10
|
+
f.write app.spec.to_ruby
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -61,7 +61,7 @@ class GithubNetwork < GM::Network
|
|
61
61
|
def commit_gemspec
|
62
62
|
version = config[:general][:version]
|
63
63
|
GM::Command.run(:spec)
|
64
|
-
sh %{ git ci -m "Bumped to version #{version}" -o "#{app.
|
64
|
+
sh %{ git ci -m "Bumped to version #{version}" -o "#{app.spec.name}.gemspec" -o "Gmfile" }
|
65
65
|
end
|
66
66
|
|
67
67
|
def push_to_github
|
@@ -24,7 +24,7 @@ class RubyforgeNetwork < GM::Network
|
|
24
24
|
prepare
|
25
25
|
version = config[:general][:version]
|
26
26
|
GM::Command.run(:build, ['-E'])
|
27
|
-
sh "rubyforge add_release #{group_id} #{package_id} #{version} pkg/#{
|
27
|
+
sh "rubyforge add_release #{group_id} #{package_id} #{version} pkg/#{gem_file_name}"
|
28
28
|
end
|
29
29
|
|
30
30
|
def published_versions
|
data/lib/gm/app.rb
CHANGED
@@ -4,33 +4,23 @@ module GM
|
|
4
4
|
class App
|
5
5
|
include Singleton
|
6
6
|
|
7
|
-
attr_accessor :configuration_passes
|
8
|
-
attr_accessor :gemspec
|
9
|
-
attr_accessor :emulate
|
10
|
-
attr_accessor :gem_file_name
|
11
|
-
attr_accessor :log_level
|
12
|
-
|
13
7
|
def initialize # :nodoc:
|
14
|
-
@log_level = :normal
|
15
8
|
reset!
|
16
9
|
end
|
17
10
|
|
18
11
|
# reset the app
|
19
12
|
def reset!
|
20
|
-
|
13
|
+
EC.store.reset!(true)
|
14
|
+
GM::Behavior.behaviors.clear
|
21
15
|
GM::Command.commands.clear
|
22
16
|
GM::Network.networks.clear
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# extra options provided by the app.
|
31
|
-
def extra_options(options)
|
32
|
-
options.flag 'v', 'verbose', :desc => 'Print more information.'
|
33
|
-
options.flag 'd', 'debug', :desc => 'Print debugging information.'
|
17
|
+
|
18
|
+
EC.store.specify do |root|
|
19
|
+
root.conf(:log_level) do |c|
|
20
|
+
c.should_be_a String
|
21
|
+
c.should_not_be_empty
|
22
|
+
end
|
23
|
+
end
|
34
24
|
end
|
35
25
|
|
36
26
|
# run the app
|
@@ -39,6 +29,16 @@ module GM
|
|
39
29
|
load_commands
|
40
30
|
load_networks
|
41
31
|
|
32
|
+
if ARGV.include? '-v'
|
33
|
+
EC.store.config[:log_level] = 'verbose'
|
34
|
+
ARGV.delete '-v'
|
35
|
+
elsif ARGV.include? '-d'
|
36
|
+
EC.store.config[:log_level] = 'debug'
|
37
|
+
ARGV.delete '-d'
|
38
|
+
else
|
39
|
+
EC.store.config[:log_level] = 'normal'
|
40
|
+
end
|
41
|
+
|
42
42
|
load_configuration('~/.gmrc')
|
43
43
|
load_configuration('Gmfile')
|
44
44
|
EC.store.validate
|
@@ -55,21 +55,24 @@ module GM
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def reset_spec!
|
59
|
+
@spec = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def spec
|
63
|
+
@spec ||= Gem::Specification.new
|
61
64
|
end
|
62
65
|
|
63
66
|
def log(msg)
|
64
|
-
puts msg
|
67
|
+
puts msg if %w( debug verbose normal ).include? EC.store.config[:log_level]
|
65
68
|
end
|
66
69
|
|
67
70
|
def info(msg)
|
68
|
-
puts msg if
|
71
|
+
puts msg if %w( debug verbose ).include? EC.store.config[:log_level]
|
69
72
|
end
|
70
73
|
|
71
74
|
def debug(msg)
|
72
|
-
puts msg if
|
75
|
+
puts msg if %w( debug ).include? EC.store.config[:log_level]
|
73
76
|
end
|
74
77
|
|
75
78
|
private
|
data/lib/gm/behavior.rb
CHANGED
data/lib/gm/command.rb
CHANGED
@@ -19,7 +19,6 @@ module GM
|
|
19
19
|
|
20
20
|
# build a command
|
21
21
|
def self.run(cmd_name=nil, argv=ARGV)
|
22
|
-
app = GM.app
|
23
22
|
if Array === cmd_name
|
24
23
|
argv = cmd_name
|
25
24
|
cmd_name = nil
|
@@ -27,11 +26,8 @@ module GM
|
|
27
26
|
cmd = self.build(cmd_name, argv)
|
28
27
|
clip = Clip(argv) do |p|
|
29
28
|
p.banner = cmd.banner_text
|
30
|
-
|
31
|
-
cmd.extra_options(p)
|
29
|
+
cmd.add_options(p)
|
32
30
|
end
|
33
|
-
app.log_level = :verbose if clip.verbose?
|
34
|
-
app.log_level = :debug if clip.debug?
|
35
31
|
cmd.options = clip
|
36
32
|
argv.clear
|
37
33
|
argv.concat(clip.remainder)
|
@@ -58,7 +54,7 @@ module GM
|
|
58
54
|
end
|
59
55
|
|
60
56
|
# A command can overwrite this method in order to add extra command line options.
|
61
|
-
def
|
57
|
+
def add_options(options)
|
62
58
|
end
|
63
59
|
|
64
60
|
# A command must overwrite this method.
|
data/lib/gm/helpers.rb
CHANGED
data/test/command_test.rb
CHANGED
@@ -69,8 +69,8 @@ class CommandTest < Test::Unit::TestCase
|
|
69
69
|
hello_cmd = mock('hello_command') do
|
70
70
|
expects(:run)
|
71
71
|
expects(:banner_text).returns("")
|
72
|
-
expects(:
|
73
|
-
expects(:options=).with()
|
72
|
+
expects(:add_options).with() { |value| Clip::Parser === value }
|
73
|
+
expects(:options=).with() { |value| Clip::Parser === value }
|
74
74
|
expects(:argv=).with %w( p )
|
75
75
|
end
|
76
76
|
hello_cmd_class = mock('hello_command_class') do
|
@@ -85,8 +85,8 @@ class CommandTest < Test::Unit::TestCase
|
|
85
85
|
hello_cmd = mock('hello_command') do
|
86
86
|
expects(:run)
|
87
87
|
expects(:banner_text).returns("")
|
88
|
-
expects(:
|
89
|
-
expects(:options=).with()
|
88
|
+
expects(:add_options).with() { |value| Clip::Parser === value }
|
89
|
+
expects(:options=).with() { |value| Clip::Parser === value }
|
90
90
|
expects(:argv=).with %w( p )
|
91
91
|
end
|
92
92
|
hello_cmd_class = mock('hello_command_class') do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -20,7 +20,37 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.
|
23
|
+
version: 0.0.4
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: clip
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rubigen
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.5.1
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: simonmenke-ec
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.0.4
|
24
54
|
version:
|
25
55
|
- !ruby/object:Gem::Dependency
|
26
56
|
name: clip
|
@@ -52,6 +82,14 @@ extensions: []
|
|
52
82
|
extra_rdoc_files: []
|
53
83
|
|
54
84
|
files:
|
85
|
+
- test/command_test.rb
|
86
|
+
- test/gem_extentions_test.rb
|
87
|
+
- test/system_test.rb
|
88
|
+
- test/test_helper.rb
|
89
|
+
- bin/gem-make
|
90
|
+
- bin/gm
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.textile
|
55
93
|
- gm_generators/bin/bin_generator.rb
|
56
94
|
- gm_generators/bin/templates/bin/bin.rb
|
57
95
|
- gm_generators/gem/gem_generator.rb
|
@@ -105,14 +143,6 @@ files:
|
|
105
143
|
- gm_generators/rails/templates/rails
|
106
144
|
- gm_generators/test
|
107
145
|
- gm_generators/test/templates
|
108
|
-
- test/command_test.rb
|
109
|
-
- test/gem_extentions_test.rb
|
110
|
-
- test/system_test.rb
|
111
|
-
- test/test_helper.rb
|
112
|
-
- bin/gem-make
|
113
|
-
- bin/gm
|
114
|
-
- LICENSE.txt
|
115
|
-
- README.textile
|
116
146
|
- lib/autotest/discover.rb
|
117
147
|
- lib/autotest/gm.rb
|
118
148
|
- lib/extentions/gem.rb
|
@@ -157,3 +187,7 @@ test_files:
|
|
157
187
|
- test/gem_extentions_test.rb
|
158
188
|
- test/system_test.rb
|
159
189
|
- test/test_helper.rb
|
190
|
+
- test/command_test.rb
|
191
|
+
- test/gem_extentions_test.rb
|
192
|
+
- test/system_test.rb
|
193
|
+
- test/test_helper.rb
|