gemstub 1.0.3 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gemstub CHANGED
@@ -1,35 +1,34 @@
1
+ #!/usr/local/bin/ruby
2
+ require 'rubygems'
1
3
  require 'fileutils'
2
4
  require 'optparse'
3
5
  require 'optparse/time'
4
6
  require 'ostruct'
5
7
  require 'pp'
6
- require "active_support"
8
+ require "mack-facets"
9
+ require 'genosaurus'
10
+ require 'erb'
7
11
 
8
12
  app = ARGV[0]
9
13
  raise "You must specify a name for this gem!" if app.nil?
10
14
 
11
15
  options = OpenStruct.new
12
16
  options.version = "0.0.1"
13
- options.binary = false
14
17
  options.author = (ENV["USERNAME"] || ENV["USER"])
15
18
  options.force = false
16
19
 
17
20
  opts = OptionParser.new do |opts|
18
- opts.banner = "Usage: example.rb [options]"
19
-
20
- opts.on("-b") do
21
- options.binary = true
22
- end
21
+ opts.banner = "Usage: gemstub [options]"
23
22
 
24
- opts.on("-v [VERSION]") do |v|
23
+ opts.on("-v [initial version]") do |v|
25
24
  options.version = v
26
25
  end
27
26
 
28
- opts.on("-a [AUTHOR]") do |v|
27
+ opts.on("-a [author name]") do |v|
29
28
  options.author = v
30
29
  end
31
30
 
32
- opts.on("-f") do |v|
31
+ opts.on("-f [force]") do |v|
33
32
  options.force = true
34
33
  end
35
34
 
@@ -37,7 +36,7 @@ end
37
36
 
38
37
  opts.parse!(ARGV)
39
38
 
40
- puts "options = #{options.inspect}"
39
+ # puts "options = #{options.inspect}"
41
40
 
42
41
  app = app.downcase.gsub(" ", "_")
43
42
 
@@ -49,142 +48,33 @@ if options.force
49
48
  end
50
49
  end
51
50
 
