gemstub 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gemstub CHANGED
@@ -5,7 +5,6 @@ require 'optparse'
5
5
  require 'optparse/time'
6
6
  require 'ostruct'
7
7
  require 'pp'
8
- require "mack-facets"
9
8
  require 'genosaurus'
10
9
  require 'erb'
11
10
 
@@ -31,6 +30,10 @@ opts = OptionParser.new do |opts|
31
30
  opts.on("-f [force]") do |v|
32
31
  options.force = true
33
32
  end
33
+
34
+ opts.on("-t [rspec/unit]") do |v|
35
+ options.test = v
36
+ end
34
37
 
35
38
  end
36
39
 
@@ -48,33 +51,8 @@ if options.force
48
51
  end
49
52
  end
50
53
 
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
54
+ require File.join(File.dirname(__FILE__), "..", "lib", 'gemstub', 'gem_generator', 'gem_generator')
55
+ GemGenerator.run("app" => app,
56
+ "version" => options.version,
57
+ "author" => options.author,
58
+ "test" => options.test)
@@ -0,0 +1,29 @@
1
+ class GemGenerator < Genosaurus
2
+
3
+ require_param :app
4
+
5
+ def app
6
+ param(:app)
7
+ end
8
+
9
+ def version
10
+ param(:version) || '0.0.1'
11
+ end
12
+
13
+ def author
14
+ param(:author) || (ENV["USERNAME"] || ENV["USER"])
15
+ end
16
+
17
+ def test
18
+ param(:test) || 'rspec'
19
+ end
20
+
21
+ def rspec?
22
+ test == 'rspec'
23
+ end
24
+
25
+ def unit?
26
+ test == 'unit'
27
+ end
28
+
29
+ end
@@ -0,0 +1,62 @@
1
+ app_directory:
2
+ type: directory
3
+ output_path: <%= File.join(app, "lib", app) %>
4
+
5
+ app_rake_file:
6
+ type: file
7
+ template_path: <%= File.join(templates_directory_path, "Rakefile.template") %>
8
+ output_path: <%= File.join(app, "Rakefile") %>
9
+
10
+ app_readme_file:
11
+ type: file
12
+ template_path: <%= File.join(templates_directory_path, "README.template") %>
13
+ output_path: <%= File.join(app, "README") %>
14
+
15
+ app_lib_init_file:
16
+ type: file
17
+ template_path: <%= File.join(templates_directory_path, "app_init.rb.template") %>
18
+ output_path: <%= File.join(app, "lib", "#{app}.rb") %>
19
+
20
+ app_lib_app_gem_file:
21
+ type: file
22
+ template_path: <%= File.join(templates_directory_path, "app_gem.rb.template") %>
23
+ output_path: <%= File.join(app, "lib", app, "#{app}.rb") %>
24
+
25
+ <% if rspec? %>
26
+
27
+ spec_directory:
28
+ type: directory
29
+ output_path: <%= File.join(app, "spec", "lib", app) %>
30
+
31
+ spec_helper_file:
32
+ type: file
33
+ template_path: <%= File.join(templates_directory_path, "spec", "spec_helper.rb.template") %>
34
+ output_path: <%= File.join(app, "spec", "spec_helper.rb") %>
35
+
36
+ spec_opts_file:
37
+ type: file
38
+ template_path: <%= File.join(templates_directory_path, "spec", "spec.opts.template") %>
39
+ output_path: <%= File.join(app, "spec", "spec.opts") %>
40
+
41
+ spec_file:
42
+ type: file
43
+ template_path: <%= File.join(templates_directory_path, "spec", "app_spec.rb.template") %>
44
+ output_path: <%= File.join(app, "spec", "lib", app, "#{app}_spec.rb") %>
45
+
46
+ <% elsif unit? %>
47
+
48
+ unit_directory:
49
+ type: directory
50
+ output_path: <%= File.join(app, "test", "unit") %>
51
+
52
+ unit_helper:
53
+ type: file
54
+ template_path: <%= File.join(templates_directory_path, "test", "test_helper.rb.template") %>
55
+ output_path: <%= File.join(app, "test", "test_helper.rb") %>
56
+
57
+ unit_file:
58
+ type: file
59
+ template_path: <%= File.join(templates_directory_path, "test", "test_app.rb.template") %>
60
+ output_path: <%= File.join(app, "test", "unit", "test_#{app}.rb") %>
61
+
62
+ <% end %>
@@ -7,8 +7,16 @@ require 'find'
7
7
  require 'rubyforge'
8
8
  require 'rubygems'
9
9
  require 'rubygems/gem_runner'
10
+ <%- if rspec? -%>
10
11
  require 'spec'
11
12
  require 'spec/rake/spectask'
13
+ <%- elsif unit? -%>
14
+ begin
15
+ require 'shoulda'
16
+ require 'shoulda/tasks'
17
+ rescue LoadError
18
+ end
19
+ <%- end -%>
12
20
 
13
21
  @gem_spec = Gem::Specification.new do |s|
14
22
  s.name = "<%= app %>"
@@ -18,12 +26,12 @@ require 'spec/rake/spectask'
18
26
  s.author = "<%= author %>"
19
27
  s.email = ""
20
28
  s.homepage = ""
21
- s.test_files = FileList['test/**/*']
22
29
  s.files = FileList['lib/**/*.*', 'README', 'doc/**/*.*', 'bin/**/*.*']
23
30
  s.require_paths = ['lib']
24
31
  s.extra_rdoc_files = ["README"]
25
32
  s.has_rdoc = true
26
33
  s.rubyforge_project = "<%= app %>"
34
+ # s.test_files = FileList['spec/**/*']
27
35
  #s.bindir = "bin"
28
36
  #s.executables << "<%= app %>"
