simonmenke-gm 0.1.4 → 0.1.6
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 +9 -6
- data/gm_commands/build_gemspec_command.rb +5 -1
- 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 +72 -0
- 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 +42 -11
@@ -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,16 +7,19 @@ class BuildCommand < GM::Command
|
|
7
7
|
build a gem and put the result in pkg/
|
8
8
|
DOC
|
9
9
|
|
10
|
+
def add_options(p)
|
11
|
+
p.flag 'E', 'no-emulation', :desc => 'Don\'t emulate any network'
|
12
|
+
end
|
13
|
+
|
10
14
|
def run
|
11
|
-
|
12
|
-
GM::Command.run(:build_gemspec)
|
15
|
+
GM::Command.run(:build_gemspec, [(options.no_emulation? ? '-E' : nil)].compact)
|
13
16
|
|
14
17
|
app.info "Building your gem..."
|
15
|
-
builder = Gem::Builder.new app.
|
16
|
-
|
17
|
-
sh("rm -f pkg/#{
|
18
|
+
builder = Gem::Builder.new app.spec
|
19
|
+
builder.build
|
20
|
+
sh("rm -f pkg/#{gem_file_name}",
|
18
21
|
"mkdir -p pkg",
|
19
|
-
"mv #{
|
22
|
+
"mv #{gem_file_name} pkg/")
|
20
23
|
end
|
21
24
|
|
22
25
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
|
2
2
|
class BuildGemspecCommand < GM::Command
|
3
3
|
|
4
|
+
def add_options(p)
|
5
|
+
p.flag 'E', 'no-emulation', :desc => 'Don\'t emulate any network'
|
6
|
+
end
|
7
|
+
|
4
8
|
def run
|
5
9
|
app.info "Generating your gemspec..."
|
6
|
-
app.gemspec = Gem::Specification.new
|
7
10
|
|
8
11
|
GM::Behavior.behaviors.each do |name,klass|
|
9
12
|
behavior = klass.new
|
13
|
+
behavior.command = self
|
10
14
|
behavior.run
|
11
15
|
end
|
12
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
|
@@ -11,8 +11,80 @@ class RubyforgeNetwork < GM::Network
|
|
11
11
|
s.should_not_be_empty
|
12
12
|
end
|
13
13
|
|
14
|
+
rubyforge.conf(:package) do |s|
|
15
|
+
s.should_be_a String
|
16
|
+
s.should_not_be_empty
|
17
|
+
end
|
18
|
+
|
14
19
|
end
|
15
20
|
|
16
21
|
end
|
17
22
|
|
23
|
+
def publish
|
24
|
+
prepare
|
25
|
+
version = config[:general][:version]
|
26
|
+
GM::Command.run(:build, ['-E'])
|
27
|
+
sh "rubyforge add_release #{group_id} #{package_id} #{version} pkg/#{gem_file_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def published_versions
|
31
|
+
prepare
|
32
|
+
if rubyforge_info['release_ids'][package_name]
|
33
|
+
rubyforge_info['release_ids'][package_name].keys
|
34
|
+
else
|
35
|
+
[]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def rubyforge_info(reset=false)
|
42
|
+
@rubyforge_info = nil if reset
|
43
|
+
@rubyforge_info ||= YAML.load_file(File.expand_path('~/.rubyforge/auto-config.yml'))
|
44
|
+
end
|
45
|
+
|
46
|
+
def project_name
|
47
|
+
if config[:rubyforge]
|
48
|
+
config[:rubyforge][:project]
|
49
|
+
else
|
50
|
+
config[:general][:name]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def package_name
|
55
|
+
if config[:rubyforge] and config[:rubyforge][:package]
|
56
|
+
config[:rubyforge][:package]
|
57
|
+
else
|
58
|
+
config[:general][:name]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def group_id
|
63
|
+
@group_id ||= rubyforge_info['group_ids'][project_name]
|
64
|
+
end
|
65
|
+
|
66
|
+
def package_id
|
67
|
+
@package_id ||= rubyforge_info['package_ids'][package_name]
|
68
|
+
end
|
69
|
+
|
70
|
+
def prepare
|
71
|
+
unless @prepared
|
72
|
+
login
|
73
|
+
create_package
|
74
|
+
@prepared = true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def login
|
79
|
+
sh "rubyforge login",
|
80
|
+
"rubyforge config"
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_package
|
84
|
+
unless rubyforge_info['package_ids'].include? package_name
|
85
|
+
sh "rubyforge create_package #{group_id} #{package_name}"
|
86
|
+
rubyforge_info(true)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
18
90
|
end
|
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: simonmenke-gm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -19,7 +19,34 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.0.
|
22
|
+
version: 0.0.4
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: clip
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.0.0
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rubigen
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.1
|
41
|
+
version:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: simonmenke-ec
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.0.4
|
23
50
|
version:
|
24
51
|
- !ruby/object:Gem::Dependency
|
25
52
|
name: clip
|
@@ -49,6 +76,14 @@ extensions: []
|
|
49
76
|
extra_rdoc_files: []
|
50
77
|
|
51
78
|
files:
|
79
|
+
- test/command_test.rb
|
80
|
+
- test/gem_extentions_test.rb
|
81
|
+
- test/system_test.rb
|
82
|
+
- test/test_helper.rb
|
83
|
+
- bin/gem-make
|
84
|
+
- bin/gm
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.textile
|
52
87
|
- gm_generators/bin/bin_generator.rb
|
53
88
|
- gm_generators/bin/templates/bin/bin.rb
|
54
89
|
- gm_generators/gem/gem_generator.rb
|
@@ -102,14 +137,6 @@ files:
|
|
102
137
|
- gm_generators/rails/templates/rails
|
103
138
|
- gm_generators/test
|
104
139
|
- gm_generators/test/templates
|
105
|
-
- test/command_test.rb
|
106
|
-
- test/gem_extentions_test.rb
|
107
|
-
- test/system_test.rb
|
108
|
-
- test/test_helper.rb
|
109
|
-
- bin/gem-make
|
110
|
-
- bin/gm
|
111
|
-
- LICENSE.txt
|
112
|
-
- README.textile
|
113
140
|
- lib/autotest/discover.rb
|
114
141
|
- lib/autotest/gm.rb
|
115
142
|
- lib/extentions/gem.rb
|
@@ -144,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
171
|
version:
|
145
172
|
requirements: []
|
146
173
|
|
147
|
-
rubyforge_project:
|
174
|
+
rubyforge_project: gem-make
|
148
175
|
rubygems_version: 1.2.0
|
149
176
|
signing_key:
|
150
177
|
specification_version: 2
|
@@ -154,3 +181,7 @@ test_files:
|
|
154
181
|
- test/gem_extentions_test.rb
|
155
182
|
- test/system_test.rb
|
156
183
|
- test/test_helper.rb
|
184
|
+
- test/command_test.rb
|
185
|
+
- test/gem_extentions_test.rb
|
186
|
+
- test/system_test.rb
|
187
|
+
- test/test_helper.rb
|