52
- puts "create directory: #{app}"
53
- Dir.mkdir app
54
-
55
- puts "create directory: #{app}/bin"
56
- Dir.mkdir "#{app}/bin"
57
-
58
- puts "create directory: #{app}/docs"
59
- Dir.mkdir "#{app}/docs"
60
-
61
- puts "create directory: #{app}/lib"
62
- Dir.mkdir "#{app}/lib"
63
-
64
- puts "create directory: #{app}/test"
65
- Dir.mkdir "#{app}/test"
66
-
67
- puts "creating Rakefile"
68
- File.open("#{app}/Rakefile", "w") do |file|
69
- file << %{
70
- require 'rake'
71
- require 'rake/gempackagetask'
72
- require 'rake/clean'
73
- require 'rake/testtask'
74
- require 'find'
75
-
76
- gem_spec = Gem::Specification.new do |s|
77
- s.name = '#{app}'
78
- s.version = '#{options.version}'
79
- s.summary = %{#{app}}
80
- s.description = %{#{app} was developed by: #{options.author}}
81
- s.author = "#{options.author}"
82
- #s.email = ""
83
- #s.homepage = ""
84
-
85
- s.test_files = FileList['test/**/*']
86
-
87
- s.files = FileList['lib/**/*.rb', 'README', 'doc/**/*.*']
88
- s.require_paths << 'lib'
89
-
90
- # This will loop through all files in your lib directory and autorequire them for you.
91
- # It will also ignore all Subversion files.
92
- s.autorequire = []
93
-
94
- ["lib"].each do |dir|
95
- Find.find(dir) do |f|
96
- if FileTest.directory?(f) and !f.match(/.svn/)
97
- s.require_paths << f
98
- else
99
- if FileTest.file?(f)
100
- m = f.match(/[a-zA-Z\-_]*.rb/)
101
- if m
102
- model = m.to_s
103
- unless model.match("test_")
104
- x = model.gsub('/', '').gsub('.rb', '')
105
- s.autorequire << x
106
- end
107
- end
108
- end
109
- end
110
- end
111
- end
112
- s.autorequire.uniq!
113
-
114
- #{options.binary ? "" : "#"}s.bindir = "bin"
115
- #{options.binary ? "" : "#"}s.executables = "#{app}"
116
- #s.default_executable = ""
117
- #s.add_dependency("", "")
118
- #s.add_dependency("", "")
119
- #s.extensions << ""
120
- #s.extra_rdoc_files = ["README"]
121
- #s.has_rdoc = true
122
- #s.platform = "Gem::Platform::Ruby"
123
- #s.required_ruby_version = ">= 1.8.5"
124
- #s.requirements << "An ice cold beer."
125
- #s.requirements << "Some free time!"
126
- #s.rubyforge_project = "#{app}"
127
- end
128
-
129
- Rake::GemPackageTask.new(gem_spec) do |pkg|
130
- pkg.need_zip = false
131
- pkg.need_tar = false
132
- rm_f FileList['pkg/**/*.*']
133
- end
134
-
135
- desc "Run test code"
136
- Rake::TestTask.new(:default) do |t|
137
- t.libs << "test"
138
- t.pattern = 'test/**/*_test.rb'
139
- t.verbose = true
140
- end
141
- }.strip
142
- end
143
-
144
- puts "creating README"
145
- File.open("#{app}/README", "w") do |file|
146
- file << %{
147
- README
148
- ========================================================================
149
- #{app}
150
- }.strip
151
- end
152
-
153
- ldir = options.binary ? "bin" : "lib"
154
- fext = options.binary ? "" : ".rb"
155
- puts "creating #{app}/#{ldir}/#{app}#{fext}"
156
- File.open("#{app}/#{ldir}/#{app}#{fext}", "w") do |file|
157
- file << ""
158
- end
159
-
160
- puts "creating #{app}/test/#{app}_test.rb"
161
- File.open("#{app}/test/#{app}_test.rb", "w") do |file|
162
- file << %{
163
- require File.dirname(__FILE__) + '/test_helper.rb'
164
-
165
- class #{app.classify}Test < Test::Unit::TestCase
166
-
167
- def setup
168
- end
169
-
170
- def teardown
171
- end
172
-
173
- # replace this with tests of your own.
174
- def test_truth
175
- assert true
176
- end
177
- end
178
- }.strip
179
- end
180
-
181
- puts "creating #{app}/test/test_helper.rb"
182
- File.open("#{app}/test/test_helper.rb", "w") do |file|
183
- file << %{
184
- require "test/unit"
185
-
186
- # place common methods, assertions, and other type things in this file so
187
- # other tests will have access to them.
188
-
189
- }.strip
190
- end
51
+ require File.join(File.dirname(__FILE__), "..", "lib", "gem_generator")
52
+
53
+ GemGenerator.run("app" => app, "version" => options.version, "author" => options.author)
54
+
55
+ # puts "create directory: #{app}"
56
+ # Dir.mkdir app
57
+ #
58
+ # puts "create directory: #{app}/bin"
59
+ # Dir.mkdir "#{app}/bin"
60
+ #
61
+ # puts "create directory: #{app}/doc"
62
+ # Dir.mkdir "#{app}/doc"
63
+ #
64
+ # puts "create directory: #{app}/lib"
65
+ # Dir.mkdir "#{app}/lib"
66
+ #
67
+ # puts "create directory: #{app}/test"
68
+ # Dir.mkdir "#{app}/test"
69
+ #
70
+ # # Copy over templates:
71
+ # erb_files = Dir.glob(File.join(File.dirname(__FILE__), "templates", "**/*.template"))
72
+ #
73
+ # erb_files.each do |fl|
74
+ # res = ERB.new(File.open(fl).read).result(binding)
75
+ # n = fl.gsub(File.join(File.dirname(__FILE__), "templates"), app).gsub(".template", "")
76
+ # n.gsub!("%=app%", app)
77
+ # FileUtils.mkdir_p(File.dirname(n))
78
+ # File.open(n, "w") {|f| f.puts res}
79
+ # puts "Created: #{n}"
80
+ # end
@@ -0,0 +1,15 @@
1
+ class GemGenerator < Genosaurus
2
+
3
+ def app
4
+ param(:app)
5
+ end
6
+
7
+ def version
8
+ param(:version)
9
+ end
10
+
11
+ def author
12
+ param(:author)
13
+ end
14
+
15
+ end
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/gempackagetask'
4
+
5
+ @gem_spec = Gem::Specification.new do |s|
6
+ s.name = "<%= app %>"
7
+ s.version = "<%= version %>"
8
+ s.summary = "<%= app %>"
9
+ s.description = "<%= app %> was developed by: <%= author %>"
10
+ s.author = "<%= author %>"
11
+ s.email = ""
12
+ s.homepage = ""
13
+
14
+ s.test_files = FileList['test/**/*']
15
+
16
+ s.files = FileList['lib/**/*.*', 'README', 'doc/**/*.*', 'bin/**/*.*']
17
+ s.require_paths << 'lib'
18
+
19
+ #s.bindir = "bin"
20
+ #s.executables << "<%= app %>"
21
+ #s.default_executable = ""
22
+ #s.add_dependency("", "")
23
+ #s.add_dependency("", "")
24
+ #s.extensions << ""
25
+ s.extra_rdoc_files = ["README"]
26
+ s.has_rdoc = true
27
+ #s.platform = "Gem::Platform::Ruby"
28
+ #s.required_ruby_version = ">= 1.8.6"
29
+ #s.requirements << "An ice cold beer."
30
+ #s.requirements << "Some free time!"
31
+ s.rubyforge_project = "<%= app %>"
32
+ end
@@ -0,0 +1,3 @@
1
+ README
2
+ ========================================================================
3
+ <%= app %> was developed by: <%= author %>
@@ -0,0 +1,80 @@
1
+ require 'rake'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+ require 'find'
7
+ require 'rubyforge'
8
+ require 'rubygems'
9
+ require 'rubygems/gem_runner'
10
+ require 'spec'
11
+ require 'spec/rake/spectask'
12
+
13
+ load File.join(File.dirname(__FILE__), '<%= app %>.gemspec')
14
+
15
+ # rake package
16
+ Rake::GemPackageTask.new(@gem_spec) do |pkg|
17
+ pkg.need_zip = false
18
+ pkg.need_tar = false
19
+ rm_f FileList['pkg/**/*.*']
20
+ end
21
+
22
+ # rake
23
+ desc 'Run specifications'
24
+ Spec::Rake::SpecTask.new(:default) do |t|
25
+ opts = File.join(File.dirname(__FILE__), "test", 'spec.opts')
26
+ t.spec_opts << '--options' << opts if File.exists?(opts)
27
+ t.spec_files = Dir.glob('test/**/*_spec.rb')
28
+ end
29
+
30
+ desc "Install the gem"
31
+ task :install => [:package] do |t|
32
+ sudo = ENV['SUDOLESS'] == 'true' || RUBY_PLATFORM =~ /win32|cygwin/ ? '' : 'sudo'
33
+ puts `#{sudo} gem install #{File.join("pkg", @gem_spec.name)}-#{@gem_spec.version}.gem --no-update-sources --no-ri --no-rdoc`
34
+ end
35
+
36
+ desc "Release the gem"
37
+ task :release => :install do |t|
38
+ begin
39
+ ac_path = File.join(ENV["HOME"], ".rubyforge", "auto-config.yml")
40
+ if File.exists?(ac_path)
41
+ fixed = File.open(ac_path).read.gsub(" ~: {}\n\n", '')
42
+ fixed.gsub!(/ !ruby\/object:Gem::Version \? \n.+\n.+\n\n/, '')
43
+ puts "Fixing #{ac_path}..."
44
+ File.open(ac_path, "w") {|f| f.puts fixed}
45
+ end
46
+ begin
47
+ rf = RubyForge.new
48
+ rf.configure
49
+ rf.login
50
+ rf.add_release(@gem_spec.rubyforge_project, @gem_spec.name, @gem_spec.version, File.join("pkg", "#{@gem_spec.name}-#{@gem_spec.version}.gem"))
51
+ rescue Exception => e
52
+ if e.message.match("Invalid package_id") || e.message.match("no <package_id> configured for")
53
+ puts "You need to create the package!"
54
+ rf.create_package(@gem_spec.rubyforge_project, @gem_spec.name)
55
+ rf.add_release(@gem_spec.rubyforge_project, @gem_spec.name, @gem_spec.version, File.join("pkg", "#{@gem_spec.name}-#{@gem_spec.version}.gem"))
56
+ else
57
+ raise e
58
+ end
59
+ end
60
+ rescue Exception => e
61
+ if e.message == "You have already released this version."
62
+ puts e
63
+ else
64
+ raise e
65
+ end
66
+ end
67
+ end
68
+
69
+
70
+ Rake::RDocTask.new do |rd|
71
+ rd.main = "README"
72
+ files = Dir.glob("**/*.rb")
73
+ files = files.collect {|f| f unless f.match("test/") || f.match("doc/") }.compact
74
+ files << "README"
75
+ rd.rdoc_files = files
76
+ rd.rdoc_dir = "doc"
77
+ rd.options << "--line-numbers"
78
+ rd.options << "--inline-source"
79
+ rd.title = "<%= app %>"
80
+ end
@@ -0,0 +1 @@
1
+ # Put your gem code here:
@@ -0,0 +1,3 @@
1
+ Dir.glob(File.join(File.dirname(__FILE__), '<%= app %>', '**/*.rb')).each do |f|
2
+ require f
3
+ end
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe "<%= app.camelcase %>" do
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ --format specdoc
2
+ --colour
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ require File.join(File.dirname(__FILE__), '..', 'lib', '<%= app %>')
data/test/foo_test.rb ADDED
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class FooTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ # replace this with tests of your own.
12
+ def test_truth
13
+ assert true
14
+ end
15
+
16
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+
3
+ class Test::Unit::TestCase
4
+
5
+ # place common methods, assertions, and other type things in this file so
6
+ # other tests will have access to them.
7
+
8
+ end
metadata CHANGED
@@ -1,48 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
3
- specification_version: 1
4
2
  name: gemstub
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.3
7
- date: 2007-07-06 00:00:00 -04:00
8
- summary: "Gemstub is a very simple tool for creating the stub code you need to build a gem. Usage: at a command prompt simply type: gemstub your_gem_name_here That's it, after that, you all you have to do is the actual coding of your gem! Enjoy!"
9
- require_paths:
10
- - lib
11
- - lib
12
- email:
13
- homepage:
14
- rubyforge_project:
15
- description:
4
+ version: 1.0.17
5
+ platform: ruby
6
+ authors:
7
+ - Mark Bates
16
8
  autorequire:
17
- - gemstub
18
- default_executable:
19
9
  bindir: bin
20
- has_rdoc: false
21
- required_ruby_version: !ruby/object:Gem::Version::Requirement
22
- requirements:
23
- - - ">"
24
- - !ruby/object:Gem::Version
25
- version: 0.0.0
26
- version:
27
- platform: ruby
28
- signing_key:
29
- cert_chain:
30
- post_install_message:
31
- authors: []
32
-
33
- files:
34
- - README
35
- test_files: []
36
-
37
- rdoc_options: []
38
-
39
- extra_rdoc_files: []
10
+ cert_chain: []
40
11
 
12
+ date: 2009-01-13 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mack-facets
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: genosaurus
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description:
36
+ email: mark@markbates.com
41
37
  executables:
42
38
  - gemstub
43
39
  extensions: []
44
40
 
45
- requirements: []
41
+ extra_rdoc_files: []
46
42
 
47
- dependencies: []
43
+ files:
44
+ - lib/gem_generator.rb
45
+ - lib/templates/%=app%/%=app%.gemspec.template
46
+ - lib/templates/%=app%/lib/%=app%/%=app%.rb.template
47
+ - lib/templates/%=app%/lib/%=app%.rb.template
48
+ - lib/templates/%=app%/Rakefile.template
49
+ - lib/templates/%=app%/README.template
50
+ - lib/templates/%=app%/test/lib/%=app%_spec.rb.template
51
+ - lib/templates/%=app%/test/spec.opts.template
52
+ - lib/templates/%=app%/test/spec_helper.rb.template
53
+ - README
54
+ has_rdoc: false
55
+ homepage: http://www.mackframework.com
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements: []
48
75
 
76
+ rubyforge_project: gemstub
77
+ rubygems_version: 1.3.1
78
+ signing_key:
79
+ specification_version: 2
80
+ summary: "Gemstub is a very simple tool for creating the stub code you need to build a gem. Usage: at a command prompt simply type: gemstub your_gem_name_here That's it, after that, you all you have to do is the actual coding of your gem! Enjoy!"
81
+ test_files:
82
+ - test/foo_test.rb
83
+ - test/test_helper.rb