singem 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data/.gitignore +2 -0
  2. data/README.md +3 -10
  3. data/Rakefile +0 -54
  4. data/bin/singem +1 -5
  5. data/lib/generators/{twitter → default}/USAGE +0 -0
  6. data/lib/generators/{cucumber/cucumber_generator.rb → default/default_generator.rb} +4 -12
  7. data/lib/generators/default/templates/Gemfile +14 -0
  8. data/lib/generators/{cucumber → default}/templates/LICENSE +0 -0
  9. data/lib/generators/{cucumber → default}/templates/README.md +0 -0
  10. data/lib/generators/default/templates/Rakefile +19 -0
  11. data/lib/generators/{cucumber → default}/templates/TODO +1 -1
  12. data/lib/generators/default/templates/config.ru.erb +11 -0
  13. data/lib/generators/default/templates/lib/templates.rb.erb +13 -0
  14. data/lib/generators/{cucumber → default}/templates/lib/templates/app.rb.erb +1 -1
  15. data/lib/generators/{cucumber → default}/templates/spec/spec_helper.rb.erb +0 -0
  16. data/lib/generators/{cucumber → default}/templates/spec/templates_spec.rb.erb +0 -0
  17. data/lib/singem/version.rb +4 -0
  18. data/singem.gemspec +22 -0
  19. metadata +39 -74
  20. data/lib/generators/cucumber/USAGE +0 -5
  21. data/lib/generators/cucumber/templates/Gemfile +0 -29
  22. data/lib/generators/cucumber/templates/Rakefile +0 -71
  23. data/lib/generators/cucumber/templates/config.ru.erb +0 -20
  24. data/lib/generators/cucumber/templates/features/basics.feature.erb +0 -7
  25. data/lib/generators/cucumber/templates/features/step_definitions/basics.rb.erb +0 -8
  26. data/lib/generators/cucumber/templates/features/support/env.rb.erb +0 -21
  27. data/lib/generators/cucumber/templates/lib/templates.rb.erb +0 -16
  28. data/lib/generators/cucumber/templates/spec/fixtures.rb.erb +0 -0
  29. data/lib/generators/twitter/templates/Gemfile +0 -32
  30. data/lib/generators/twitter/templates/LICENSE +0 -20
  31. data/lib/generators/twitter/templates/README.md +0 -10
  32. data/lib/generators/twitter/templates/Rakefile +0 -71
  33. data/lib/generators/twitter/templates/TODO +0 -4
  34. data/lib/generators/twitter/templates/config.ru.erb +0 -23
  35. data/lib/generators/twitter/templates/features/basics.feature.erb +0 -11
  36. data/lib/generators/twitter/templates/features/step_definitions/basics.rb.erb +0 -15
  37. data/lib/generators/twitter/templates/features/support/env.rb.erb +0 -23
  38. data/lib/generators/twitter/templates/lib/templates.rb.erb +0 -55
  39. data/lib/generators/twitter/templates/lib/templates/app.rb.erb +0 -65
  40. data/lib/generators/twitter/templates/lib/templates/models/user.rb.erb +0 -38
  41. data/lib/generators/twitter/templates/lib/templates/views/about.haml +0 -5
  42. data/lib/generators/twitter/templates/lib/templates/views/failed.haml +0 -4
  43. data/lib/generators/twitter/templates/lib/templates/views/home.haml +0 -1
  44. data/lib/generators/twitter/templates/spec/fixtures.rb.erb +0 -0
  45. data/lib/generators/twitter/templates/spec/helpers.rb.erb +0 -36
  46. data/lib/generators/twitter/templates/spec/spec_helper.rb.erb +0 -39
  47. data/lib/generators/twitter/templates/spec/templates_spec.rb.erb +0 -59
  48. data/lib/generators/twitter/twitter_generator.rb +0 -90
@@ -0,0 +1,2 @@
1
+ pkg
2
+ ./*.gem
data/README.md CHANGED
@@ -6,7 +6,7 @@ singem
6
6
  Installation
7
7
  ============
8
8
 
9
- % sudo gem install singem
9
+ % gem install singem
10
10
 
11
11
  Or build it yourself
12
12
 
@@ -20,13 +20,6 @@ Basic Sinatra App, no sessions, cucumber testing
20
20
  ------------------------------------------------
21
21
  % singem foo
22
22
  % cd foo
23
- % bundle install
24
- % bundle exec rake
23
+ % bundle install --binstubs
24
+ % bin/rake
25
25
 
26
- Basic Twitter OAuth App,
27
- ------------------------------
28
- % singem --twitter foo
29
- % cd foo
30
- % bundle install
31
- % bundle exec rake
32
- % open http://twitter.com/oauth_clients
data/Rakefile CHANGED
@@ -2,57 +2,3 @@ require 'rake/gempackagetask'
2
2
  require 'rubygems/specification'
3
3
  require 'date'
4
4
  require 'spec/rake/spectask'
5
-
6
- GEM = "singem"
7
- GEM_VERSION = "0.2.0"
8
- AUTHOR = "Corey Donohoe"
9
- EMAIL = "atmos@atmos.org"
10
- HOMEPAGE = "http://github.com/atmos/singem"
11
- SUMMARY = "A gem that provides generators for sinatra apps, ready to go with rack-test/webrat/randexp and others"
12
-
13
- spec = Gem::Specification.new do |s|
14
- s.name = GEM
15
- s.version = GEM_VERSION
16
- s.platform = Gem::Platform::RUBY
17
- s.has_rdoc = true
18
- s.extra_rdoc_files = ["LICENSE", 'TODO']
19
- s.summary = SUMMARY
20
- s.description = s.summary
21
- s.author = AUTHOR
22
- s.email = EMAIL
23
- s.homepage = HOMEPAGE
24
-
25
- s.add_dependency "rubigen"
26
- s.add_dependency "bundler", '~>0.9.3'
27
-
28
- s.bindir = "bin"
29
- s.executables = %w( singem )
30
- s.require_path = 'lib'
31
- s.autorequire = GEM
32
- s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
33
- end
34
-
35
- task :default => :spec
36
-
37
- desc "Run specs"
38
- Spec::Rake::SpecTask.new do |t|
39
- t.spec_files = FileList['spec/**/*_spec.rb']
40
- t.spec_opts = %w(-fs --color)
41
- end
42
-
43
-
44
- Rake::GemPackageTask.new(spec) do |pkg|
45
- pkg.gem_spec = spec
46
- end
47
-
48
- desc "install the gem locally"
49
- task :install => [:package] do
50
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
51
- end
52
-
53
- desc "create a gemspec file"
54
- task :make_spec do
55
- File.open("#{GEM}.gemspec", "w") do |file|
56
- file.puts spec.to_ruby
57
- end
58
- end
data/bin/singem CHANGED
@@ -12,8 +12,4 @@ RubiGen::Base.prepend_sources(*[
12
12
  RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "lib/generators"))
