gm 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +22 -0
- data/README.textile +13 -0
- data/bin/gem-make +6 -0
- data/bin/gm +6 -0
- data/gm_behaviors/author_behavior.rb +29 -0
- data/gm_behaviors/bin_files_behavior.rb +10 -0
- data/gm_behaviors/dependencies_behavior.rb +22 -0
- data/gm_behaviors/executables_behavior.rb +13 -0
- data/gm_behaviors/general_behavior.rb +41 -0
- data/gm_behaviors/github_behavior.rb +11 -0
- data/gm_behaviors/gm_files_behavior.rb +13 -0
- data/gm_behaviors/lib_files_behavior.rb +10 -0
- data/gm_behaviors/rails_behavior.rb +11 -0
- data/gm_behaviors/rdoc_behavior.rb +34 -0
- data/gm_behaviors/rspec_behavior.rb +10 -0
- data/gm_behaviors/rubigen_behavior.rb +13 -0
- data/gm_behaviors/rubyforge_behavior.rb +12 -0
- data/gm_behaviors/test_behavior.rb +10 -0
- data/gm_behaviors/text_files_behavior.rb +10 -0
- data/gm_commands/build_command.rb +25 -0
- data/gm_commands/build_gemspec_command.rb +35 -0
- data/gm_commands/clean_command.rb +14 -0
- data/gm_commands/config_command.rb +42 -0
- data/gm_commands/create_command.rb +10 -0
- data/gm_commands/gen_command.rb +31 -0
- data/gm_commands/help_command.rb +246 -0
- data/gm_commands/install_command.rb +17 -0
- data/gm_commands/publish_command.rb +33 -0
- data/gm_commands/spec_command.rb +14 -0
- data/gm_generators/bin/bin_generator.rb +22 -0
- data/gm_generators/bin/templates/bin/bin.rb +3 -0
- data/gm_generators/gem/gem_generator.rb +38 -0
- data/gm_generators/gem/templates/Gmfile +4 -0
- data/gm_generators/gem/templates/README.textile +0 -0
- data/gm_generators/gem/templates/lib/module.rb +4 -0
- data/gm_generators/mit_license/mit_license_generator.rb +17 -0
- data/gm_generators/mit_license/templates/LICENSE.txt +22 -0
- data/gm_generators/rails/rails_generator.rb +18 -0
- data/gm_generators/rails/templates/rails/init.rb +1 -0
- data/gm_generators/test/templates/test_case.rb.erb +5 -0
- data/gm_generators/test/templates/test_helper.rb.erb +7 -0
- data/gm_generators/test/test_generator.rb +26 -0
- data/gm_networks/github_network.rb +72 -0
- data/gm_networks/rubyforge_network.rb +90 -0
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/gm.rb +37 -0
- data/lib/extentions/gem.rb +27 -0
- data/lib/gm.rb +30 -0
- data/lib/gm/app.rb +108 -0
- data/lib/gm/behavior.rb +23 -0
- data/lib/gm/command.rb +70 -0
- data/lib/gm/configuration.rb +20 -0
- data/lib/gm/documentation.rb +38 -0
- data/lib/gm/helpers.rb +20 -0
- data/lib/gm/loader.rb +84 -0
- data/lib/gm/network.rb +29 -0
- data/lib/gm/system.rb +16 -0
- data/test/command_test.rb +106 -0
- data/test/gem_extentions_test.rb +31 -0
- data/test/system_test.rb +17 -0
- data/test/test_helper.rb +12 -0
- metadata +159 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
|
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
|
12
|
+
|
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
|
21
|
+
|
22
|
+
def run
|
23
|
+
GM::Command.run(:build_gemspec) if File.exist?('./Gmfile')
|
24
|
+
@gen_name = self.argv.shift
|
25
|
+
@gen_options = self.argv
|
26
|
+
|
27
|
+
RubiGen::Base.use_component_sources!(:gm)
|
28
|
+
RubiGen::Scripts::Generate.new.run(@gen_options, :generator => @gen_name)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
|
2
|
+
class HelpCommand < GM::Command
|
3
|
+
|
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
|
9
|
+
|
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
|
204
|
+
puts "#{File.basename($0)} <command> <options>"
|
205
|
+
puts options.to_s
|
206
|
+
puts ""
|
207
|
+
puts "Commands:"
|
208
|
+
command_descriptions
|
209
|
+
puts ""
|
210
|
+
puts "Passes:"
|
211
|
+
passes_in_running_order
|
212
|
+
end
|
213
|
+
|
214
|
+
def passes_in_running_order
|
215
|
+
format = "% 3d %- 20s %s"
|
216
|
+
|
217
|
+
puts "- initialization"
|
218
|
+
GM::ConfigurationPassQueue.new(:initialization).each_with_index do |pass, idx|
|
219
|
+
puts format % [idx+1, pass.name, pass.description]
|
220
|
+
end
|
221
|
+
puts "- configuration"
|
222
|
+
GM::ConfigurationPassQueue.new(:configuration).each_with_index do |pass, idx|
|
223
|
+
puts format % [idx+1, pass.name, pass.description]
|
224
|
+
end
|
225
|
+
puts "- normal"
|
226
|
+
GM::ConfigurationPassQueue.new(:normal).each_with_index do |pass, idx|
|
227
|
+
puts format % [idx+1, pass.name, pass.description]
|
228
|
+
end
|
229
|
+
puts "- finalization"
|
230
|
+
GM::ConfigurationPassQueue.new(:finalization).each_with_index do |pass, idx|
|
231
|
+
puts format % [idx+1, pass.name, pass.description]
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def command_descriptions
|
236
|
+
descriptions = []
|
237
|
+
GM::Command.commands.each do |name, cmd|
|
238
|
+
descriptions << [name.to_s, cmd.description]
|
239
|
+
end
|
240
|
+
descriptions.sort { |a,b| a.first <=> b.first }
|
241
|
+
descriptions.collect do |(name, desc)|
|
242
|
+
puts "%- 17s %s" % [name, desc]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class InstallCommand < GM::Command
|
3
|
+
|
4
|
+
desc "Install the gem localy"
|
5
|
+
banner "install"
|
6
|
+
doc <<-DOC
|
7
|
+
Build and install the gem localy.
|
8
|
+
DOC
|
9
|
+
|
10
|
+
def run
|
11
|
+
GM::Command.run(:build)
|
12
|
+
|
13
|
+
app.info "Installing your gem..."
|
14
|
+
sh("sudo gem install pkg/#{app.gem_file_name}")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
class PublishCommand < GM::Command
|
3
|
+
|
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
|
12
|
+
|
13
|
+
def run
|
14
|
+
GM::Command.run(:build_gemspec)
|
15
|
+
|
16
|
+
networks = argv.collect do |network|
|
17
|
+
name = network.underscore.to_sym
|
18
|
+
klass = GM::Network.networks[name]
|
19
|
+
klass.new unless klass.nil?
|
20
|
+
end.compact
|
21
|
+
|
22
|
+
version = config[:general][:version]
|
23
|
+
networks.each do |network|
|
24
|
+
if network.has_version? version
|
25
|
+
GM.app.log "Skipping #{network.class.name} (version #{version} already present)"
|
26
|
+
else
|
27
|
+
network.publish
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
class SpecCommand < GM::Command
|
3
|
+
|
4
|
+
desc "Dump the gemspec file."
|
5
|
+
|
6
|
+
def run
|
7
|
+
GM::Command.run(:build_gemspec)
|
8
|
+
app.info "Writing your gemspec..."
|
9
|
+
File.open("#{app.gemspec.name}.gemspec", 'w+') do |f|
|
10
|
+
f.write app.gemspec.to_ruby
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
class BinGenerator < RubiGen::Base
|
3
|
+
|
4
|
+
attr_reader :bin_name
|
5
|
+
|
6
|
+
def initialize(runtime_args, runtime_options = {})
|
7
|
+
super
|
8
|
+
@destination_root = '.'
|
9
|
+
@bin_name = args.shift
|
10
|
+
end
|
11
|
+
|
12
|
+
def manifest
|
13
|
+
record do |m|
|
14
|
+
|
15
|
+
m.directory ''
|
16
|
+
%w( bin ).each { |path| m.directory path }
|
17
|
+
|
18
|
+
m.template "bin/bin.rb", "bin/#{@bin_name}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
class GemGenerator < RubiGen::Base
|
3
|
+
|
4
|
+
attr_reader :app_name, :module_name
|
5
|
+
|
6
|
+
def initialize(runtime_args, runtime_options = {})
|
7
|
+
super
|
8
|
+
usage if args.empty?
|
9
|
+
@destination_root = args.shift
|
10
|
+
@app_name = File.basename(File.expand_path(@destination_root))
|
11
|
+
@module_name = app_name.camelize
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
|
17
|
+
# Root directory and all subdirectories.
|
18
|
+
m.directory ''
|
19
|
+
%w( lib ).each { |path| m.directory path }
|
20
|
+
|
21
|
+
# Root
|
22
|
+
m.template_copy_each %w( Gmfile )
|
23
|
+
m.file_copy_each %w( README.textile )
|
24
|
+
|
25
|
+
m.template "lib/module.rb", "lib/#{app_name}.rb"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def banner
|
32
|
+
<<-EOS
|
33
|
+
Create a stub gem for #{File.basename $0} to get started.
|
34
|
+
|
35
|
+
Usage: #{File.basename $0} gen gm /path/to/your/gem"
|
36
|
+
EOS
|
37
|
+
end
|
38
|
+
end
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class MitLicenseGenerator < RubiGen::Base
|
3
|
+
|
4
|
+
def initialize(runtime_args, runtime_options = {})
|
5
|
+
super
|
6
|
+
@destination_root = '.'
|
7
|
+
end
|
8
|
+
|
9
|
+
def manifest
|
10
|
+
record do |m|
|
11
|
+
m.directory ''
|
12
|
+
|
13
|
+
m.template "LICENSE.txt", "LICENSE.txt"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|