simonmenke-gm 0.1.1 → 0.1.2
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.
- data/bin/{gmm → gem-make} +1 -0
- data/bin/gm +1 -0
- data/gm_commands/build_command.rb +6 -2
- data/gm_commands/clean_command.rb +5 -1
- data/gm_commands/config_command.rb +22 -2
- data/gm_commands/create_command.rb +2 -2
- data/gm_commands/gen_command.rb +17 -1
- data/gm_commands/help_command.rb +203 -8
- data/gm_commands/install_command.rb +6 -2
- data/gm_commands/publish_command.rb +12 -8
- data/gm_commands/spec_command.rb +1 -1
- data/gm_networks/github_network.rb +11 -3
- data/gm_passes/clean_file_list.rb +4 -0
- data/lib/autotest/gm.rb +30 -27
- data/lib/extentions/configatron.rb +17 -0
- data/lib/gm/app.rb +4 -3
- data/lib/gm/command.rb +13 -6
- data/lib/gm/documentation.rb +16 -0
- data/lib/gm/loader.rb +6 -2
- data/lib/gm/network.rb +9 -1
- data/lib/gm.rb +2 -0
- data/test/command_test.rb +11 -7
- data/test/configatron_test.rb +15 -0
- data/test/gem_extentions_test.rb +15 -0
- data/test/system_test.rb +17 -0
- metadata +41 -36
data/bin/{gmm → gem-make}
RENAMED
data/bin/gm
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
|
2
|
-
class ConfigCommand < Command
|
2
|
+
class ConfigCommand < GM::Command
|
3
3
|
|
4
|
-
desc "
|
4
|
+
desc "Manage your GM configurations."
|
5
|
+
banner "config [show edit]"
|
6
|
+
doc <<-DOC
|
7
|
+
With the edit argument the config command allows you to edit your glabal GM configurations.
|
8
|
+
With the show argument the config command will display all the configurations made in your environment.
|
9
|
+
|
10
|
+
The edit option is the default.
|
11
|
+
DOC
|
5
12
|
|
6
13
|
EMPTY_CONFIG = <<-EOC
|
7
14
|
author:
|
@@ -12,6 +19,14 @@ github:
|
|
12
19
|
EOC
|
13
20
|
|
14
21
|
def run
|
22
|
+
case argv.first
|
23
|
+
when 'edit' then run_edit
|
24
|
+
when 'show' then run_show
|
25
|
+
else run_edit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def run_edit
|
15
30
|
path = File.expand_path('~/.gmrc')
|
16
31
|
unless File.exist? path
|
17
32
|
File.open(path, 'w+') { |f| f.write EMPTY_CONFIG }
|
@@ -19,4 +34,9 @@ EOC
|
|
19
34
|
sh("$EDITOR '#{path}'")
|
20
35
|
end
|
21
36
|
|
37
|
+
def run_show
|
38
|
+
app.build_gemspec
|
39
|
+
puts configatron.to_hash2.to_yaml
|
40
|
+
end
|
41
|
+
|
22
42
|
end
|
data/gm_commands/gen_command.rb
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
|
2
|
-
class GenCommand < Command
|
2
|
+
class GenCommand < GM::Command
|
3
|
+
|
4
|
+
def self.generator_names
|
5
|
+
RubiGen::Base.use_component_sources!(:gm)
|
6
|
+
RubiGen::Base.sources.collect do |s|
|
7
|
+
s.collect do |g|
|
8
|
+
g.name if g.path.include?('gm_generators') and g.name != 'gem'
|
9
|
+
end
|
10
|
+
end.flatten.compact.sort
|
11
|
+
end
|
3
12
|
|
4
13
|
desc "Use a generator"
|
14
|
+
banner "gen generator options..."
|
15
|
+
doc <<-DOC
|
16
|
+
The gen command allows you to generate code using rubigen compatible generators.
|
17
|
+
The generators must be on the search path (any gem with a gm_generator directory).
|
18
|
+
</p><p>
|
19
|
+
#{generator_names.join(', ')}
|
20
|
+
DOC
|
5
21
|
|
6
22
|
def run
|
7
23
|
app.build_gemspec if File.exist?('./gmfile.yml')
|
data/gm_commands/help_command.rb
CHANGED
@@ -1,9 +1,206 @@
|
|
1
1
|
|
2
|
-
class HelpCommand < Command
|
2
|
+
class HelpCommand < GM::Command
|
3
3
|
|
4
|
-
desc "
|
4
|
+
desc "Get help with GM"
|
5
|
+
banner "help [doc]"
|
6
|
+
doc <<-DOC
|
7
|
+
The help command will display a help message by default but when the doc argument is provided it will open and HTML version of the documentation.
|
8
|
+
DOC
|
5
9
|
|
6
10
|
def run
|
11
|
+
case argv.first
|
12
|
+
when 'doc' then run_doc
|
13
|
+
else run_help
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def run_doc
|
20
|
+
path = File.expand_path("~/.gmdoc.html")
|
21
|
+
File.open(path, 'w+') { |f| f.write doc }
|
22
|
+
sh %{ open "#{path}" }
|
23
|
+
end
|
24
|
+
|
25
|
+
def doc
|
26
|
+
%{
|
27
|
+
<html>
|
28
|
+
<head>
|
29
|
+
<title>GM documentation</title>
|
30
|
+
<style>
|
31
|
+
body {
|
32
|
+
font-family: Arial;
|
33
|
+
font-size: 12px;
|
34
|
+
text-align:center;
|
35
|
+
background-color:#e0e0e0;
|
36
|
+
margin:25px
|
37
|
+
}
|
38
|
+
#wrapper {
|
39
|
+
width:800px;
|
40
|
+
text-align:left;
|
41
|
+
margin:0px auto;
|
42
|
+
}
|
43
|
+
#content {
|
44
|
+
padding:50px 50px 1px;
|
45
|
+
width:500px;
|
46
|
+
margin: 0 100px;
|
47
|
+
background-color:#fff;
|
48
|
+
}
|
49
|
+
#menu {
|
50
|
+
position:fixed;
|
51
|
+
top:25px;
|
52
|
+
width:100px;
|
53
|
+
}
|
54
|
+
#menu a {
|
55
|
+
padding:10px;
|
56
|
+
display:block;
|
57
|
+
color:#000;
|
58
|
+
text-decoration:none;
|
59
|
+
font-weight:bold;
|
60
|
+
background-color:#fff;
|
61
|
+
margin-bottom:2px;
|
62
|
+
}
|
63
|
+
#menu a:hover {
|
64
|
+
background-color:#000;
|
65
|
+
color:#fff;
|
66
|
+
}
|
67
|
+
h1 {
|
68
|
+
margin-top:0;
|
69
|
+
}
|
70
|
+
h2 {
|
71
|
+
margin:0;
|
72
|
+
}
|
73
|
+
h3 {
|
74
|
+
float:left;
|
75
|
+
margin: 0;
|
76
|
+
width:75px;
|
77
|
+
font-size:12px;
|
78
|
+
}
|
79
|
+
.description {
|
80
|
+
color:#999
|
81
|
+
}
|
82
|
+
#commands, #networks, #passes {
|
83
|
+
margin:50px 0;
|
84
|
+
padding-top:50px;
|
85
|
+
border-top:2px solid #e0e0e0;
|
86
|
+
}
|
87
|
+
.command, .network, .pass {
|
88
|
+
margin: 30px 0;
|
89
|
+
border-left:10px solid #e0e0e0;
|
90
|
+
padding-left:10px;
|
91
|
+
margin-left:-20px;
|
92
|
+
}
|
93
|
+
.options {
|
94
|
+
font-family: monospace;
|
95
|
+
}
|
96
|
+
|
97
|
+
.pass h3 {
|
98
|
+
float:none;
|
99
|
+
width:auto;
|
100
|
+
}
|
101
|
+
</style>
|
102
|
+
</head>
|
103
|
+
<body>
|
104
|
+
<div id="wrapper">
|
105
|
+
<div id="menu">
|
106
|
+
<a href="#commands">Commands</a>
|
107
|
+
<a href="#networks">Network</a>
|
108
|
+
<a href="#passes">Passes</a>
|
109
|
+
</div>
|
110
|
+
<div id="content">
|
111
|
+
<h1>GM documentation</h1>
|
112
|
+
#{doc_commands}
|
113
|
+
#{doc_networks}
|
114
|
+
#{doc_passes}
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
</body>
|
118
|
+
</html>
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
def doc_commands
|
123
|
+
commands = GM::Command.commands.values
|
124
|
+
commands.sort! { |a,b| a.name.to_s <=> b.name.to_s }
|
125
|
+
commands.collect! { |command| doc_command(command) }
|
126
|
+
commands = commands.join
|
127
|
+
%{
|
128
|
+
<div id="commands">
|
129
|
+
<h2>Commands</h2>
|
130
|
+
#{commands}
|
131
|
+
</div>
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
def doc_command(command)
|
136
|
+
options = Clip { |p|
|
137
|
+
p.banner = command.banner_text
|
138
|
+
command.new.extra_options(p)
|
139
|
+
}.to_s
|
140
|
+
options.gsub!(/Usage:\n/, '')
|
141
|
+
%{
|
142
|
+
<div class="command">
|
143
|
+
<h3>#{command.name}</h3>
|
144
|
+
<p class="description">#{command.description}</p>
|
145
|
+
<p class="options">#{options}</p>
|
146
|
+
<p class="documentation">#{command.documentation}</p>
|
147
|
+
</div>
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def doc_networks
|
152
|
+
networks = GM::Network.networks.values
|
153
|
+
networks.sort! { |a,b| a.name.to_s <=> b.name.to_s }
|
154
|
+
networks.collect! { |network| doc_network(network) }
|
155
|
+
networks = networks.join
|
156
|
+
%{
|
157
|
+
<div id="networks">
|
158
|
+
<h2>Networks</h2>
|
159
|
+
#{networks}
|
160
|
+
</div>
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
def doc_network(network)
|
165
|
+
%{
|
166
|
+
<div class="network" id="network_#{network.name}">
|
167
|
+
<h3>#{network.name}</h3>
|
168
|
+
<p class="description">#{network.description}</p>
|
169
|
+
<p class="documentation">#{network.documentation}</p>
|
170
|
+
</div>
|
171
|
+
}
|
172
|
+
end
|
173
|
+
|
174
|
+
def doc_passes
|
175
|
+
%{
|
176
|
+
<div id="passes">
|
177
|
+
<h2>Passes</h2>
|
178
|
+
#{doc_passes_in_fase(:initialization)}
|
179
|
+
#{doc_passes_in_fase(:configuration)}
|
180
|
+
#{doc_passes_in_fase(:normal)}
|
181
|
+
#{doc_passes_in_fase(:finalization)}
|
182
|
+
</div>
|
183
|
+
}
|
184
|
+
end
|
185
|
+
|
186
|
+
def doc_passes_in_fase(fase)
|
187
|
+
passes = []
|
188
|
+
GM::ConfigurationPassQueue.new(fase).each_with_index do |pass, idx|
|
189
|
+
passes << doc_pass(fase, pass, idx)
|
190
|
+
end
|
191
|
+
passes = passes.join
|
192
|
+
end
|
193
|
+
|
194
|
+
def doc_pass(fase, pass, idx)
|
195
|
+
%{
|
196
|
+
<div class="pass">
|
197
|
+
<h3>##{idx + 1} - #{fase}:#{pass.name}</h3>
|
198
|
+
<p class="documentation">#{pass.description}</p>
|
199
|
+
</div>
|
200
|
+
}
|
201
|
+
end
|
202
|
+
|
203
|
+
def run_help
|
7
204
|
puts "#{File.basename($0)} <command> <options>"
|
8
205
|
puts options.to_s
|
9
206
|
puts ""
|
@@ -14,25 +211,23 @@ class HelpCommand < Command
|
|
14
211
|
passes_in_running_order
|
15
212
|
end
|
16
213
|
|
17
|
-
private
|
18
|
-
|
19
214
|
def passes_in_running_order
|
20
215
|
format = "% 3d %- 20s %s"
|
21
216
|
|
22
217
|
puts "- initialization"
|
23
|
-
ConfigurationPassQueue.new(:initialization).each_with_index do |pass, idx|
|
218
|
+
GM::ConfigurationPassQueue.new(:initialization).each_with_index do |pass, idx|
|
24
219
|
puts format % [idx+1, pass.name, pass.description]
|
25
220
|
end
|
26
221
|
puts "- configuration"
|
27
|
-
ConfigurationPassQueue.new(:configuration).each_with_index do |pass, idx|
|
222
|
+
GM::ConfigurationPassQueue.new(:configuration).each_with_index do |pass, idx|
|
28
223
|
puts format % [idx+1, pass.name, pass.description]
|
29
224
|
end
|
30
225
|
puts "- normal"
|
31
|
-
ConfigurationPassQueue.new(:normal).each_with_index do |pass, idx|
|
226
|
+
GM::ConfigurationPassQueue.new(:normal).each_with_index do |pass, idx|
|
32
227
|
puts format % [idx+1, pass.name, pass.description]
|
33
228
|
end
|
34
229
|
puts "- finalization"
|
35
|
-
ConfigurationPassQueue.new(:finalization).each_with_index do |pass, idx|
|
230
|
+
GM::ConfigurationPassQueue.new(:finalization).each_with_index do |pass, idx|
|
36
231
|
puts format % [idx+1, pass.name, pass.description]
|
37
232
|
end
|
38
233
|
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
|
2
|
-
class InstallCommand < Command
|
2
|
+
class InstallCommand < GM::Command
|
3
3
|
|
4
4
|
desc "Install the gem localy"
|
5
|
+
banner "install"
|
6
|
+
doc <<-DOC
|
7
|
+
Build and install the gem localy.
|
8
|
+
DOC
|
5
9
|
|
6
10
|
def run
|
7
|
-
Command.run(:build)
|
11
|
+
GM::Command.run(:build)
|
8
12
|
|
9
13
|
app.info "Installing your gem..."
|
10
14
|
sh("sudo gem install pkg/#{app.gem_file_name}")
|
@@ -1,24 +1,28 @@
|
|
1
1
|
|
2
|
-
class PublishCommand < Command
|
2
|
+
class PublishCommand < GM::Command
|
3
3
|
|
4
4
|
desc "Publish your gems to a network"
|
5
|
+
banner "publish network..."
|
6
|
+
doc <<-DOC
|
7
|
+
This command will publish your gem through the provided networks.
|
8
|
+
</p><p>
|
9
|
+
<%= GM::Network.networks.keys.collect{|n|
|
10
|
+
%{<a href="#network_\#{n}">\#{n}</a>} }.join(', ') %>
|
11
|
+
DOC
|
5
12
|
|
6
13
|
def run
|
7
14
|
app.build_gemspec
|
8
15
|
|
9
16
|
networks = argv.collect do |network|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
rescue
|
14
|
-
nil
|
15
|
-
end
|
17
|
+
name = network.underscore.to_sym
|
18
|
+
klass = GM::Network.networks[name]
|
19
|
+
klass.new unless klass.nil?
|
16
20
|
end.compact
|
17
21
|
|
18
22
|
version = configatron.general.version
|
19
23
|
networks.each do |network|
|
20
24
|
if network.has_version? version
|
21
|
-
GM.app.log "Skipping #{network.class.name} (version already present)"
|
25
|
+
GM.app.log "Skipping #{network.class.name} (version #{version} already present)"
|
22
26
|
else
|
23
27
|
network.publish
|
24
28
|
end
|
data/gm_commands/spec_command.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
|
2
|
-
class GithubNetwork < Network
|
2
|
+
class GithubNetwork < GM::Network
|
3
3
|
|
4
4
|
desc "push new releases to GitHub"
|
5
|
+
doc <<-DOC
|
6
|
+
This will dump the .gemspec file, create a new (optonaly signed) tag and push the master branch to github.
|
7
|
+
DOC
|
5
8
|
|
6
9
|
def publish
|
7
10
|
commit_gemspec
|
@@ -25,13 +28,18 @@ class GithubNetwork < Network
|
|
25
28
|
def make_tag
|
26
29
|
version = configatron.general.version
|
27
30
|
key = configatron.gpg.key
|
28
|
-
|
31
|
+
signing_options = if key.nil?
|
32
|
+
"-a"
|
33
|
+
else
|
34
|
+
"-u '#{key}'"
|
35
|
+
end
|
36
|
+
sh %{ git tag -m "Version #{version}" #{signing_options} 'v#{version}' HEAD }
|
29
37
|
end
|
30
38
|
|
31
39
|
def commit_gemspec
|
32
40
|
version = configatron.general.version
|
33
41
|
GM::Command.run(:spec)
|
34
|
-
sh %{ git ci -m "Bumped to version #{version}" -o "#{
|
42
|
+
sh %{ git ci -m "Bumped to version #{version}" -o "#{app.gemspec.name}.gemspec" -o "Gmfile" }
|
35
43
|
end
|
36
44
|
|
37
45
|
def push_to_github
|
@@ -4,6 +4,10 @@ desc "Remove dir and duplicate paths"
|
|
4
4
|
finalization_pass :clean_file_list do |spec|
|
5
5
|
|
6
6
|
spec.files.reject! { |path| File.directory? path }
|
7
|
+
spec.files.reject! { |path| File.basename(path) == '.DS_Store' }
|
8
|
+
spec.files.reject! { |path| File.basename(path) == '.gitignore' }
|
9
|
+
spec.files.reject! { |path| path.include? '/.svn' }
|
10
|
+
spec.files.reject! { |path| path.include? '/.git' }
|
7
11
|
spec.files.uniq!
|
8
12
|
spec.files.compact!
|
9
13
|
spec.files.sort!
|
data/lib/autotest/gm.rb
CHANGED
@@ -1,34 +1,37 @@
|
|
1
1
|
require 'autotest'
|
2
2
|
|
3
|
-
class Autotest
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
class Autotest # :nodoc:
|
4
|
+
|
5
|
+
class Gm < Autotest # :nodoc:
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
|
10
|
+
add_exception %r%^\./(?:doc|pkg)%
|
11
|
+
|
12
|
+
clear_mappings
|
13
|
+
|
14
|
+
self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
|
15
|
+
impl = File.basename(filename, '.rb')
|
16
|
+
files_matching %r%^test/#{impl}_test.rb$%
|
17
|
+
end
|
18
|
+
|
19
|
+
add_mapping %r%^test/.*rb$% do |filename, _|
|
20
|
+
filename
|
21
|
+
end
|
22
|
+
|
23
|
+
add_mapping %r%^test/test_helper.rb% do
|
24
|
+
files_matching %r%^test/.*_test\.rb$%
|
25
|
+
end
|
19
26
|
end
|
20
27
|
|
21
|
-
|
22
|
-
|
28
|
+
def path_to_classname(s)
|
29
|
+
sep = File::SEPARATOR
|
30
|
+
f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
|
31
|
+
f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
|
32
|
+
f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
|
33
|
+
f.join('::')
|
23
34
|
end
|
24
35
|
end
|
25
|
-
|
26
|
-
# Convert the pathname s to the name of class.
|
27
|
-
def path_to_classname(s)
|
28
|
-
sep = File::SEPARATOR
|
29
|
-
f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
|
30
|
-
f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
|
31
|
-
f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
|
32
|
-
f.join('::')
|
33
|
-
end
|
36
|
+
|
34
37
|
end
|
data/lib/gm/app.rb
CHANGED
@@ -5,12 +5,13 @@ module GM
|
|
5
5
|
include Singleton
|
6
6
|
|
7
7
|
attr_accessor :configuration_passes
|
8
|
-
attr_accessor :options
|
9
8
|
attr_accessor :gemspec
|
10
9
|
attr_accessor :emulate
|
11
10
|
attr_accessor :gem_file_name
|
11
|
+
attr_accessor :log_level
|
12
12
|
|
13
13
|
def initialize # :nodoc:
|
14
|
+
@log_level = :normal
|
14
15
|
reset!
|
15
16
|
end
|
16
17
|
|
@@ -61,11 +62,11 @@ module GM
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def info(msg)
|
64
|
-
puts msg if
|
65
|
+
puts msg if log_level == :verbose
|
65
66
|
end
|
66
67
|
|
67
68
|
def debug(msg)
|
68
|
-
puts msg if
|
69
|
+
puts msg if log_level == :verbose or log_level == :debug
|
69
70
|
end
|
70
71
|
|
71
72
|
private
|
data/lib/gm/command.rb
CHANGED
@@ -3,7 +3,6 @@ module GM
|
|
3
3
|
|
4
4
|
class Command
|
5
5
|
|
6
|
-
attr_accessor :app
|
7
6
|
attr_accessor :argv
|
8
7
|
attr_accessor :options
|
9
8
|
|
@@ -12,7 +11,9 @@ module GM
|
|
12
11
|
include GM::Loader
|
13
12
|
|
14
13
|
desc ""
|
15
|
-
|
14
|
+
doc ""
|
15
|
+
banner ""
|
16
|
+
loads :commands#, :extends => GM
|
16
17
|
|
17
18
|
# build a command
|
18
19
|
def self.run(cmd_name=nil, argv=ARGV)
|
@@ -22,12 +23,14 @@ module GM
|
|
22
23
|
cmd_name = nil
|
23
24
|
end
|
24
25
|
cmd = self.build(cmd_name, argv)
|
25
|
-
cmd.app = app
|
26
26
|
clip = Clip(argv) do |p|
|
27
|
+
p.banner = cmd.banner_text
|
27
28
|
app.extra_options(p)
|
28
29
|
cmd.extra_options(p)
|
29
30
|
end
|
30
|
-
|
31
|
+
app.log_level = :verbose if clip.verbose?
|
32
|
+
app.log_level = :debug if clip.debug?
|
33
|
+
cmd.options = clip
|
31
34
|
argv.clear
|
32
35
|
argv.concat(clip.remainder)
|
33
36
|
cmd.argv = argv
|
@@ -54,12 +57,16 @@ module GM
|
|
54
57
|
|
55
58
|
# A command can overwrite this method in order to add extra command line options.
|
56
59
|
def extra_options(options)
|
57
|
-
|
58
60
|
end
|
59
61
|
|
60
62
|
# A command must overwrite this method.
|
61
63
|
def run
|
62
|
-
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
def app
|
69
|
+
GM.app
|
63
70
|
end
|
64
71
|
|
65
72
|
end
|
data/lib/gm/documentation.rb
CHANGED
@@ -11,8 +11,24 @@ module GM
|
|
11
11
|
def desc(text)
|
12
12
|
module_eval %{
|
13
13
|
def self.description
|
14
|
+
ERB.new(#{text.inspect}).result(binding)
|
15
|
+
end
|
16
|
+
}
|
17
|
+
end
|
18
|
+
def doc(text)
|
19
|
+
module_eval %{
|
20
|
+
def self.documentation
|
21
|
+
ERB.new(#{text.inspect}).result(binding)
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
def banner(text)
|
26
|
+
text = "#{File.basename($0)} #{text}" unless text.blank?
|
27
|
+
module_eval %{
|
28
|
+
def self.banner_text
|
14
29
|
#{text.inspect}
|
15
30
|
end
|
31
|
+
def banner_text; self.class.banner_text ; end
|
16
32
|
}
|
17
33
|
end
|
18
34
|
end
|
data/lib/gm/loader.rb
CHANGED
@@ -9,7 +9,7 @@ module GM
|
|
9
9
|
|
10
10
|
module Macros
|
11
11
|
|
12
|
-
def loads(name, options)
|
12
|
+
def loads(name, options={})
|
13
13
|
options.reverse_merge!(
|
14
14
|
:name => name.to_s.singularize.underscore,
|
15
15
|
:includes => [],
|
@@ -29,7 +29,11 @@ module GM
|
|
29
29
|
klass
|
30
30
|
end
|
31
31
|
def self.name
|
32
|
-
@name
|
32
|
+
return @name unless @name.nil?
|
33
|
+
regexp = /^(?:[#][<]Module[:]0x[0-9a-f]+[>][:]{2})?(.+)#{options[:name].camelize}$/
|
34
|
+
@name = self.to_s
|
35
|
+
@name.gsub!(regexp, '\\1')
|
36
|
+
@name = @name.underscore.to_sym
|
33
37
|
end
|
34
38
|
def self.#{options[:collection]}
|
35
39
|
@#{options[:collection]} ||= {}
|
data/lib/gm/network.rb
CHANGED
@@ -8,7 +8,9 @@ module GM
|
|
8
8
|
include GM::Loader
|
9
9
|
|
10
10
|
desc ""
|
11
|
-
|
11
|
+
doc ""
|
12
|
+
|
13
|
+
loads :networks
|
12
14
|
|
13
15
|
def publish
|
14
16
|
end
|
@@ -20,6 +22,12 @@ module GM
|
|
20
22
|
published_versions.include? version
|
21
23
|
end
|
22
24
|
|
25
|
+
protected
|
26
|
+
|
27
|
+
def app
|
28
|
+
GM.app
|
29
|
+
end
|
30
|
+
|
23
31
|
end
|
24
32
|
|
25
33
|
end
|
data/lib/gm.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
begin
|
3
|
+
require 'erb'
|
3
4
|
require 'clip'
|
4
5
|
require 'singleton'
|
5
6
|
require 'configatron'
|
@@ -18,6 +19,7 @@ module GM
|
|
18
19
|
end
|
19
20
|
|
20
21
|
require File.dirname(__FILE__)+'/extentions/gem'
|
22
|
+
require File.dirname(__FILE__)+'/extentions/configatron'
|
21
23
|
require File.dirname(__FILE__)+'/gm/loader'
|
22
24
|
require File.dirname(__FILE__)+'/gm/system'
|
23
25
|
require File.dirname(__FILE__)+'/gm/documentation'
|
data/test/command_test.rb
CHANGED
@@ -36,7 +36,7 @@ class CommandTest < Test::Unit::TestCase
|
|
36
36
|
help_cmd = mock
|
37
37
|
help_cmd_class = mock
|
38
38
|
help_cmd_class.expects(:new).returns(help_cmd)
|
39
|
-
GM::Command.commands[:
|
39
|
+
GM::Command.commands[:hello] = help_cmd_class
|
40
40
|
cmd = GM::Command.build(:hello)
|
41
41
|
assert_equal help_cmd, cmd
|
42
42
|
end
|
@@ -45,7 +45,7 @@ class CommandTest < Test::Unit::TestCase
|
|
45
45
|
hello_cmd = mock
|
46
46
|
hello_cmd_class = mock
|
47
47
|
hello_cmd_class.expects(:new).returns(hello_cmd)
|
48
|
-
GM::Command.commands[:
|
48
|
+
GM::Command.commands[:hello] = hello_cmd_class
|
49
49
|
cmd = GM::Command.build(:hello)
|
50
50
|
assert_equal hello_cmd, cmd
|
51
51
|
end
|
@@ -55,7 +55,7 @@ class CommandTest < Test::Unit::TestCase
|
|
55
55
|
hello_cmd = mock
|
56
56
|
hello_cmd_class = mock
|
57
57
|
hello_cmd_class.expects(:new).returns(hello_cmd)
|
58
|
-
GM::Command.commands[:
|
58
|
+
GM::Command.commands[:hello] = hello_cmd_class
|
59
59
|
cmd = GM::Command.build(argv)
|
60
60
|
assert_equal hello_cmd, cmd
|
61
61
|
end
|
@@ -68,7 +68,7 @@ class CommandTest < Test::Unit::TestCase
|
|
68
68
|
argv = %w( -v p )
|
69
69
|
hello_cmd = mock('hello_command') do
|
70
70
|
expects(:run)
|
71
|
-
expects(:
|
71
|
+
expects(:banner_text).returns("")
|
72
72
|
expects(:extra_options).with() { |value| Clip::Parser === value }
|
73
73
|
expects(:options=).with() { |value| Clip::Parser === value }
|
74
74
|
expects(:argv=).with %w( p )
|
@@ -76,7 +76,7 @@ class CommandTest < Test::Unit::TestCase
|
|
76
76
|
hello_cmd_class = mock('hello_command_class') do
|
77
77
|
expects(:new).returns(hello_cmd)
|
78
78
|
end
|
79
|
-
GM::Command.commands[:
|
79
|
+
GM::Command.commands[:hello] = hello_cmd_class
|
80
80
|
assert_equal %w( p ), GM::Command.run(:hello, argv)
|
81
81
|
end
|
82
82
|
|
@@ -84,7 +84,7 @@ class CommandTest < Test::Unit::TestCase
|
|
84
84
|
argv = %w( -v hello p )
|
85
85
|
hello_cmd = mock('hello_command') do
|
86
86
|
expects(:run)
|
87
|
-
expects(:
|
87
|
+
expects(:banner_text).returns("")
|
88
88
|
expects(:extra_options).with() { |value| Clip::Parser === value }
|
89
89
|
expects(:options=).with() { |value| Clip::Parser === value }
|
90
90
|
expects(:argv=).with %w( p )
|
@@ -92,11 +92,15 @@ class CommandTest < Test::Unit::TestCase
|
|
92
92
|
hello_cmd_class = mock('hello_command_class') do
|
93
93
|
expects(:new).returns(hello_cmd)
|
94
94
|
end
|
95
|
-
GM::Command.commands[:
|
95
|
+
GM::Command.commands[:hello] = hello_cmd_class
|
96
96
|
assert_equal %w( p ), GM::Command.run(argv)
|
97
97
|
end
|
98
98
|
|
99
99
|
end
|
100
100
|
|
101
101
|
|
102
|
+
should "retrun GM.app for #app" do
|
103
|
+
assert_equal GM.app, GM::Command.new.send(:app)
|
104
|
+
end
|
105
|
+
|
102
106
|
end
|
@@ -0,0 +1,15 @@
|
|
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
|
data/test/gem_extentions_test.rb
CHANGED
@@ -28,4 +28,19 @@ class GemExtentionsTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal paths, Gem.find_recent_resources('lib/autotest/discover.rb')
|
29
29
|
end
|
30
30
|
|
31
|
+
context "Gem::Specification" do
|
32
|
+
|
33
|
+
setup do
|
34
|
+
configatron.reset!
|
35
|
+
configatron.configure_from_hash({ 'hello' => { 'world' => 'sun' } })
|
36
|
+
@spec = Gem::Specification.new
|
37
|
+
end
|
38
|
+
|
39
|
+
should "treat Configatron::Store as nil" do
|
40
|
+
assert_equal 'nil', @spec.send(:ruby_code, configatron.hello)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
31
46
|
end
|
data/test/system_test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class SystemTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include GM::System
|
6
|
+
|
7
|
+
should "call Kernel#system" do
|
8
|
+
GM.app.expects(:log).with('> ls -l')
|
9
|
+
GM.app.expects(:log).with('> ls -a')
|
10
|
+
|
11
|
+
expects(:system).with('ls -l')
|
12
|
+
expects(:system).with('ls -a')
|
13
|
+
|
14
|
+
sh %{ ls -l }, %{ ls -a }
|
15
|
+
end
|
16
|
+
|
17
|
+
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.1.
|
4
|
+
version: 0.1.2
|
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-22 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,41 +42,20 @@ dependencies:
|
|
42
42
|
description:
|
43
43
|
email: simon.menke@gmail.com
|
44
44
|
executables:
|
45
|
+
- gem-make
|
45
46
|
- gm
|
46
|
-
- gmm
|
47
47
|
extensions: []
|
48
48
|
|
49
49
|
extra_rdoc_files: []
|
50
50
|
|
51
51
|
files:
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
- gm_generators/mit_license/templates/LICENSE.txt
|
60
|
-
- gm_generators/rails/rails_generator.rb
|
61
|
-
- gm_generators/rails/templates/rails/init.rb
|
62
|
-
- gm_generators/test/templates/test_case.rb.erb
|
63
|
-
- gm_generators/test/templates/test_helper.rb.erb
|
64
|
-
- gm_generators/test/test_generator.rb
|
65
|
-
- bin/gm
|
66
|
-
- bin/gmm
|
67
|
-
- lib/autotest/discover.rb
|
68
|
-
- lib/autotest/gm.rb
|
69
|
-
- lib/extentions/gem.rb
|
70
|
-
- lib/gm/app.rb
|
71
|
-
- lib/gm/command.rb
|
72
|
-
- lib/gm/configuration_pass.rb
|
73
|
-
- lib/gm/configuration_pass_queue.rb
|
74
|
-
- lib/gm/documentation.rb
|
75
|
-
- lib/gm/dsl.rb
|
76
|
-
- lib/gm/loader.rb
|
77
|
-
- lib/gm/network.rb
|
78
|
-
- lib/gm/system.rb
|
79
|
-
- lib/gm.rb
|
52
|
+
- test/command_test.rb
|
53
|
+
- test/configatron_test.rb
|
54
|
+
- test/configuration_pass_queue_test.rb
|
55
|
+
- test/configuration_pass_test.rb
|
56
|
+
- test/gem_extentions_test.rb
|
57
|
+
- test/system_test.rb
|
58
|
+
- test/test_helper.rb
|
80
59
|
- gm_commands/build_command.rb
|
81
60
|
- gm_commands/clean_command.rb
|
82
61
|
- gm_commands/config_command.rb
|
@@ -99,25 +78,49 @@ files:
|
|
99
78
|
- gm_passes/test.rb
|
100
79
|
- gm_networks/github_network.rb
|
101
80
|
- gm_generators/bin
|
81
|
+
- gm_generators/bin/bin_generator.rb
|
102
82
|
- gm_generators/bin/templates
|
103
83
|
- gm_generators/bin/templates/bin
|
84
|
+
- gm_generators/bin/templates/bin/bin.rb
|
104
85
|
- gm_generators/gem
|
86
|
+
- gm_generators/gem/gem_generator.rb
|
105
87
|
- gm_generators/gem/templates
|
88
|
+
- gm_generators/gem/templates/Gmfile
|
106
89
|
- gm_generators/gem/templates/lib
|
90
|
+
- gm_generators/gem/templates/lib/module.rb
|
91
|
+
- gm_generators/gem/templates/README.textile
|
107
92
|
- gm_generators/mit_license
|
93
|
+
- gm_generators/mit_license/mit_license_generator.rb
|
108
94
|
- gm_generators/mit_license/templates
|
95
|
+
- gm_generators/mit_license/templates/LICENSE.txt
|
109
96
|
- gm_generators/rails
|
97
|
+
- gm_generators/rails/rails_generator.rb
|
110
98
|
- gm_generators/rails/templates
|
111
99
|
- gm_generators/rails/templates/rails
|
100
|
+
- gm_generators/rails/templates/rails/init.rb
|
112
101
|
- gm_generators/test
|
113
102
|
- gm_generators/test/templates
|
114
|
-
- test/
|
115
|
-
- test/
|
116
|
-
- test/
|
117
|
-
- test/gem_extentions_test.rb
|
118
|
-
- test/test_helper.rb
|
103
|
+
- gm_generators/test/templates/test_case.rb.erb
|
104
|
+
- gm_generators/test/templates/test_helper.rb.erb
|
105
|
+
- gm_generators/test/test_generator.rb
|
119
106
|
- LICENSE.txt
|
120
107
|
- README.textile
|
108
|
+
- lib/autotest/discover.rb
|
109
|
+
- lib/autotest/gm.rb
|
110
|
+
- lib/extentions/configatron.rb
|
111
|
+
- lib/extentions/gem.rb
|
112
|
+
- lib/gm/app.rb
|
113
|
+
- lib/gm/command.rb
|
114
|
+
- lib/gm/configuration_pass.rb
|
115
|
+
- lib/gm/configuration_pass_queue.rb
|
116
|
+
- lib/gm/documentation.rb
|
117
|
+
- lib/gm/dsl.rb
|
118
|
+
- lib/gm/loader.rb
|
119
|
+
- lib/gm/network.rb
|
120
|
+
- lib/gm/system.rb
|
121
|
+
- lib/gm.rb
|
122
|
+
- bin/gem-make
|
123
|
+
- bin/gm
|
121
124
|
has_rdoc: true
|
122
125
|
homepage: http://github.com/simonmenke/gm
|
123
126
|
post_install_message:
|
@@ -146,7 +149,9 @@ specification_version: 2
|
|
146
149
|
summary: Building gems the clean way.
|
147
150
|
test_files:
|
148
151
|
- test/command_test.rb
|
152
|
+
- test/configatron_test.rb
|
149
153
|
- test/configuration_pass_queue_test.rb
|
150
154
|
- test/configuration_pass_test.rb
|
151
155
|
- test/gem_extentions_test.rb
|
156
|
+
- test/system_test.rb
|
152
157
|
- test/test_helper.rb
|