29
37
  #s.add_dependency("", "")
@@ -43,6 +51,7 @@ Rake::GemPackageTask.new(@gem_spec) do |pkg|
43
51
  rm_f FileList['pkg/**/*.*']
44
52
  end
45
53
 
54
+ <%- if rspec? -%>
46
55
  # rake
47
56
  desc 'Run specifications'
48
57
  Spec::Rake::SpecTask.new(:default) do |t|
@@ -50,6 +59,15 @@ Spec::Rake::SpecTask.new(:default) do |t|
50
59
  t.spec_opts << '--options' << opts if File.exists?(opts)
51
60
  t.spec_files = Dir.glob('spec/**/*_spec.rb')
52
61
  end
62
+ <%- elsif unit? -%>
63
+ task :default => :test
64
+ Rake::TestTask.new { |t|
65
+ t.libs << "test"
66
+ t.pattern = 'test/unit/**/test_*.rb'
67
+ t.verbose = true
68
+ t.warning = true
69
+ }
70
+ <%- end -%>
53
71
 
54
72
  desc 'regenerate the gemspec'
55
73
  task :gemspec do
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), "..", "test_helper")
2
+
3
+ class Test<%= app.classify %> < Test::Unit::TestCase
4
+ context <%= app.classify %> do
5
+ should "pass" do
6
+ assert true
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ begin
3
+ require 'shoulda'
4
+ require 'mocha'
5
+ rescue LoadError
6
+ end
7
+
8
+ require File.join(File.dirname(__FILE__), '..', 'lib', '<%= app %>')
@@ -0,0 +1,5 @@
1
+ module Gemstub
2
+ module Tools
3
+
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ template_1:
2
+ type: file
3
+ template_path: <%= File.join(templates_directory_path, 'gems.yml.template') %>
4
+ output_path: <%= File.join(output_dir, 'gems.yml') %>
@@ -0,0 +1,23 @@
1
+ # specify an alternate gems repository
2
+ # source: http://local_mirror.example.com
3
+ # specify a different gem command
4
+ # gem_command: 'jruby -S gem'
5
+ gems:
6
+ # - name: postgres
7
+ # # the version to use
8
+ # version: '0.7.1'
9
+ # # use a specfic source URL
10
+ # source: 'http://mongrel.rubyforge.org/releases'
11
+ # # load with GemTools.load_gems
12
+ # load: true
13
+ # # any extra config that needs to be passed to gem install
14
+ # config: '--with-pgsql-include-dir=/usr/local/pgsql/include --with-pgsql-lib-dir=/usr/local/pgsql/lib'
15
+ # # require name is different than the gem name
16
+ # require_name: foo-bar
17
+ # - name: mislav-will_paginate
18
+ # version: 2.3.2
19
+ # require_name:
20
+ # - will_paginate
21
+ # - will_paginate/collection
22
+ # - will_paginate/array
23
+ # load: true
@@ -0,0 +1,7 @@
1
+ class YamlGenerator < Genosaurus
2
+
3
+ def output_dir
4
+ param('output_dir') || 'config'
5
+ end
6
+
7
+ end
data/lib/gemstub.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'genosaurus'
2
+ require "mack-facets"
3
+ require File.join(File.dirname(__FILE__), 'gemstub', 'tools')
4
+ require File.join(File.dirname(__FILE__), 'gemstub', 'gem_generator', 'gem_generator')
5
+ require File.join(File.dirname(__FILE__), 'gemstub', 'yaml_generator', 'yaml_generator')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemstub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Bates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-27 00:00:00 -05:00
12
+ date: 2009-02-22 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -51,14 +51,22 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
 
53
53
  files:
54
- - lib/gem_generator.rb
55
- - lib/templates/%=app%/lib/%=app%/%=app%.rb.template
56
- - lib/templates/%=app%/lib/%=app%.rb.template
57
- - lib/templates/%=app%/Rakefile.template
58
- - lib/templates/%=app%/README.template
59
- - lib/templates/%=app%/spec/lib/%=app%_spec.rb.template
60
- - lib/templates/%=app%/spec/spec.opts.template
61
- - lib/templates/%=app%/spec/spec_helper.rb.template
54
+ - lib/gemstub/gem_generator/gem_generator.rb
55
+ - lib/gemstub/gem_generator/manifest.yml
56
+ - lib/gemstub/gem_generator/templates/app_gem.rb.template
57
+ - lib/gemstub/gem_generator/templates/app_init.rb.template
58
+ - lib/gemstub/gem_generator/templates/Rakefile.template
59
+ - lib/gemstub/gem_generator/templates/README.template
60
+ - lib/gemstub/gem_generator/templates/spec/app_spec.rb.template
61
+ - lib/gemstub/gem_generator/templates/spec/spec.opts.template
62
+ - lib/gemstub/gem_generator/templates/spec/spec_helper.rb.template
63
+ - lib/gemstub/gem_generator/templates/test/test_app.rb.template
64
+ - lib/gemstub/gem_generator/templates/test/test_helper.rb.template
65
+ - lib/gemstub/tools.rb
66
+ - lib/gemstub/yaml_generator/manifest.yml
67
+ - lib/gemstub/yaml_generator/templates/gems.yml.template
68
+ - lib/gemstub/yaml_generator/yaml_generator.rb
69
+ - lib/gemstub.rb
62
70
  - README
63
71
  has_rdoc: false
64
72
  homepage: http://www.mackframework.com
@@ -67,7 +75,6 @@ rdoc_options: []
67
75
 
68
76
  require_paths:
69
77
  - lib
70
- - lib
71
78
  required_ruby_version: !ruby/object:Gem::Requirement
72
79
  requirements:
73
80
  - - ">="
data/lib/gem_generator.rb DELETED
@@ -1,15 +0,0 @@
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