13
13
  ])
14
14
 
15
- if ARGV.delete "--twitter"
16
- RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'twitter', :backtrace => true)
17
- else
18
- RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'cucumber', :backtrace => true)
19
- end
15
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => "default", :backtrace => true)
@@ -1,4 +1,4 @@
1
- class CucumberGenerator < RubiGen::Base
1
+ class DefaultGenerator < RubiGen::Base
2
2
  DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
3
3
  Config::CONFIG['ruby_install_name'])
4
4
 
@@ -19,28 +19,20 @@ class CucumberGenerator < RubiGen::Base
19
19
  m.directory ''
20
20
  BASEDIRS.each { |path| m.directory path }
21
21
  m.directory "lib/#{name}"
22
- m.directory "features/support"
23
- m.directory "features/step_definitions"
24
22
 
25
23
  # Create stubs
26
- m.template "config.ru.erb", "config.ru.example"
24
+ m.template "config.ru.erb", "config.ru"
27
25
  m.template "lib/templates.rb.erb", "lib/#{name}.rb"
28
26
  m.template "lib/templates/app.rb.erb", "lib/#{name}/app.rb"
29
27
 
30
- # cucumber stubs
31
- m.template "features/support/env.rb.erb", "features/support/env.rb"
32
- m.template "features/basics.feature.erb", "features/#{name}.feature"
33
- m.template "features/step_definitions/basics.rb.erb", "features/step_definitions/#{name}.rb"
34
-
35
28
  # rspec stubs
36
29
  m.template "spec/spec_helper.rb.erb", "spec/spec_helper.rb"
37
30
  m.template "spec/templates_spec.rb.erb", "spec/#{name}_spec.rb"
38
- m.template "spec/fixtures.rb.erb", "spec/fixtures.rb"
39
31
 
40
- %w(LICENSE Rakefile README.md Gemfile).each do |file|
32
+ %w(LICENSE Rakefile README.md Gemfile).each do |file|
41
33
  m.template file, file
42
34
  end
43
- %w(TODO).each do |file|
35
+ %w(TODO).each do |file|
44
36
  m.file file, file
45
37
  end
46
38
  end
@@ -0,0 +1,14 @@
1
+ source :gemcutter
2
+
3
+ gem 'sinatra', '~>1.0'
4
+ gem 'rack', '~>1.1.0'
5
+
6
+ group :test do
7
+ gem 'rake'
8
+ gem 'rspec', '~>2.0'
9
+ gem 'shotgun'
10
+ gem 'bundler', '~>1.0'
11
+ gem 'rack-test', '~>0.5.3', :require => 'rack/test'
12
+ end
13
+
14
+ # vim:ft=ruby
@@ -0,0 +1,19 @@
1
+ require 'rake/gempackagetask'
2
+ require 'rubygems/specification'
3
+ require 'date'
4
+ require 'bundler'
5
+
6
+ task :default => [:spec]
7
+
8
+ require 'spec/rake/spectask'
9
+ desc "Run specs"
10
+ Spec::Rake::SpecTask.new do |t|
11
+ t.spec_files = FileList['spec/**/*_spec.rb']
12
+ t.spec_opts = %w(-fs --color)
13
+ t.spec_opts << '--loadby' << 'random'
14
+
15
+ t.rcov_opts << '--exclude' << 'spec,.bundle'
16
+ t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
17
+ t.rcov_opts << '--text-summary'
18
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
19
+ end
@@ -1,4 +1,4 @@
1
1
  TODO:
2
2
  Fix LICENSE with your name
3
3
  Fix Rakefile with your name and contact info
4
- Add your code to lib/<%= name %>.rb
4
+ Add your code to lib/<%= name %>.rb
@@ -0,0 +1,11 @@
1
+ ENV['RACK_ENV'] ||= 'development'
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+
5
+ require File.expand_path(File.join(File.dirname(__FILE__), 'lib', '<%= name %>'))
6
+
7
+ use Rack::Static, :urls => ["/css", "/img", "/js"], :root => "public"
8
+
9
+ run <%= name.camelize %>.app
10
+
11
+ # vim:ft=ruby
@@ -0,0 +1,13 @@
1
+ require 'sinatra/base'
2
+
3
+ module <%= name.camelize %>
4
+ def self.app
5
+ @app ||= Rack::Builder.new do
6
+ use Rack::Session::Cookie, :key => 'rack.session', :path => '/',
7
+ :expire_after => 2592000, :secret => '<%= ::Digest::SHA1.hexdigest(Time.now.to_s) %>'
8
+ run <%= name.camelize %>::App
9
+ end
10
+ end
11
+ end
12
+
13
+ require File.dirname(__FILE__)+'/<%= name %>/app'
@@ -1,7 +1,7 @@
1
1
  module <%= name.camelize %>
2
2
  class App < Sinatra::Base
3
3
  get '/' do
