rubigen 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +13 -0
- data/History.txt +14 -1
- data/Manifest.txt +11 -7
- data/{README.txt → README.rdoc} +21 -7
- data/Rakefile +20 -3
- data/Todo.txt +4 -2
- data/bin/install_rubigen_scripts +0 -0
- data/bin/rubigen +10 -0
- data/bin/ruby_app +0 -0
- data/features/development.feature +13 -0
- data/features/help.feature +14 -0
- data/features/rubigen_cli.feature +10 -0
- data/features/steps/common.rb +195 -0
- data/features/steps/env.rb +6 -0
- data/lib/rubigen/base.rb +11 -1
- data/lib/rubigen/cli.rb +31 -0
- data/lib/rubigen/commands.rb +76 -80
- data/lib/rubigen/lookup.rb +5 -7
- data/lib/rubigen/options.rb +7 -0
- data/lib/rubigen/scripts/destroy.rb +3 -0
- data/lib/rubigen/scripts.rb +15 -8
- data/lib/rubigen.rb +6 -1
- data/rubygems_generators/application_generator/USAGE +2 -2
- data/rubygems_generators/application_generator/application_generator_generator.rb +1 -1
- data/rubygems_generators/application_generator/templates/generator.rb +1 -1
- data/rubygems_generators/application_generator/templates/readme +2 -2
- data/rubygems_generators/component_generator/USAGE +3 -4
- data/rubygems_generators/component_generator/component_generator_generator.rb +1 -5
- data/rubygems_generators/component_generator/templates/generator.rb +1 -1
- data/rubygems_generators/component_generator/templates/readme +1 -1
- data/script/console +10 -0
- data/script/destroy +1 -1
- data/script/generate +1 -1
- data/test/test_component_generator_generator.rb +0 -26
- data/test/test_generator_helper.rb +3 -1
- data/test/test_helper.rb +2 -0
- data/test/test_install_rubigen_scripts_generator.rb +1 -1
- data/test/test_rubigen_cli.rb +71 -0
- data/website/index.html +5 -5
- data/website/index.txt +5 -5
- metadata +34 -16
- data/config/hoe.rb +0 -74
- data/config/requirements.rb +0 -17
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/test_generator_helper"
|
2
|
+
require 'rubigen/cli'
|
3
|
+
|
4
|
+
class TestRubigenCli < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
attr_reader :stdout
|
7
|
+
|
8
|
+
context "run executable with scope 'rubygems'" do
|
9
|
+
setup do
|
10
|
+
bare_setup
|
11
|
+
Rubigen::CLI.new.execute(@stdout_io = StringIO.new,
|
12
|
+
%w[rubygems component_generator name scope], :backtrace => true)
|
13
|
+
@stdout_io.rewind
|
14
|
+
@stdout = @stdout_io.read
|
15
|
+
end
|
16
|
+
|
17
|
+
should "create main generator manifest" do
|
18
|
+
assert_file_exists("scope_generators/name/name_generator.rb")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "run executable with scope 'rubygems'" do
|
23
|
+
setup do
|
24
|
+
Rubigen::CLI.execute(@stdout_io = StringIO.new, %w[rubygems])
|
25
|
+
@stdout_io.rewind
|
26
|
+
@stdout = @stdout_io.read
|
27
|
+
end
|
28
|
+
|
29
|
+
should "display help" do
|
30
|
+
assert_match(/General Options/, stdout)
|
31
|
+
end
|
32
|
+
|
33
|
+
should "display installed generators for 'rubygems'" do
|
34
|
+
assert_match(/Installed Generators/, stdout)
|
35
|
+
assert_match(/application_generator/, stdout)
|
36
|
+
assert_match(/component_generator/, stdout)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "run executable with multiple scopes 'rubygems' and 'something_else'" do
|
41
|
+
setup do
|
42
|
+
# rubigen rubygems,something_else a_generator
|
43
|
+
Rubigen::CLI.execute(@stdout_io = StringIO.new, ['rubygems,something_else'])
|
44
|
+
@stdout_io.rewind
|
45
|
+
@stdout = @stdout_io.read
|
46
|
+
end
|
47
|
+
|
48
|
+
should "display help" do
|
49
|
+
assert_match(/General Options/, stdout)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "display installed generators for 'rubygems,something_else'" do
|
53
|
+
assert_match(/Installed Generators/, stdout)
|
54
|
+
assert_match(/application_generator/, stdout)
|
55
|
+
assert_match(/component_generator/, stdout)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "run executable without any arguments" do
|
60
|
+
setup do
|
61
|
+
Rubigen::CLI.execute(@stdout_io = StringIO.new, %w[])
|
62
|
+
@stdout_io.rewind
|
63
|
+
@stdout = @stdout_io.read
|
64
|
+
end
|
65
|
+
|
66
|
+
should "display main usage" do
|
67
|
+
assert_match(/Usage:/, stdout)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/website/index.html
CHANGED
@@ -35,7 +35,7 @@
|
|
35
35
|
<div class="sidebar">
|
36
36
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rubigen"; return false'>
|
37
37
|
<p>Get Version</p>
|
38
|
-
<a href="http://rubyforge.org/projects/rubigen" class="numbers">1.
|
38
|
+
<a href="http://rubyforge.org/projects/rubigen" class="numbers">1.5.0</a>
|
39
39
|
</div>
|
40
40
|
|
41
41
|
<div id="twitter_search">
|
@@ -60,7 +60,7 @@
|
|
60
60
|
<h2>Background</h2>
|
61
61
|
<p>RubiGen is originally extracted from Ruby on Rails (specifically the rails_generator from its railties gem).</p>
|
62
62
|
<p>The rails_generator was hardcoded with Rails-specific dependencies (<code>RAILS_ROOT</code>), Rails generators (‘app’ = Rails application; ‘model’ = Rails model+tests+migration), and generally assumed it was the only generator framework within the Ruby world (it was). So, any RubyGem whose name ended with ‘_generator’ was assumed to be a generator for a Rails application.</p>
|
63
|
-
<p>But if you are developing
|
63
|
+
<p>But if you are developing an Adhearsion application, then you may want a different set of generators.<br />
|
64
64
|
If you are developing a RubyGem, then you will want a different set of generators.</p>
|
65
65
|
<p>RubiGen exists to give different development environments their own generator framework.</p>
|
66
66
|
<h2>Installing</h2>
|
@@ -84,8 +84,8 @@ If you are developing a RubyGem, then you will want a different set of generator
|
|
84
84
|
generate components/extensions within the framework. <br /><br />
|
85
85
|
RubiGen allows you to restrict which generators are available. For example, within<br />
|
86
86
|
RubyGem development environment (as generated by <code>newgem</code>), the <code>script/generator</code><br />
|
87
|
-
only shows <code>rubygem</code>-related generators.
|
88
|
-
to only show
|
87
|
+
only shows <code>rubygem</code>-related generators. Rails could restrict <code>script/generator</code><br />
|
88
|
+
to only show Rails related generators</li>
|
89
89
|
<li>Your framework RubyGem (e.g. <code>newgem</code> or <code>merb</code> RubyGems) needs to add <code>rubigen</code> as a <br />
|
90
90
|
dependency, so that users of your RubyGem can access the generator framework.</li>
|
91
91
|
</ol>
|
@@ -259,7 +259,7 @@ script/generate component_generator
|
|
259
259
|
<h2>Contact</h2>
|
260
260
|
<p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a> via the <a href="http://groups.google.com/group/rubigen">forum</a></p>
|
261
261
|
<p class="coda">
|
262
|
-
<a href="drnicwilliams@gmail.com">Dr Nic Williams</a>,
|
262
|
+
<a href="drnicwilliams@gmail.com">Dr Nic Williams</a>, 27th December 2008<br>
|
263
263
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
264
264
|
</p>
|
265
265
|
</div>
|
data/website/index.txt
CHANGED
@@ -14,7 +14,7 @@ RubiGen is originally extracted from Ruby on Rails (specifically the rails_gener
|
|
14
14
|
|
15
15
|
The rails_generator was hardcoded with Rails-specific dependencies (<code>RAILS_ROOT</code>), Rails generators ('app' = Rails application; 'model' = Rails model+tests+migration), and generally assumed it was the only generator framework within the Ruby world (it was). So, any RubyGem whose name ended with '_generator' was assumed to be a generator for a Rails application.
|
16
16
|
|
17
|
-
But if you are developing
|
17
|
+
But if you are developing an Adhearsion application, then you may want a different set of generators.
|
18
18
|
If you are developing a RubyGem, then you will want a different set of generators.
|
19
19
|
|
20
20
|
RubiGen exists to give different development environments their own generator framework.
|
@@ -29,7 +29,7 @@ On your development machine:
|
|
29
29
|
|
30
30
|
h2. Usage
|
31
31
|
|
32
|
-
RubiGen will be normally integrated into another RubyGem, such as <code>newgem</code> or <code>
|
32
|
+
RubiGen will be normally integrated into another RubyGem, such as <code>newgem</code> or <code>rails</code> or <code>camping</code>, rather than be used on its own.
|
33
33
|
|
34
34
|
These frameworks might use RubiGen for two reasons:
|
35
35
|
|
@@ -46,9 +46,9 @@ So, there are two steps to integrating RubiGen into your framework:
|
|
46
46
|
generate components/extensions within the framework. <br />
|
47
47
|
RubiGen allows you to restrict which generators are available. For example, within
|
48
48
|
RubyGem development environment (as generated by <code>newgem</code>), the <code>script/generator</code>
|
49
|
-
only shows <code>rubygem</code>-related generators.
|
50
|
-
to only show
|
51
|
-
# Your framework RubyGem (e.g. <code>newgem</code> or <code>
|
49
|
+
only shows <code>rubygem</code>-related generators. Rails could restrict <code>script/generator</code>
|
50
|
+
to only show Rails related generators
|
51
|
+
# Your framework RubyGem (e.g. <code>newgem</code> or <code>rails</code> RubyGems) needs to add <code>rubigen</code> as a
|
52
52
|
dependency, so that users of your RubyGem can access the generator framework.
|
53
53
|
|
54
54
|
h1. Creating generators
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubigen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-12-
|
13
|
+
date: 2008-12-27 00:00:00 +10:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,17 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
24
|
+
version: 2.2.2
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: newgem
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.2.2
|
25
35
|
version:
|
26
36
|
- !ruby/object:Gem::Dependency
|
27
37
|
name: hoe
|
@@ -31,12 +41,15 @@ dependencies:
|
|
31
41
|
requirements:
|
32
42
|
- - ">="
|
33
43
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.8.
|
44
|
+
version: 1.8.0
|
35
45
|
version:
|
36
|
-
description:
|
37
|
-
email:
|
46
|
+
description: A framework to allow Ruby applications to generate file/folder stubs (like the `rails` command does for Ruby on Rails, and the 'script/generate' command within a Rails application during development).
|
47
|
+
email:
|
48
|
+
- drnicwilliams@gmail.com
|
49
|
+
- jeremy@bitsweat.net
|
38
50
|
executables:
|
39
51
|
- install_rubigen_scripts
|
52
|
+
- rubigen
|
40
53
|
- ruby_app
|
41
54
|
extensions: []
|
42
55
|
|
@@ -44,17 +57,18 @@ extra_rdoc_files:
|
|
44
57
|
- History.txt
|
45
58
|
- License.txt
|
46
59
|
- Manifest.txt
|
47
|
-
- README.
|
60
|
+
- README.rdoc
|
48
61
|
- Todo.txt
|
49
62
|
- app_generators/ruby_app/templates/README.txt
|
50
63
|
- website/index.txt
|
51
64
|
- website/version-raw.txt
|
52
65
|
- website/version.txt
|
53
66
|
files:
|
67
|
+
- .autotest
|
54
68
|
- History.txt
|
55
69
|
- License.txt
|
56
70
|
- Manifest.txt
|
57
|
-
- README.
|
71
|
+
- README.rdoc
|
58
72
|
- Rakefile
|
59
73
|
- Todo.txt
|
60
74
|
- app_generators/ruby_app/USAGE
|
@@ -64,15 +78,20 @@ files:
|
|
64
78
|
- app_generators/ruby_app/templates/lib/module.rb
|
65
79
|
- app_generators/ruby_app/templates/test/test_helper.rb.erb
|
66
80
|
- bin/install_rubigen_scripts
|
81
|
+
- bin/rubigen
|
67
82
|
- bin/ruby_app
|
68
|
-
-
|
69
|
-
-
|
83
|
+
- features/development.feature
|
84
|
+
- features/help.feature
|
85
|
+
- features/rubigen_cli.feature
|
86
|
+
- features/steps/common.rb
|
87
|
+
- features/steps/env.rb
|
70
88
|
- generators/install_rubigen_scripts/install_rubigen_scripts_generator.rb
|
71
89
|
- generators/install_rubigen_scripts/templates/script/destroy
|
72
90
|
- generators/install_rubigen_scripts/templates/script/generate
|
73
91
|
- generators/install_rubigen_scripts/templates/script/win_script.cmd
|
74
92
|
- lib/rubigen.rb
|
75
93
|
- lib/rubigen/base.rb
|
94
|
+
- lib/rubigen/cli.rb
|
76
95
|
- lib/rubigen/commands.rb
|
77
96
|
- lib/rubigen/generated_attribute.rb
|
78
97
|
- lib/rubigen/helpers/generator_test_helper.rb
|
@@ -101,13 +120,10 @@ files:
|
|
101
120
|
- rubygems_generators/component_generator/templates/test.rb
|
102
121
|
- rubygems_generators/component_generator/templates/test_generator_helper.rb
|
103
122
|
- rubygems_generators/component_generator/templates/usage
|
123
|
+
- script/console
|
104
124
|
- script/destroy
|
105
125
|
- script/generate
|
106
126
|
- script/txt2html
|
107
|
-
- setup.rb
|
108
|
-
- tasks/deployment.rake
|
109
|
-
- tasks/environment.rake
|
110
|
-
- tasks/website.rake
|
111
127
|
- test/test_application_generator_generator.rb
|
112
128
|
- test/test_component_generator_generator.rb
|
113
129
|
- test/test_generate_builtin_application.rb
|
@@ -116,6 +132,7 @@ files:
|
|
116
132
|
- test/test_helper.rb
|
117
133
|
- test/test_install_rubigen_scripts_generator.rb
|
118
134
|
- test/test_lookup.rb
|
135
|
+
- test/test_rubigen_cli.rb
|
119
136
|
- test_unit_generators/test_unit/USAGE
|
120
137
|
- test_unit_generators/test_unit/templates/test.rb
|
121
138
|
- test_unit_generators/test_unit/test_unit_generator.rb
|
@@ -134,7 +151,7 @@ homepage: http://rubigen.rubyforge.org
|
|
134
151
|
post_install_message:
|
135
152
|
rdoc_options:
|
136
153
|
- --main
|
137
|
-
- README.
|
154
|
+
- README.rdoc
|
138
155
|
require_paths:
|
139
156
|
- lib
|
140
157
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -155,7 +172,7 @@ rubyforge_project: rubigen
|
|
155
172
|
rubygems_version: 1.3.1
|
156
173
|
signing_key:
|
157
174
|
specification_version: 2
|
158
|
-
summary:
|
175
|
+
summary: A framework to allow Ruby applications to generate file/folder stubs (like the `rails` command does for Ruby on Rails, and the 'script/generate' command within a Rails application during development).
|
159
176
|
test_files:
|
160
177
|
- test/test_application_generator_generator.rb
|
161
178
|
- test/test_component_generator_generator.rb
|
@@ -165,3 +182,4 @@ test_files:
|
|
165
182
|
- test/test_helper.rb
|
166
183
|
- test/test_install_rubigen_scripts_generator.rb
|
167
184
|
- test/test_lookup.rb
|
185
|
+
- test/test_rubigen_cli.rb
|
data/config/hoe.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'rubigen'
|
2
|
-
|
3
|
-
AUTHOR = ['Dr Nic Williams', 'Jeremy Kemper'] # can also be an array of Authors
|
4
|
-
EMAIL = "drnicwilliams@gmail.com"
|
5
|
-
DESCRIPTION = <<-EOS
|
6
|
-
A framework to allow Ruby applications to generate file/folder stubs (like the rails command does for Ruby on Rails, and the ‘script/generate’ command within a Rails application during development).
|
7
|
-
EOS
|
8
|
-
GEM_NAME = 'rubigen' # what ppl will type to install your gem
|
9
|
-
|
10
|
-
RUBYFORGE_PROJECT = 'rubigen' # The unix name for your project
|
11
|
-
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
12
|
-
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
13
|
-
|
14
|
-
@config_file = "~/.rubyforge/user-config.yml"
|
15
|
-
@config = nil
|
16
|
-
RUBYFORGE_USERNAME = "unknown"
|
17
|
-
def rubyforge_username
|
18
|
-
unless @config
|
19
|
-
begin
|
20
|
-
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
21
|
-
rescue
|
22
|
-
puts <<-EOS
|
23
|
-
ERROR: No rubyforge config file found: #{@config_file}
|
24
|
-
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
25
|
-
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
26
|
-
EOS
|
27
|
-
exit
|
28
|
-
end
|
29
|
-
end
|
30
|
-
RUBYFORGE_USERNAME.replace @config["username"]
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
REV = nil
|
35
|
-
# UNCOMMENT IF REQUIRED:
|
36
|
-
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
37
|
-
VERS = RubiGen::VERSION
|
38
|
-
RDOC_OPTS = ['--quiet', '--title', 'rubigen documentation',
|
39
|
-
"--opname", "index.html",
|
40
|
-
"--line-numbers",
|
41
|
-
"--main", "README",
|
42
|
-
"--inline-source"]
|
43
|
-
|
44
|
-
class Hoe
|
45
|
-
def extra_deps
|
46
|
-
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
47
|
-
@extra_deps
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Generate all the Rake tasks
|
52
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
53
|
-
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
54
|
-
p.author = AUTHOR
|
55
|
-
p.description = DESCRIPTION
|
56
|
-
p.email = EMAIL
|
57
|
-
p.summary = DESCRIPTION
|
58
|
-
p.url = HOMEPATH
|
59
|
-
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
60
|
-
p.test_globs = ["test/**/test_*.rb"]
|
61
|
-
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
62
|
-
|
63
|
-
# == Optional
|
64
|
-
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
65
|
-
p.extra_deps = [ [ 'activesupport', '>= 1.4.4'] ] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
66
|
-
|
67
|
-
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
72
|
-
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
73
|
-
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
74
|
-
hoe.rsync_args = '-av --delete --ignore-errors'
|
data/config/requirements.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
include FileUtils
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
%w[rake hoe].each do |req_gem|
|
6
|
-
begin
|
7
|
-
require req_gem
|
8
|
-
rescue LoadError
|
9
|
-
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
-
puts "Installation: gem install #{req_gem} -y"
|
11
|
-
exit
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
16
|
-
|
17
|
-
require 'rubigen'
|