newgem 0.11.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +42 -0
- data/Manifest.txt +84 -17
- data/README.txt +3 -2
- data/Rakefile +4 -106
- data/Todo.txt +1 -1
- data/app_generators/newgem/newgem_generator.rb +172 -0
- data/{templates → app_generators/newgem/templates}/History.txt +1 -1
- data/{templates → app_generators/newgem/templates}/License.txt +1 -1
- data/app_generators/newgem/templates/README.txt +1 -0
- data/app_generators/newgem/templates/Rakefile +4 -0
- data/{templates → app_generators/newgem/templates}/app.rb +3 -3
- data/app_generators/newgem/templates/config/hoe.rb +73 -0
- data/app_generators/newgem/templates/config/requirements.rb +17 -0
- data/app_generators/newgem/templates/empty.log +0 -0
- data/app_generators/newgem/templates/module.rb +5 -0
- data/app_generators/newgem/templates/script/destroy +14 -0
- data/app_generators/newgem/templates/script/generate +14 -0
- data/{templates → app_generators/newgem/templates}/setup.rb +0 -0
- data/{templates → app_generators/newgem/templates}/spec.opts +0 -0
- data/{templates → app_generators/newgem/templates}/spec.rb +0 -0
- data/app_generators/newgem/templates/tasks/deployment.rake +27 -0
- data/app_generators/newgem/templates/tasks/environment.rake +7 -0
- data/app_generators/newgem/templates/tasks/website.rake +9 -0
- data/{templates → app_generators/newgem/templates}/test.rb +1 -1
- data/app_generators/newgem/templates/test_helper.rb +2 -0
- data/app_generators/newgem/templates/version.rb +9 -0
- data/bin/newgem +9 -272
- data/bundles/RubyGem.tmbundle/Snippets/History header trunk.tmSnippet +18 -0
- data/bundles/RubyGem.tmbundle/Snippets/History header.tmSnippet +18 -0
- data/bundles/RubyGem.tmbundle/Syntaxes/Rdoc.tmLanguage +70 -0
- data/bundles/RubyGem.tmbundle/info.plist +16 -0
- data/config/hoe.rb +48 -0
- data/config/svn_branch.rb +15 -0
- data/lib/newgem.rb +2 -3
- data/lib/newgem/quick_template.rb +28 -0
- data/lib/newgem/tasks.rb +1 -0
- data/lib/newgem/version.rb +1 -1
- data/newgem_generators/install_website/USAGE +5 -0
- data/newgem_generators/install_website/install_website_generator.rb +76 -0
- data/{templates/scripts → newgem_generators/install_website/templates/script}/txt2html +15 -8
- data/newgem_generators/install_website/templates/tasks/website.rake +17 -0
- data/{templates → newgem_generators/install_website/templates}/website/index.html +2 -2
- data/newgem_generators/install_website/templates/website/index.txt +39 -0
- data/newgem_theme_generators/plain/USAGE +5 -0
- data/newgem_theme_generators/plain/plain_generator.rb +54 -0
- data/{templates → newgem_theme_generators/plain/templates}/website/javascripts/rounded_corners_lite.inc.js +0 -0
- data/{templates → newgem_theme_generators/plain/templates}/website/stylesheets/screen.css +0 -0
- data/{templates → newgem_theme_generators/plain/templates}/website/template.rhtml +6 -6
- data/rubygems_generators/application_generator/USAGE +28 -0
- data/rubygems_generators/application_generator/application_generator_generator.rb +58 -0
- data/rubygems_generators/application_generator/templates/bin +12 -0
- data/rubygems_generators/application_generator/templates/generator.rb +51 -0
- data/rubygems_generators/application_generator/templates/readme +24 -0
- data/rubygems_generators/application_generator/templates/test.rb +43 -0
- data/rubygems_generators/application_generator/templates/test_generator_helper.rb +19 -0
- data/rubygems_generators/application_generator/templates/usage +5 -0
- data/rubygems_generators/component_generator/USAGE +29 -0
- data/rubygems_generators/component_generator/component_generator_generator.rb +52 -0
- data/rubygems_generators/component_generator/templates/generator.rb +51 -0
- data/rubygems_generators/component_generator/templates/readme +28 -0
- data/rubygems_generators/component_generator/templates/test.rb +43 -0
- data/rubygems_generators/component_generator/templates/test_generator_helper.rb +19 -0
- data/rubygems_generators/component_generator/templates/usage +5 -0
- data/rubygems_generators/executable/executable_generator.rb +53 -0
- data/rubygems_generators/executable/templates/app.rb +44 -0
- data/rubygems_generators/install_jruby/USAGE +5 -0
- data/rubygems_generators/install_jruby/install_jruby_generator.rb +48 -0
- data/rubygems_generators/install_jruby/templates/tasks/jruby.rake +7 -0
- data/rubygems_generators/install_rspec/USAGE +5 -0
- data/rubygems_generators/install_rspec/install_rspec_generator.rb +55 -0
- data/rubygems_generators/install_rspec/templates/spec.rb +11 -0
- data/rubygems_generators/install_rspec/templates/spec/spec.opts +1 -0
- data/rubygems_generators/install_rspec/templates/spec/spec_helper.rb +7 -0
- data/rubygems_generators/install_rspec/templates/tasks/rspec.rake +21 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/{scripts → script}/txt2html +3 -3
- data/{scripts → script}/txt2js +0 -0
- data/tasks/bundles.rake +12 -0
- data/tasks/deployment.rake +27 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +19 -0
- data/test/test_application_generator_generator.rb +60 -0
- data/test/test_executable_generator.rb +28 -0
- data/test/test_generate_component_generator.rb +67 -0
- data/test/test_generator_helper.rb +19 -0
- data/test/test_install_jruby_generator.rb +29 -0
- data/test/test_install_rspec_generator.rb +33 -0
- data/test/test_install_website_generator.rb +50 -0
- data/test/test_newgem_generator.rb +120 -0
- data/test/test_plain_generator.rb +37 -0
- data/website/images/beginning-ruby.jpg +0 -0
- data/website/index.html +8 -6
- data/website/index.txt +4 -2
- data/website/rubyforge.html +3 -3
- data/website/version-raw.js +1 -1
- data/website/version.js +1 -1
- metadata +111 -27
- data/templates/Manifest.txt +0 -15
- data/templates/Rakefile +0 -123
- data/templates/website/index.txt +0 -38
- data/test/test_svn.rb +0 -13
@@ -0,0 +1 @@
|
|
1
|
+
README
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Created by
|
4
|
-
# Copyright (c)
|
3
|
+
# Created by <%= author %> on <%= (now = Time.now).year %>-<%= now.month %>-<%= now.day %>.
|
4
|
+
# Copyright (c) <%= now.year %>. All rights reserved.
|
5
5
|
|
6
6
|
begin
|
7
7
|
require 'rubygems'
|
@@ -22,7 +22,7 @@ parser = OptionParser.new do |opts|
|
|
22
22
|
opts.banner = <<BANNER
|
23
23
|
This application is wonderful because...
|
24
24
|
|
25
|
-
Usage:
|
25
|
+
Usage: #{File.basename($0)} [options]
|
26
26
|
|
27
27
|
Options are:
|
28
28
|
BANNER
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require '<%= gem_name %>/version'
|
2
|
+
|
3
|
+
AUTHOR = '<%= author %>' # can also be an array of Authors
|
4
|
+
EMAIL = "<%= email %>"
|
5
|
+
DESCRIPTION = "description of gem"
|
6
|
+
GEM_NAME = '<%= gem_name %>' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = '<%= gem_name %>' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
+
@config = nil
|
13
|
+
RUBYFORGE_USERNAME = "unknown"
|
14
|
+
def rubyforge_username
|
15
|
+
unless @config
|
16
|
+
begin
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
18
|
+
rescue
|
19
|
+
puts <<-EOS
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}"
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
23
|
+
EOS
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
REV = nil
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
33
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
34
|
+
VERS = <%= module_name %>::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', '<%= gem_name %> documentation',
|
36
|
+
"--opname", "index.html",
|
37
|
+
"--line-numbers",
|
38
|
+
"--main", "README",
|
39
|
+
"--inline-source"]
|
40
|
+
|
41
|
+
class Hoe
|
42
|
+
def extra_deps
|
43
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
|
+
@extra_deps
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generate all the Rake tasks
|
49
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
|
+
p.author = AUTHOR
|
52
|
+
p.description = DESCRIPTION
|
53
|
+
p.email = EMAIL
|
54
|
+
p.summary = DESCRIPTION
|
55
|
+
p.url = HOMEPATH
|
56
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
57
|
+
p.test_globs = ["test/**/test_*.rb"]
|
58
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
59
|
+
|
60
|
+
# == Optional
|
61
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
|
62
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
63
|
+
<% if is_jruby %>
|
64
|
+
# JRuby gem created, e.g. <%= gem_name %>-X.Y.Z-jruby.gem
|
65
|
+
p.spec_extras = { :platform => 'jruby' } # A hash of extra values to set in the gemspec.
|
66
|
+
<% else %>
|
67
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
68
|
+
<% end %>
|
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')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].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 '<%= gem_name %>'
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! :rubygems
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! :rubygems, :newgem
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{RUBYFORGE_USERNAME}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{RUBYFORGE_USERNAME}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
data/bin/newgem
CHANGED
@@ -1,276 +1,13 @@
|
|
1
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubigen'
|
2
3
|
|
3
|
-
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
4
|
+
if %w(-v --version).include? ARGV.first
|
5
|
+
require 'newgem/version'
|
6
|
+
puts "#{File.basename($0)} #{Newgem::VERSION::STRING}"
|
7
|
+
exit(0)
|
7
8
|
end
|
8
9
|
|
9
|
-
require 'fileutils'
|
10
|
-
require 'active_support'
|
11
|
-
require 'optparse'
|
12
10
|
|
13
|
-
require '
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
OPTIONS = {
|
18
|
-
:import_path => nil,
|
19
|
-
:version => '0.0.1',
|
20
|
-
:full_name => nil,
|
21
|
-
:email => nil,
|
22
|
-
:bin_name => nil,
|
23
|
-
:svn_struct => nil,
|
24
|
-
:test_framework => 'test::unit'
|
25
|
-
}
|
26
|
-
parser = OptionParser.new do |opts|
|
27
|
-
opts.banner = <<BANNER
|
28
|
-
Take any library or Rails plugin or command line application,
|
29
|
-
gemify it, and easily share it with the Ruby world.
|
30
|
-
|
31
|
-
Usage: #{File.basename($0)} [options] <gemname>
|
32
|
-
|
33
|
-
Options are:
|
34
|
-
BANNER
|
35
|
-
opts.separator ""
|
36
|
-
opts.on("-b", "--bin-name=BIN_NAME[,BIN_NAME2]", String,
|
37
|
-
"Sets up executable scripts in the bin folder.",
|
38
|
-
"Default: none") { |OPTIONS[:bin_name]| }
|
39
|
-
opts.on("-i", "--import_path=PATH", String,
|
40
|
-
"Path where your files could be copied from.",
|
41
|
-
"Default: none") { |OPTIONS[:import_path]| }
|
42
|
-
opts.on("-n", "--full_name=PATH", String,
|
43
|
-
"Your name to be inserted into generated files.",
|
44
|
-
"Default: ~/.rubyforge/user-config.yml[user_name]") { |OPTIONS[:full_name]| }
|
45
|
-
opts.on("-e", "--email=PATH", String,
|
46
|
-
"Your email to be inserted into generated files.",
|
47
|
-
"Default: ~/.rubyforge/user-config.yml[email]") { |OPTIONS[:email]| }
|
48
|
-
opts.on("-s", "--svn",
|
49
|
-
"Creates trunk/branches/tags folders beneath <gemname> folder.",
|
50
|
-
"Generated gem placed in trunk folder.") { |OPTIONS[:svn_struct]| }
|
51
|
-
opts.on("-t", "--test-with=TEST_FRAMEWORK", String,
|
52
|
-
"Select your preferred testing framework.",
|
53
|
-
"Options: test::unit (default), rspec.") { |OPTIONS[:test_framework]| }
|
54
|
-
opts.on("-v", "--version=YOUR_VERSION", String,
|
55
|
-
"Version of the gem you are creating.",
|
56
|
-
"Default: 0.0.1") { |OPTIONS[:version]| }
|
57
|
-
opts.on("-h", "--help",
|
58
|
-
"Show this help message.") { puts opts; exit }
|
59
|
-
opts.parse!(ARGV)
|
60
|
-
end
|
61
|
-
OPTIONS[:version] = OPTIONS[:version].to_s.split(/\./)
|
62
|
-
version_str = OPTIONS[:version].join('.')
|
63
|
-
author = OPTIONS[:full_name]
|
64
|
-
email = OPTIONS[:email]
|
65
|
-
svn_struct = OPTIONS[:svn_struct]
|
66
|
-
unless author && email
|
67
|
-
rubyforge_config = Newgem::Rubyforge.new
|
68
|
-
author ||= rubyforge_config.full_name
|
69
|
-
email ||= rubyforge_config.email
|
70
|
-
end
|
71
|
-
test_framework = OPTIONS[:test_framework]
|
72
|
-
|
73
|
-
gem_name = project_name = ARGV[0]
|
74
|
-
parser.parse!(["-h"]) unless gem_name
|
75
|
-
|
76
|
-
module_name = project_name.classify
|
77
|
-
root = project_name + (svn_struct ? '/trunk' : '')
|
78
|
-
lib = root + '/lib'
|
79
|
-
lib_project_name = root + '/lib/' + project_name
|
80
|
-
version = root + "/lib/" + project_name + "/version.rb"
|
81
|
-
readme, setup = %w(README.txt setup.rb).
|
82
|
-
collect {|f| root + '/' + f}
|
83
|
-
template_files = %w(Rakefile History.txt License.txt Manifest.txt scripts/txt2html website/index.txt website/index.html website/template.rhtml)
|
84
|
-
copy_files = %w(website/javascripts/rounded_corners_lite.inc.js website/stylesheets/screen.css)
|
85
|
-
|
86
|
-
main = root + "/lib/" + project_name + ".rb"
|
87
|
-
|
88
|
-
examples = root + '/examples'
|
89
|
-
bin = root + '/bin'
|
90
|
-
folders = %w( scripts website website/javascripts website/stylesheets)
|
91
|
-
|
92
|
-
FileUtils.rm_rf project_name
|
93
|
-
|
94
|
-
puts "creating: " + project_name
|
95
|
-
Dir.mkdir project_name
|
96
|
-
|
97
|
-
if svn_struct
|
98
|
-
%w[trunk branches tags].each do |folder|
|
99
|
-
folder_path = File.join(project_name, folder)
|
100
|
-
puts "creating: " + folder_path
|
101
|
-
Dir.mkdir folder_path
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
puts "creating: " + readme
|
106
|
-
File.open(readme, 'w') do |file|
|
107
|
-
file << <<-eos
|
108
|
-
README for #{project_name}
|
109
|
-
===========#{'=' * project_name.length}
|
110
|
-
|
111
|
-
eos
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
puts "creating: " + lib
|
116
|
-
FileUtils.mkdir_p lib
|
117
|
-
|
118
|
-
folders.each do |folder|
|
119
|
-
new_folder = root + '/' + folder
|
120
|
-
puts "creating: " + new_folder
|
121
|
-
FileUtils.mkdir_p new_folder
|
122
|
-
end
|
123
|
-
|
124
|
-
if OPTIONS[:import_path]
|
125
|
-
require 'fileutils'
|
126
|
-
OPTIONS[:import_path].chomp! if OPTIONS[:import_path][-1] == 47 # /
|
127
|
-
FileUtils.cp_r OPTIONS[:import_path] + '/.', lib, :preserve => true
|
128
|
-
end
|
129
|
-
|
130
|
-
puts "creating: " + lib_project_name
|
131
|
-
FileUtils.mkdir_p lib_project_name
|
132
|
-
|
133
|
-
puts "creating: " + main
|
134
|
-
File.open(main, 'w') do |file|
|
135
|
-
file << <<-EOS
|
136
|
-
module #{module_name}
|
137
|
-
end
|
138
|
-
|
139
|
-
require '#{project_name}/version'
|
140
|
-
EOS
|
141
|
-
end
|
142
|
-
|
143
|
-
puts "creating: " + version
|
144
|
-
File.open(version, 'w') do |file|
|
145
|
-
file << <<-EOS
|
146
|
-
module #{module_name} #:nodoc:
|
147
|
-
module VERSION #:nodoc:
|
148
|
-
MAJOR = #{OPTIONS[:version][0] || '0'}
|
149
|
-
MINOR = #{OPTIONS[:version][1] || '0'}
|
150
|
-
TINY = #{OPTIONS[:version][2] || '0'}
|
151
|
-
|
152
|
-
STRING = [MAJOR, MINOR, TINY].join('.')
|
153
|
-
end
|
154
|
-
end
|
155
|
-
EOS
|
156
|
-
end
|
157
|
-
|
158
|
-
puts "creating: " + bin
|
159
|
-
Dir.mkdir bin
|
160
|
-
|
161
|
-
if OPTIONS[:bin_name]
|
162
|
-
bin_names_list = OPTIONS[:bin_name].split(',')
|
163
|
-
template = File.open(templates + 'app.rb','r') {|f| f.readlines.join}
|
164
|
-
bin_names_list.each do |bin_name|
|
165
|
-
puts "creating: " + bin + '/' + bin_name
|
166
|
-
File.open(bin + '/' + bin_name, 'w') do |file|
|
167
|
-
file << eval('"' + template.gsub(/"/, '\"') + '"')
|
168
|
-
end
|
169
|
-
end
|
170
|
-
bin_names = bin_names_list.join(' ')
|
171
|
-
else
|
172
|
-
bin_names = ''
|
173
|
-
bin_names_list = []
|
174
|
-
end
|
175
|
-
|
176
|
-
# Setup spec/test::unit environments
|
177
|
-
# Would like to refactor this...
|
178
|
-
if test_framework == 'rspec'
|
179
|
-
test = root + "/spec"
|
180
|
-
test_helper = test + "/spec_helper.rb"
|
181
|
-
test_template = 'spec.rb'
|
182
|
-
unit_test = test + "/" + project_name + "_spec.rb"
|
183
|
-
test_file_prefix = 'spec/NAME_spec'
|
184
|
-
spec_opts = 'spec.opts'
|
185
|
-
unit_test_template = <<-eos
|
186
|
-
require 'spec'
|
187
|
-
eos
|
188
|
-
requirements = <<-eos
|
189
|
-
begin
|
190
|
-
require 'spec/rake/spectask'
|
191
|
-
rescue LoadError
|
192
|
-
puts 'To use rspec for testing you must install rspec gem:'
|
193
|
-
puts '$ sudo gem install rspec'
|
194
|
-
exit
|
195
|
-
end
|
196
|
-
eos
|
197
|
-
test_task = <<-eos
|
198
|
-
desc "Run the specs under spec/models"
|
199
|
-
Spec::Rake::SpecTask.new do |t|
|
200
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
201
|
-
t.spec_files = FileList['spec/*_spec.rb']
|
202
|
-
end
|
203
|
-
|
204
|
-
desc "Default task is to run specs"
|
205
|
-
task :default => :spec
|
206
|
-
eos
|
207
|
-
else
|
208
|
-
test = root + "/test"
|
209
|
-
test_helper = test + "/test_helper.rb"
|
210
|
-
test_template = 'test.rb'
|
211
|
-
unit_test = test + "/test_" + project_name + ".rb"
|
212
|
-
test_file_prefix = 'test/test_NAME'
|
213
|
-
unit_test_template = <<-eos
|
214
|
-
require 'test/unit'
|
215
|
-
require File.dirname(__FILE__) + '/../lib/#{project_name}'
|
216
|
-
eos
|
217
|
-
requirements = ''
|
218
|
-
test_task = ''
|
219
|
-
end
|
220
|
-
|
221
|
-
puts "creating: " + test
|
222
|
-
Dir.mkdir test
|
223
|
-
|
224
|
-
puts "creating: " + test_helper
|
225
|
-
File.open(test_helper, 'w') do |file|
|
226
|
-
file << unit_test_template
|
227
|
-
end
|
228
|
-
|
229
|
-
puts "creating: " + unit_test
|
230
|
-
|
231
|
-
template = File.open(templates + test_template,'r') {|f| f.readlines.join}
|
232
|
-
File.open(unit_test, 'w') do |file|
|
233
|
-
file << eval('"' + template.gsub(/"/, '\"') + '"')
|
234
|
-
end
|
235
|
-
|
236
|
-
if test_framework == 'rspec'
|
237
|
-
spec_opts_file = test + "/" + spec_opts
|
238
|
-
puts "creating: " + spec_opts_file
|
239
|
-
template = File.open(templates + spec_opts, 'r') { |f| f.readlines.join }
|
240
|
-
File.open(spec_opts_file, 'w') do |file|
|
241
|
-
file << eval('"' + template.gsub(/"/, '\""') + '"')
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
puts "creating: " + examples
|
246
|
-
Dir.mkdir examples
|
247
|
-
|
248
|
-
puts "creating: " + setup
|
249
|
-
template = File.open(templates + 'setup.rb','r') {|f| f.readlines.join}
|
250
|
-
File.open(setup, 'w') do |file|
|
251
|
-
file << template
|
252
|
-
end
|
253
|
-
|
254
|
-
bin_names_list = bin_names_list.collect {|name| 'bin/' + name }.join("\n")
|
255
|
-
bin_names_list += "\n" if bin_names_list.size > 0
|
256
|
-
test_names_list = ['helper.rb',"#{project_name}.rb"].sort.collect {|name| test_file_prefix.gsub('NAME', name) }.join("\n")
|
257
|
-
|
258
|
-
template_files.each do |template_file|
|
259
|
-
puts "creating: " + root + '/' + template_file
|
260
|
-
template = File.open(templates + template_file,'r') {|f| f.readlines.join}
|
261
|
-
File.open(root + '/' + template_file, 'w') do |file|
|
262
|
-
file << eval('"' + template.gsub(/"/, '\"') + '"')
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
copy_files.each do |file|
|
267
|
-
puts "copying: " + root + '/' + file
|
268
|
-
template = File.open(templates + file,'r') {|f| f.readlines.join}
|
269
|
-
File.open(root + '/' + file, 'w') do |file|
|
270
|
-
file << template
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
puts "NOW - update #{gem_name}/Rakefile with gem description, etc"
|
11
|
+
require 'rubigen/scripts/generate'
|
12
|
+
RubiGen::Base.use_application_sources! :rubygems, :newgem, :newgem_theme
|
13
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'newgem')
|