4
- haml "%h2= 'Hello There, buddy!'"
4
+ erb "<h2>Hello There, buddy!</h2>"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,4 @@
1
+ module Singem
2
+ VERSION = "0.3.0"
3
+ end
4
+
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "singem/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "singem"
7
+ s.version = Singem::VERSION
8
+ s.authors = ["Corey Donohoe"]
9
+ s.email = ["atmos@atmos.org"]
10
+ s.homepage = "http://github.com/atmos/singem"
11
+ s.summary = %q{A gem that provides generators for sinatra apps, ready to go with rack-test and others}
12
+ s.description = s.summary
13
+
14
+ s.rubyforge_project = "singem"
15
+
16
+ s.add_dependency "rubigen", "~>1.5.2"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ end
metadata CHANGED
@@ -1,108 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Corey Donohoe
14
- autorequire: singem
14
+ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-31 00:00:00 -07:00
18
+ date: 2011-08-02 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rubigen
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: bundler
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
25
  none: false
40
26
  requirements:
41
27
  - - ~>
42
28
  - !ruby/object:Gem::Version
43
- hash: 61
29
+ hash: 7
44
30
  segments:
45
- - 0
46
- - 9
47
- - 3
48
- version: 0.9.3
31
+ - 1
32
+ - 5
33
+ - 2
34
+ version: 1.5.2
49
35
  type: :runtime
50
- version_requirements: *id002
51
- description: A gem that provides generators for sinatra apps, ready to go with rack-test/webrat/randexp and others
52
- email: atmos@atmos.org
36
+ version_requirements: *id001
37
+ description: A gem that provides generators for sinatra apps, ready to go with rack-test and others
38
+ email:
39
+ - atmos@atmos.org
53
40
  executables:
54
41
  - singem
55
42
  extensions: []
56
43
 
57
- extra_rdoc_files:
58
- - LICENSE
59
- - TODO
44
+ extra_rdoc_files: []
45
+
60
46
  files:
47
+ - .gitignore
61
48
  - LICENSE
62
49
  - README.md
63
50
  - Rakefile
64
51
  - TODO
65
- - lib/generators/cucumber/cucumber_generator.rb
66
- - lib/generators/cucumber/templates/config.ru.erb
67
- - lib/generators/cucumber/templates/features/basics.feature.erb
68
- - lib/generators/cucumber/templates/features/step_definitions/basics.rb.erb
69
- - lib/generators/cucumber/templates/features/support/env.rb.erb
70
- - lib/generators/cucumber/templates/Gemfile
71
- - lib/generators/cucumber/templates/lib/templates/app.rb.erb
72
- - lib/generators/cucumber/templates/lib/templates.rb.erb
73
- - lib/generators/cucumber/templates/LICENSE
74
- - lib/generators/cucumber/templates/Rakefile
75
- - lib/generators/cucumber/templates/README.md
76
- - lib/generators/cucumber/templates/spec/fixtures.rb.erb
77
- - lib/generators/cucumber/templates/spec/spec_helper.rb.erb
78
- - lib/generators/cucumber/templates/spec/templates_spec.rb.erb
79
- - lib/generators/cucumber/templates/TODO
80
- - lib/generators/cucumber/USAGE
81
- - lib/generators/twitter/templates/config.ru.erb
82
- - lib/generators/twitter/templates/features/basics.feature.erb
83
- - lib/generators/twitter/templates/features/step_definitions/basics.rb.erb
84
- - lib/generators/twitter/templates/features/support/env.rb.erb
85
- - lib/generators/twitter/templates/Gemfile
86
- - lib/generators/twitter/templates/lib/templates/app.rb.erb
87
- - lib/generators/twitter/templates/lib/templates/models/user.rb.erb
88
- - lib/generators/twitter/templates/lib/templates/views/about.haml
89
- - lib/generators/twitter/templates/lib/templates/views/failed.haml
90
- - lib/generators/twitter/templates/lib/templates/views/home.haml
91
- - lib/generators/twitter/templates/lib/templates.rb.erb
92
- - lib/generators/twitter/templates/LICENSE
93
- - lib/generators/twitter/templates/Rakefile
94
- - lib/generators/twitter/templates/README.md
95
- - lib/generators/twitter/templates/spec/fixtures.rb.erb
96
- - lib/generators/twitter/templates/spec/helpers.rb.erb
97
- - lib/generators/twitter/templates/spec/spec_helper.rb.erb
98
- - lib/generators/twitter/templates/spec/templates_spec.rb.erb
99
- - lib/generators/twitter/templates/TODO
100
- - lib/generators/twitter/twitter_generator.rb
101
- - lib/generators/twitter/USAGE
52
+ - bin/singem
53
+ - lib/generators/default/USAGE
54
+ - lib/generators/default/default_generator.rb
55
+ - lib/generators/default/templates/Gemfile
56
+ - lib/generators/default/templates/LICENSE
57
+ - lib/generators/default/templates/README.md
58
+ - lib/generators/default/templates/Rakefile
59
+ - lib/generators/default/templates/TODO
60
+ - lib/generators/default/templates/config.ru.erb
61
+ - lib/generators/default/templates/lib/templates.rb.erb
62
+ - lib/generators/default/templates/lib/templates/app.rb.erb
63
+ - lib/generators/default/templates/spec/spec_helper.rb.erb
64
+ - lib/generators/default/templates/spec/templates_spec.rb.erb
65
+ - lib/singem/version.rb
102
66
  - lib/singen.rb
67
+ - singem.gemspec
103
68
  - spec/singem_spec.rb
104
69
  - spec/spec_helper.rb
105
- - bin/singem
106
70
  has_rdoc: true
107
71
  homepage: http://github.com/atmos/singem
108
72
  licenses: []
@@ -132,10 +96,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
96
  version: "0"
133
97
  requirements: []
134
98
 
135
- rubyforge_project:
136
- rubygems_version: 1.3.7
99
+ rubyforge_project: singem
100
+ rubygems_version: 1.6.2
137
101
  signing_key:
138
102
  specification_version: 3
139
- summary: A gem that provides generators for sinatra apps, ready to go with rack-test/webrat/randexp and others
140
- test_files: []
141
-
103
+ summary: A gem that provides generators for sinatra apps, ready to go with rack-test and others
104
+ test_files:
105
+ - spec/singem_spec.rb
106
+ - spec/spec_helper.rb
@@ -1,5 +0,0 @@
1
- Description:
2
-
3
-
4
- Usage:
5
-
@@ -1,29 +0,0 @@
1
- source :gemcutter
2
-
3
- group :runtime do
4
- gem 'rack_hoptoad', '~>0.1.2', :require => 'rack/hoptoad'
5
- gem 'haml', '~>2.2.0'
6
- gem 'sinatra', '~>1.0'
7
- gem 'rack', '~>1.1.0'
8
- #gem 'do_sqlite3', '>=0.10.1.1'
9
- #gem 'dm-core', '>=0.10.2'
10
- #gem 'dm-validations', '>=0.10.2'
11
- #gem 'dm-timestamps', '>=0.10.2'
12
- end
13
-
14
- group :test do
15
- gem 'rake'
16
- gem 'rspec', '~>1.3.0', :require => 'spec'
17
- gem 'rcov'
18
- gem 'webrat', '~>0.7.0'
19
- gem 'shotgun'
20
- gem 'bundler', '~>1.0'
21
- gem 'cucumber'
22
- gem 'fakeweb', '>=1.2.8'
23
- gem 'randexp', '>=0.1.4'
24
- gem 'rack-test', '~>0.5.3', :require => 'rack/test'
25
- gem 'ParseTree', '>=3.0.4', :require => [ ]
26
- #gem 'dm-sweatshop', '~>0.10.2'
27
- end
28
-
29
- # vim:ft=ruby
@@ -1,71 +0,0 @@
1
- require 'rake/gempackagetask'
2
- require 'rubygems/specification'
3
- require 'date'
4
- require 'bundler'
5
-
6
- task :default => [:cucumber, :spec]
7
-
8
- require 'cucumber/rake/task'
9
- desc "Run cucumber"
10
- Cucumber::Rake::Task.new do |t|
11
- t.cucumber_opts = %w{--format pretty}
12
- end
13
-
14
- require 'spec/rake/spectask'
15
- desc "Run specs"
16
- Spec::Rake::SpecTask.new do |t|
17
- t.spec_files = FileList['spec/**/*_spec.rb']
18
- t.spec_opts = %w(-fs --color)
19
- t.spec_opts << '--loadby' << 'random'
20
-
21
- t.rcov_opts << '--exclude' << 'spec,.bundle'
22
- t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
23
- t.rcov_opts << '--text-summary'
24
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
25
- end
26
-
27
- GEM = "<%= name %>"
28
- GEM_VERSION = "0.0.1"
29
- AUTHOR = "Your Name"
30
- EMAIL = "Your Email"
31
- HOMEPAGE = "http://example.com"
32
- SUMMARY = "A sinatra app that provides..."
33
-
34
- spec = Gem::Specification.new do |s|
35
- s.name = GEM
36
- s.version = GEM_VERSION
37
- s.platform = Gem::Platform::RUBY
38
- s.has_rdoc = true
39
- s.extra_rdoc_files = ["LICENSE", 'TODO']
40
- s.summary = SUMMARY
41
- s.description = s.summary
42
- s.author = AUTHOR
43
- s.email = EMAIL
44
- s.homepage = HOMEPAGE
45
-
46
- bundle = Bundler::Definition.build('Gemfile', 'Gemfile.lock', { })
47
- bundle.dependencies.each do |dep|
48
- next unless dep.groups.include?(:runtime)
49
- s.add_dependency(dep.name, dep.version_requirements.to_s)
50
- end
51
-
52
- s.require_path = 'lib'
53
- s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,features}/**/*")
54
- end
55
-
56
- Rake::GemPackageTask.new(spec) do |pkg|
57
- pkg.gem_spec = spec
58
- end
59
-
60
- desc "install the gem locally"
61
- task :install => [:package] do
62
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
63
- end
64
-
65
- desc "create a gemspec file"
66
- task :make_spec do
67
- File.open("#{GEM}.gemspec", "w") do |file|
68
- file.puts spec.to_ruby
69
- end
70
- end
71
-
@@ -1,20 +0,0 @@
1
- ENV['RACK_ENV'] ||= 'development'
2
- begin
3
- require File.expand_path('../.bundle/environment', __FILE__)
4
- rescue LoadError
5
- require "rubygems"
6
- require "bundler"
7
- Bundler.setup
8
- end
9
-
10
- Bundler.require(:runtime)
11
-
12
- require File.expand_path(File.join(File.dirname(__FILE__), 'lib', '<%= name %>'))
13
-
14
- #DataMapper.setup(:default, "mysql://atmos:fail@localhost/<%= name.capitalize %>_production")
15
-
16
- use Rack::Static, :urls => ["/css", "/img", "/js"], :root => "public"
17
-
18
- run <%= name.camelize %>.app
19
-
20
- # vim:ft=ruby
@@ -1,7 +0,0 @@
1
- Feature: Visiting the Home Page
2
- In order to display a splash page
3
- As an anonymous user
4
-
5
- Scenario: Seeing the splash page
6
- When I visit the home page
7
- Then I should be greeted
@@ -1,8 +0,0 @@
1
- When /^I visit the home page$/ do
2
- get '/'
3
- end
4
-
5
- Then /^I should be greeted$/ do
6
- last_response.should have_selector("h2:contains('Hello There, buddy!')")
7
- end
8
-
@@ -1,21 +0,0 @@
1
- Bundler.require(:default, :runtime, :test)
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', '<%= name %>')
3
-
4
- Webrat.configure do |config|
5
- config.mode = :rack
6
- config.application_port = 4567
7
- end
8
-
9
- module <%= name.camelize %>::AppHelpers
10
- def app
11
- <%= name.camelize %>.app
12
- end
13
- end
14
-
15
- World(Rack::Test::Methods)
16
- World(Webrat::Matchers)
17
- World(<%= name.camelize %>::AppHelpers)
18
-
19
- Before do
20
- # insert before filtery things here
21
- end
@@ -1,16 +0,0 @@
1
- require 'sinatra/base'
2
- require 'haml/util'
3
- require 'haml/engine'
4
-
5
- module <%= name.camelize %>
6
- def self.app
7
- @app ||= Rack::Builder.new do
8
- # use Rack::Hoptoad 'mysecretkey'
9
- # use Rack::Session::Cookie, :key => 'rack.session', :path => '/',
10
- # :expire_after => 2592000, :secret => '<%= ::Digest::SHA1.hexdigest(Time.now.to_s) %>'
11
- run <%= name.camelize %>::App
12
- end
13
- end
14
- end
15
-
16
- require File.dirname(__FILE__)+'/<%= name %>/app'
@@ -1,32 +0,0 @@
1
- source :gemcutter
2
-
3
- group :runtime do
4
- gem 'rack_hoptoad', '~>0.1.2', :require => 'rack/hoptoad'
5
- gem 'haml', '~>2.2.0'
6
- gem 'sinatra', '~>1.0.0'
7
- gem 'rack', '~>1.1.0'
8
- gem 'curb', '>=0.3.7'
9
- gem 'json', '>=1.1.6'
10
- gem 'oauth', '=0.3.2'
11
- gem 'do_sqlite3', '>=0.10.1.1'
12
- gem 'dm-core', '~>0.10.2'
13
- gem 'dm-validations', '~>0.10.2'
14
- gem 'dm-timestamps', '~>0.10.2'
15
- end
16
-
17
- group :test do
18
- gem 'rake'
19
- gem 'rspec', '~>1.3.0', :require => 'spec'
20
- gem 'rcov'
21
- gem 'webrat', '~>0.7.0'
22
- gem 'shotgun'
23
- gem 'bundler', '~>1.0'
24
- gem 'cucumber'
25
- gem 'fakeweb', '>=1.2.8'
26
- gem 'randexp', '>=0.1.4'
27
- gem 'rack-test', '~>0.5.3', :require => 'rack/test'
28
- gem 'ParseTree', '>=3.0.4', :require => [ ]
29
- #gem 'dm-sweatshop', '~>0.10.2'
30
- end
31
-
32
- # vim:ft=ruby
@@ -1,20 +0,0 @@
1
- Copyright (c) <%= Time.now.year %> YOUR NAME
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,10 +0,0 @@
1
- <%= name %>
2
- <%= "=" * name.size %>
3
-
4
- A gem that provides...
5
-
6
- Developing
7
- ==========
8
- % gem install bundler
9
- % bundle install
10
- % bundle exec rake
@@ -1,71 +0,0 @@
1
- require 'rake/gempackagetask'
2
- require 'rubygems/specification'
3
- require 'date'
4
- require 'bundler'
5
-
6
- task :default => [:cucumber, :spec]
7
-
8
- require 'cucumber/rake/task'
9
- desc "Run cucumber"
10
- Cucumber::Rake::Task.new do |t|
11
- t.cucumber_opts = %w{--format pretty}
12
- end
13
-
14
- require 'spec/rake/spectask'
15
- desc "Run specs"
16
- Spec::Rake::SpecTask.new do |t|
17
- t.spec_files = FileList['spec/**/*_spec.rb']
18
- t.spec_opts = %w(-fs --color)
19
- t.spec_opts << '--loadby' << 'random'
20
-
21
- t.rcov_opts << '--exclude' << 'spec,.bundle'
22
- t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
23
- t.rcov_opts << '--text-summary'
24
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
25
- end
26
-
27
- GEM = "<%= name %>"
28
- GEM_VERSION = "0.0.1"
29
- AUTHOR = "Your Name"
30
- EMAIL = "Your Email"
31
- HOMEPAGE = "http://example.com"
32
- SUMMARY = "A sinatra app that provides..."
33
-
34
- spec = Gem::Specification.new do |s|
35
- s.name = GEM
36
- s.version = GEM_VERSION
37
- s.platform = Gem::Platform::RUBY
38
- s.has_rdoc = true
39
- s.extra_rdoc_files = ["LICENSE", 'TODO']
40
- s.summary = SUMMARY
41
- s.description = s.summary
42
- s.author = AUTHOR
43
- s.email = EMAIL
44
- s.homepage = HOMEPAGE
45
-
46
- bundle = Bundler::Definition.build('Gemfile', 'Gemfile.lock', { })
47
- bundle.dependencies.each do |dep|
48
- next unless dep.groups.include?(:runtime)
49
- s.add_dependency(dep.name, dep.version_requirements.to_s)
50
- end
51
-
52
- s.require_path = 'lib'
53
- s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,features}/**/*")
54
- end
55
-
56
- Rake::GemPackageTask.new(spec) do |pkg|
57
- pkg.gem_spec = spec
58
- end
59
-
60
- desc "install the gem locally"
61
- task :install => [:package] do
62
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
63
- end
64
-
65
- desc "create a gemspec file"
66
- task :make_spec do
67
- File.open("#{GEM}.gemspec", "w") do |file|
68
- file.puts spec.to_ruby
69
- end
70
- end
71
-
@@ -1,4 +0,0 @@
1
- TODO:
2
- Fix LICENSE with your name
3
- Fix Rakefile with your name and contact info
4
- Add your code to lib/<%= name %>.rb
@@ -1,23 +0,0 @@
1
- ENV['RACK_ENV'] ||= 'development'
2
- begin
3
- require File.expand_path('../.bundle/environment', __FILE__)
4
- rescue LoadError
5
- require "rubygems"
6
- require "bundler"
7
- Bundler.setup
8
- end
9
-
10
- Bundler.require(:runtime)
11
-
12
- require File.join(File.dirname(__FILE__), 'lib', '<%= name %>')
13
-
14
- ENV['<%= name.upcase %>_READKEY'] = /\w{18}/.gen # this should really be what twitter gives you
15
- ENV['<%= name.upcase %>_READSECRET'] = /\w{24}/.gen # this should really be what twitter gives you
16
-
17
- #DataMapper.setup(:default, "mysql://atmos:fail@localhost/<%= name.capitalize %>_production")
18
-
19
- use Rack::Static, :urls => ["/css", "/img", "/js"], :root => "public"
20
-
21
- run <%= name.camelize %>.app
22
-
23
- # vim:ft=ruby
@@ -1,11 +0,0 @@
1
- Feature: Visiting the Home Page
2
- In order to display a splash page
3
-
4
- Scenario: Seeing the splash page unauthenticated
5
- When I visit the home page
6
- Then I should be prompted to try the app
7
-
8
- Scenario: Seeing the splash page authenticated
9
- Given I am logged in
10
- When I visit the home page
11
- Then I should be greeted
@@ -1,15 +0,0 @@
1
- When /^I visit the home page$/ do
2
- get '/'
3
- end
4
-
5
- Then /^I should be greeted$/ do
6
- last_response.should have_selector("h2:contains('Hello There, you little twitterer!')")
7
- end
8
-
9
- Then /^I should be prompted to try the app$/ do
10
- last_response.should have_selector("p:contains('Would you mind trying out my new app')")
11
- end
12
-
13
- Given /^I am logged in$/ do
14
- login_quentin
15
- end
@@ -1,23 +0,0 @@
1
- Bundler.require(:default, :runtime, :test)
2
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', '<%= name %>')
3
-
4
- require 'spec/mocks'
5
- require 'pp'
6
-
7
- require File.dirname(__FILE__)+'/../../spec/helpers'
8
-
9
- Webrat.configure do |config|
10
- config.mode = :rack
11
- config.application_port = 4567
12
- end
13
-
14
- World(Rack::Test::Methods)
15
- World(Spec::Mocks::ExampleMethods)
16
- World(Webrat::Methods)
17
- World(Webrat::Matchers)
18
- World(<%= name.camelize %>::AppHelpers)
19
-
20
- Before do
21
- DataMapper.setup(:default, "sqlite3://:memory:")
22
- DataMapper.auto_migrate!
23
- end
@@ -1,55 +0,0 @@
1
- require 'oauth'
2
- require 'json'
3
- require 'haml/util'
4
- require 'haml/engine'
5
- require 'curb'
6
- require 'logger'
7
-
8
- require 'dm-core'
9
- require 'dm-validations'
10
- require 'dm-timestamps'
11
- require 'sinatra/base'
12
-
13
- module <%= name.camelize %>
14
- module Log
15
- def self.logger
16
- if @logger.nil?
17
- @logger = Logger.new("<%= name %>.log")
18
- @logger.level = Logger::INFO
19
- end
20
- @logger
21
- end
22
- end
23
-
24
- module OAuth
25
- def self.consumer
26
- ::OAuth::Consumer.new(ENV['<%= name.upcase %>_READKEY'],
27
- ENV['<%= name.upcase %>_READSECRET'],
28
- {:site => 'http://twitter.com'})
29
- end
30
- end
31
-
32
- def self.retryable(options = {}, &block)
33
- opts = { :tries => 1, :on => StandardError }.merge(options)
34
- retry_exception, retries = opts[:on], opts[:tries]
35
-
36
- begin
37
- return yield
38
- rescue retry_exception
39
- retry if (retries -= 1) > 0
40
- end
41
- yield
42
- end
43
-
44
- def self.app
45
- @app ||= Rack::Builder.new do
46
- # use Rack::Hoptoad 'mysecretkey'
47
- use Rack::Session::Cookie, :key => 'rack.session', :path => '/',
48
- :expire_after => 2592000, :secret => '<%= ::Digest::SHA1.hexdigest(Time.now.to_s) %>'
49
- run <%= name.camelize %>::App
50
- end
51
- end
52
- end
53
-
54
- require File.dirname(__FILE__)+'/<%= name %>/app'
55
- require File.dirname(__FILE__)+'/<%= name %>/models/user'
@@ -1,65 +0,0 @@
1
- module <%= name.camelize %>
2
- class App < Sinatra::Base
3
- set :views, File.expand_path(File.join(File.dirname(__FILE__), 'views'))
4
- enable :methodoverride
5
-
6
- helpers do
7
- def oauth_consumer
8
- ::<%= name.camelize %>::OAuth.consumer
9
- end
10
-
11
- def current_user
12
- session[:user_id].nil? ? nil : ::<%= name.camelize %>::User.get(session[:user_id])
13
- end
14
- end
15
-
16
- error do
17
- <%= name.camelize %>::Log.logger.info env['sinatra.error'].message
18
- <%= name.camelize %>::Log.logger.info env['sinatra.error'].backtrace.join("\n")
19
- haml :failed
20
- end
21
-
22
- get '/' do
23
- haml current_user.nil? ? :about : :home
24
- end
25
-
26
- get '/authenticate' do
27
- ::<%= name.camelize %>.retryable(:times => 2) do
28
- request_token = oauth_consumer.get_request_token
29
- session[:request_token] = request_token.token
30
- session[:request_token_secret] = request_token.secret
31
- redirect request_token.authorize_url
32
- end
33
- end
34
-
35
- get '/peace' do
36
- session.clear
37
- redirect '/'
38
- end
39
-
40
- get '/callback' do
41
- @request_token = ::OAuth::RequestToken.new(oauth_consumer,
42
- session[:request_token],
43
- session[:request_token_secret])
44
-
45
- access_token = @request_token.get_access_token
46
-
47
- oauth_response = oauth_consumer.request(:get, '/account/verify_credentials.json',
48
- access_token, { :scheme => :query_string })
49
- case oauth_response
50
- when Net::HTTPSuccess
51
- user_info = JSON.parse(oauth_response.body)
52
- user = ::<%= name.camelize %>::User.first_or_create(:twitter_id => user_info['id']) # really wish first_or_create behaved sanely
53
- user.name, user.avatar = user_info['name'], user_info['profile_image_url']
54
- user.token, user.secret = access_token.token, access_token.secret
55
- user.url = 'http://twitter.com/'+user_info['screen_name']
56
- user.save
57
-
58
- session[:user_id] = user.id
59
- redirect '/'
60
- else
61
- raise ArgumentError.new('Unhandled HTTP Response')
62
- end
63
- end
64
- end
65
- end
@@ -1,38 +0,0 @@
1
- module <%= name.camelize %>
2
- class User
3
- include DataMapper::Resource
4
- class UserCreationError < StandardError; end
5
- storage_names[:default] = '<%= name.camelize %>_users'
6
-
7
- property :id, Serial
8
- property :twitter_id, Integer, :required => true, :unique => true
9
- property :name, String
10
- property :token, String
11
- property :secret, String
12
-
13
- property :url, String, :length => 512
14
- property :avatar, String, :length => 512, :default => 'http://static.twitter.com/images/default_profile_normal.png'
15
-
16
- timestamps :at
17
-
18
- def access_token
19
- ::OAuth::AccessToken.new(::<%= name.camelize %>::OAuth.consumer, token, secret)
20
- end
21
-
22
- def self.create_twitter_user(twitter_id)
23
- content = Curl::Easy.perform("http://twitter.com/users/show/#{twitter_id}.json") do |curl|
24
- curl.timeout = 30
25
- end
26
- user_info = JSON.parse(content.body_str)
27
- raise UserCreationError.new("Unable to find '#{twitter_id}'") if(user_info['error'] == 'Not found')
28
- result = unless user_info['error']
29
- self.first_or_create({:twitter_id => user_info['id']},{
30
- :name => user_info['name'],
31
- :avatar => user_info['profile_image_url'],
32
- :url => 'http://twitter.com/'+user_info['screen_name']})
33
- end
34
- rescue JSON::ParserError
35
- raise UserCreationError.new("Unable to find '#{twitter_id}'")
36
- end
37
- end
38
- end
@@ -1,5 +0,0 @@
1
- %h2 Do you use twitter?
2
- %p
3
- Would you mind trying out my new app?
4
- %p
5
- Enter your custom stuff here.
@@ -1,4 +0,0 @@
1
- %p
2
- Something went wonky.
3
- a{:href => '/'} Try again
4
- ?
@@ -1 +0,0 @@
1
- %h2 Hello There, you little twitterer!
@@ -1,36 +0,0 @@
1
- class Net::HTTPResponse
2
- def body=(content)
3
- @body = content
4
- @read = true
5
- end
6
- end
7
-
8
- module <%= name.camelize %>::AppHelpers
9
- def app
10
- <%= name.camelize %>.app
11
- end
12
-
13
- def login_quentin
14
- response = Net::HTTPSuccess.new('1.0', 200, nil)
15
- response.body = "{\"description\":\"lulz\",\"profile_background_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/themes\\/theme3\\/bg.gif\",\"utc_offset\":-25200,\"friends_count\":157,\"profile_background_color\":\"EDECE9\",\"profile_text_color\":\"634047\",\"url\":\"http:\\/\\/example.org\",\"name\":\"Quentin Blake\",\"favourites_count\":6,\"profile_link_color\":\"088253\",\"protected\":false,\"status\":{\"truncated\":false,\"in_reply_to_status_id\":null,\"text\":\"stu stu studio\",\"in_reply_to_user_id\":null,\"favorited\":false,\"created_at\":\"Tue Mar 31 19:02:12 +0000 2009\",\"id\":1426242614,\"source\":\"<a href=\\\"http:\\/\\/iconfactory.com\\/software\\/twitterrific\\\">twitterrific<\\/a>\"},\"created_at\":\"Sun Mar 18 20:07:13 +0000 2007\",\"statuses_count\":2560,\"profile_background_tile\":false,\"time_zone\":\"Mountain Time (US & Canada)\",\"profile_sidebar_fill_color\":\"E3E2DE\",\"profile_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/default_profile_normal.png\",\"notifications\":false,\"profile_sidebar_border_color\":\"D3D2CF\",\"location\":\"Boulder, Colorado\",\"id\":1484261,\"following\":false,\"followers_count\":368,\"screen_name\":\"caboose\"}"
16
- login(response)
17
- end
18
-
19
- def unauthorized_quentin
20
- response = Net::HTTPUnauthorized.new('1.0', 401, nil)
21
- response.body = "Unauthorized"
22
- lambda { login(response) }.should raise_error(ArgumentError)
23
- end
24
-
25
- def login(response)
26
- token = 'oU5W1XD2TTZhWT6Snfii9JbVBUkJOurCKhWQHz98765'
27
-
28
- consumer = mock('Consumer', {:request => response})
29
- request_token = mock('RequestToken', {:get_access_token => mock('AccessToken', {:token => 'foo', :secret => 'bar'})})
30
-
31
- OAuth::Consumer.stub!(:new).and_return(consumer)
32
- OAuth::RequestToken.stub!(:new).and_return(request_token)
33
-
34
- visit "/callback?oauth_token=#{token}"
35
- end
36
- end
@@ -1,39 +0,0 @@
1
- Bundler.require(:default, :runtime, :test)
2
- require File.join(File.dirname(__FILE__), '..', 'lib', '<%= name %>')
3
- require 'pp'
4
-
5
- FakeWeb.allow_net_connect = false
6
- ENV['<%= name.upcase %>_READKEY'] = /\w{18}/.gen
7
- ENV['<%= name.upcase %>_READSECRET'] = /\w{18}/.gen
8
-
9
- require File.dirname(__FILE__)+'/fixtures'
10
- require File.dirname(__FILE__)+'/helpers'
11
-
12
- Webrat.configure do |config|
13
- config.mode = :rack
14
- config.application_port = 4567
15
- end
16
-
17
- DataMapper.setup(:default, 'sqlite3::memory:')
18
-
19
- Spec::Runner.configure do |config|
20
- config.include(Rack::Test::Methods)
21
- config.include(Webrat::Methods)
22
- config.include(Webrat::Matchers)
23
- config.include(<%= name.camelize %>::AppHelpers)
24
-
25
- config.before(:each) do
26
- ::<%= name.camelize %>::App.environment = :development
27
- DataMapper.auto_migrate!
28
- FakeWeb.clean_registry
29
- FakeWeb.register_uri(:post, "http://twitter.com:80/oauth/request_token",
30
- [{:body => "oauth_token=requestkey&oauth_token_secret=requestsecret", :status => ["200", "OK"]},
31
- {:body => "", :status => ["401", "Unauthorized"]},
32
- {:body => "", :status => ["403", "Forbidden"]},
33
- {:body => "Bad Gateway", :status => ["502", "Bad Gateway"]} ])
34
- end
35
-
36
- def app
37
- <%= name.camelize %>.app
38
- end
39
- end
@@ -1,59 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "visiting /" do
4
- describe "when unauthenticated" do
5
- it "should display the about page" do
6
- get '/'
7
- last_response.should have_selector("h2:contains('Do you use twitter?')")
8
- end
9
- end
10
- describe "when unauthorized" do
11
- it "should raise an error" do
12
- lambda { unauthorized_quentin }.should raise_error
13
- end
14
- end
15
- describe "when authenticated" do
16
- it "should display a greeting" do
17
- login_quentin
18
- get '/'
19
- last_response.should have_selector("h2:contains('Hello There, you little twitterer!')")
20
- end
21
- end
22
- end
23
-
24
- describe "visiting /peace" do
25
- describe "when authenticated" do
26
- it "should clear the session and redirect to the home page" do
27
- login_quentin
28
- get '/peace'
29
- last_response.headers['Location'].should eql('/')
30
-
31
- get last_response.headers['Location']
32
- last_response.should have_selector("h2:contains('Do you use twitter?')")
33
- end
34
- end
35
- end
36
-
37
- describe "triggering a 404" do
38
- it "should display the failed page" do
39
- pending
40
- get '/lost'
41
- last_response.should have_selector("p:contains('Something went wonky.')")
42
- end
43
- end
44
-
45
- describe "visiting /authenticate" do
46
- it "should redirect to twitter for authentication" do
47
- get '/authenticate'
48
- last_response.headers['Location'].should eql('http://twitter.com/oauth/authorize?oauth_token=requestkey')
49
- end
50
- end
51
-
52
- describe "<%= name.camelize %>::User" do
53
- it "can create users from twitter ids that exist" do
54
- lambda { <%= name.camelize %>::User.create_twitter_user('atmos') }.should_not raise_error
55
- end
56
- it "can't create users from twitter ids that do not exist" do
57
- lambda { <%= name.camelize %>::User.create_twitter_user(/\w{18}/.gen) }.should raise_error(<%= name.camelize %>::User::UserCreationError)
58
- end
59
- end
@@ -1,90 +0,0 @@
1
- class TwitterGenerator < RubiGen::Base
2
- DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
3
- Config::CONFIG['ruby_install_name'])
4
-
5
- default_options :author => nil
6
- attr_reader :name
7
-
8
- def initialize(runtime_args, runtime_options = {})
9
- super
10
- usage if args.empty?
11
- @destination_root = File.expand_path(args.shift)
12
- @name = base_name
13
- extract_options
14
- end
15
-
16
- def manifest
17
- record do |m|
18
- # Ensure appropriate folder(s) exists
19
- m.directory ''
20
- BASEDIRS.each { |path| m.directory path }
21
- m.directory "lib/#{name}"
22
- m.directory "features/support"
23
- m.directory "features/step_definitions"
24
- m.directory "lib/#{name}/sinatra"
25
- m.directory "lib/#{name}/models"
26
- m.directory "lib/#{name}/views"
27
-
28
- # Create stubs
29
- m.template "config.ru.erb", "config.ru.example"
30
- m.template "lib/templates.rb.erb", "lib/#{name}.rb"
31
- m.template "lib/templates/app.rb.erb", "lib/#{name}/app.rb"
32
- m.template "lib/templates/models/user.rb.erb", "lib/#{name}/models/user.rb"
33
-
34
- # cucumber stubs
35
- m.template "features/support/env.rb.erb", "features/support/env.rb"
36
- m.template "features/basics.feature.erb", "features/#{name}.feature"
37
- m.template "features/step_definitions/basics.rb.erb", "features/step_definitions/#{name}.rb"
38
-
39
- # rspec stubs
40
- m.template "spec/spec_helper.rb.erb", "spec/spec_helper.rb"
41
- m.template "spec/helpers.rb.erb", "spec/helpers.rb"
42
- m.template "spec/templates_spec.rb.erb", "spec/#{name}_spec.rb"
43
- m.template "spec/fixtures.rb.erb", "spec/fixtures.rb"
44
-
45
- %w(LICENSE Rakefile README.md Gemfile).each do |file|
46
- m.template file, file
47
- end
48
- %w(TODO).each do |file|
49
- m.file file, file
50
- end
51
- %w(about failed home).each do |file|
52
- m.file "lib/templates/views/#{file}.haml", "lib/#{name}/views/#{file}.haml"
53
- end
54
- end
55
- end
56
-
57
- protected
58
- def banner
59
- <<-EOS
60
- Creates a simple RubyGems scaffold.
61
-
62
- USAGE: #{spec.name} name --simple"
63
- EOS
64
- end
65
-
66
- def add_options!(opts)
67
- opts.separator ''
68
- opts.separator 'Options:'
69
- # For each option below, place the default
70
- # at the top of the file next to "default_options"
71
- # opts.on("-a", "--author=\"Your Name\"", String,
72
- # "Some comment about this option",
73
- # "Default: none") { |x| options[:author] = x }
74
- opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
75
- end
76
-
77
- def extract_options
78
- # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
79
- # Templates can access these value via the attr_reader-generated methods, but not the
80
- # raw instance variable value.
81
- # @author = options[:author]
82
- end
83
-
84
- # Installation skeleton. Intermediate directories are automatically
85
- # created so don't sweat their absence here.
86
- BASEDIRS = %w(
87
- lib
88
- spec
89
- )
90
- end