singem 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +36 -0
  3. data/Rakefile +63 -0
  4. data/TODO +1 -0
  5. data/bin/singem +26 -0
  6. data/lib/generators/cucumber/USAGE +5 -0
  7. data/lib/generators/cucumber/cucumber_generator.rb +82 -0
  8. data/lib/generators/cucumber/templates/LICENSE +20 -0
  9. data/lib/generators/cucumber/templates/README.md +4 -0
  10. data/lib/generators/cucumber/templates/Rakefile +73 -0
  11. data/lib/generators/cucumber/templates/TODO +4 -0
  12. data/lib/generators/cucumber/templates/config.ru.erb +11 -0
  13. data/lib/generators/cucumber/templates/features/basics.feature.erb +6 -0
  14. data/lib/generators/cucumber/templates/features/step_definitions/basics.rb.erb +8 -0
  15. data/lib/generators/cucumber/templates/features/support/env.rb.erb +32 -0
  16. data/lib/generators/cucumber/templates/lib/templates.rb.erb +9 -0
  17. data/lib/generators/cucumber/templates/lib/templates/app.rb.erb +7 -0
  18. data/lib/generators/cucumber/templates/spec/fixtures.rb.erb +0 -0
  19. data/lib/generators/cucumber/templates/spec/spec_helper.rb.erb +40 -0
  20. data/lib/generators/cucumber/templates/spec/templates_spec.rb.erb +8 -0
  21. data/lib/generators/singem/USAGE +5 -0
  22. data/lib/generators/singem/singem_generator.rb +77 -0
  23. data/lib/generators/singem/templates/LICENSE +20 -0
  24. data/lib/generators/singem/templates/README.md +4 -0
  25. data/lib/generators/singem/templates/Rakefile +66 -0
  26. data/lib/generators/singem/templates/TODO +4 -0
  27. data/lib/generators/singem/templates/config.ru.erb +11 -0
  28. data/lib/generators/singem/templates/lib/templates.rb.erb +9 -0
  29. data/lib/generators/singem/templates/lib/templates/app.rb.erb +7 -0
  30. data/lib/generators/singem/templates/spec/fixtures.rb.erb +0 -0
  31. data/lib/generators/singem/templates/spec/spec_helper.rb.erb +40 -0
  32. data/lib/generators/singem/templates/spec/templates_spec.rb.erb +8 -0
  33. data/lib/generators/twitter/USAGE +5 -0
  34. data/lib/generators/twitter/templates/LICENSE +20 -0
  35. data/lib/generators/twitter/templates/README.md +4 -0
  36. data/lib/generators/twitter/templates/Rakefile +66 -0
  37. data/lib/generators/twitter/templates/TODO +4 -0
  38. data/lib/generators/twitter/templates/config.ru.erb +14 -0
  39. data/lib/generators/twitter/templates/lib/templates.rb.erb +58 -0
  40. data/lib/generators/twitter/templates/lib/templates/models/user.rb.erb +38 -0
  41. data/lib/generators/twitter/templates/lib/templates/sinatra/app.rb.erb +66 -0
  42. data/lib/generators/twitter/templates/lib/templates/views/about.haml +5 -0
  43. data/lib/generators/twitter/templates/lib/templates/views/failed.haml +4 -0
  44. data/lib/generators/twitter/templates/lib/templates/views/home.haml +1 -0
  45. data/lib/generators/twitter/templates/spec/fixtures.rb.erb +0 -0
  46. data/lib/generators/twitter/templates/spec/spec_helper.rb.erb +75 -0
  47. data/lib/generators/twitter/templates/spec/templates_spec.rb.erb +59 -0
  48. data/lib/generators/twitter/twitter_generator.rb +81 -0
  49. data/lib/singen.rb +0 -0
  50. data/spec/singem_spec.rb +7 -0
  51. data/spec/spec_helper.rb +2 -0
  52. metadata +184 -0
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "<%= name.camelize %>" do
4
+ it "should do nothing" do
5
+ get '/'
6
+ last_response.should have_selector("h2:contains('Hello There, buddy!')")
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,77 @@
1
+ class SingemGenerator < 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
+
23
+ # Create stubs
24
+ m.template "config.ru.erb", "config.ru.example"
25
+ m.template "lib/templates.rb.erb", "lib/#{name}.rb"
26
+ m.template "lib/templates/app.rb.erb", "lib/#{name}/app.rb"
27
+
28
+ m.template "spec/spec_helper.rb.erb", "spec/spec_helper.rb"
29
+ m.template "spec/templates_spec.rb.erb", "spec/#{name}_spec.rb"
30
+ m.template "spec/fixtures.rb.erb", "spec/fixtures.rb"
31
+
32
+ %w(LICENSE Rakefile README.md).each do |file|
33
+ m.template file, file
34
+ end
35
+ %w(TODO).each do |file|
36
+ m.file file, file
37
+ end
38
+
39
+ # m.dependency "install_rubigen_scripts", [destination_root, 'newgem_simple'],
40
+ # :shebang => options[:shebang], :collision => :force
41
+ end
42
+ end
43
+
44
+ protected
45
+ def banner
46
+ <<-EOS
47
+ Creates a simple RubyGems scaffold.
48
+
49
+ USAGE: #{spec.name} name --simple"
50
+ EOS
51
+ end
52
+
53
+ def add_options!(opts)
54
+ opts.separator ''
55
+ opts.separator 'Options:'
56
+ # For each option below, place the default
57
+ # at the top of the file next to "default_options"
58
+ # opts.on("-a", "--author=\"Your Name\"", String,
59
+ # "Some comment about this option",
60
+ # "Default: none") { |x| options[:author] = x }
61
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
62
+ end
63
+
64
+ def extract_options
65
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
66
+ # Templates can access these value via the attr_reader-generated methods, but not the
67
+ # raw instance variable value.
68
+ # @author = options[:author]
69
+ end
70
+
71
+ # Installation skeleton. Intermediate directories are automatically
72
+ # created so don't sweat their absence here.
73
+ BASEDIRS = %w(
74
+ lib
75
+ spec
76
+ )
77
+ end
@@ -0,0 +1,20 @@
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.
@@ -0,0 +1,4 @@
1
+ <%= name %>
2
+ <%= "=" * name.size %>
3
+
4
+ A gem that provides...
@@ -0,0 +1,66 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rubygems/specification'
4
+ require 'date'
5
+ require 'spec/rake/spectask'
6
+
7
+ GEM = "<%= name %>"
8
+ GEM_VERSION = "0.0.1"
9
+ AUTHOR = "Your Name"
10
+ EMAIL = "Your Email"
11
+ HOMEPAGE = "http://example.com"
12
+ SUMMARY = "A sinatra app that provides..."
13
+
14
+ spec = Gem::Specification.new do |s|
15
+ s.name = GEM
16
+ s.version = GEM_VERSION
17
+ s.platform = Gem::Platform::RUBY
18
+ s.has_rdoc = true
19
+ s.extra_rdoc_files = ["LICENSE", 'TODO']
20
+ s.summary = SUMMARY
21
+ s.description = s.summary
22
+ s.author = AUTHOR
23
+ s.email = EMAIL
24
+ s.homepage = HOMEPAGE
25
+
26
+ s.add_dependency "sinatra", ">=0.9.2"
27
+ s.add_dependency "rubigen", ">= 1.5.2"
28
+ s.add_dependency "rack-test", "~>0.1.0"
29
+ s.add_dependency "webrat", "~>0.4.3"
30
+ s.add_dependency "fakeweb", "~>1.2.0"
31
+ s.add_dependency 'haml', "~>2.0.9"
32
+
33
+ s.require_path = 'lib'
34
+ s.autorequire = GEM
35
+ s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
36
+ end
37
+
38
+ Rake::GemPackageTask.new(spec) do |pkg|
39
+ pkg.gem_spec = spec
40
+ end
41
+
42
+ desc "install the gem locally"
43
+ task :install => [:package] do
44
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
45
+ end
46
+
47
+ desc "create a gemspec file"
48
+ task :make_spec do
49
+ File.open("#{GEM}.gemspec", "w") do |file|
50
+ file.puts spec.to_ruby
51
+ end
52
+ end
53
+
54
+ task :default => :spec
55
+
56
+ desc "Run specs"
57
+ Spec::Rake::SpecTask.new do |t|
58
+ t.spec_files = FileList['spec/**/*_spec.rb']
59
+ t.spec_opts = %w(-fs --color)
60
+ t.spec_opts << '--loadby' << 'random'
61
+
62
+ t.rcov_opts << '--exclude' << 'spec'
63
+ t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
64
+ t.rcov_opts << '--text-summary'
65
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
66
+ end
@@ -0,0 +1,4 @@
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
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require '<%= name %>'
3
+
4
+ #DataMapper.setup(:default, "mysql://atmos:fail@localhost/<%= name.capitalize %>_production")
5
+
6
+ class <%= name.camelize %>Site < <%= name.camelize %>::App
7
+ set :public, File.expand_path(File.dirname(__FILE__), "public")
8
+ set :environment, :production
9
+ end
10
+
11
+ run <%= name.camelize %>Site
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'sinatra/base'
3
+ require 'haml/util'
4
+ require 'haml/engine'
5
+
6
+ module <%= name.camelize %>
7
+ end
8
+
9
+ require File.dirname(__FILE__)+'/<%= name %>/app'
@@ -0,0 +1,7 @@
1
+ module <%= name.camelize %>
2
+ class App < Sinatra::Default
3
+ get '/' do
4
+ haml "%h2= 'Hello There, buddy!'"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,40 @@
1
+ $TESTING=true
2
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'rubygems'
4
+ require 'randexp'
5
+ require '<%= name %>'
6
+ #require 'dm-core'
7
+ require 'rack/test'
8
+ require 'webrat/sinatra'
9
+ #require 'dm-sweatshop'
10
+ require 'fakeweb'
11
+ require 'pp'
12
+
13
+ FakeWeb.allow_net_connect = false
14
+
15
+ #require File.dirname(__FILE__)+'/fixtures'
16
+ #DataMapper.setup(:default, 'sqlite3::memory:')
17
+
18
+ class Net::HTTPResponse
19
+ def body=(content)
20
+ @body = content
21
+ @read = true
22
+ end
23
+ end
24
+
25
+ Spec::Runner.configure do |config|
26
+ config.include(Rack::Test::Methods)
27
+ config.include(Webrat::Methods)
28
+ config.include(Webrat::Matchers)
29
+
30
+ config.before(:each) do
31
+ #DataMapper.auto_migrate!
32
+ FakeWeb.clean_registry
33
+ end
34
+
35
+ def app
36
+ @app = Rack::Builder.new do
37
+ run <%= name.camelize %>::App
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "<%= name.camelize %>" do
4
+ it "should do nothing" do
5
+ get '/'
6
+ last_response.should have_selector("h2:contains('Hello There, buddy!')")
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,20 @@
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.
@@ -0,0 +1,4 @@
1
+ <%= name %>
2
+ <%= "=" * name.size %>
3
+
4
+ A gem that provides...
@@ -0,0 +1,66 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rubygems/specification'
4
+ require 'date'
5
+ require 'spec/rake/spectask'
6
+
7
+ GEM = "<%= name %>"
8
+ GEM_VERSION = "0.0.1"
9
+ AUTHOR = "Your Name"
10
+ EMAIL = "Your Email"
11
+ HOMEPAGE = "http://example.com"
12
+ SUMMARY = "A sinatra app that provides..."
13
+
14
+ spec = Gem::Specification.new do |s|
15
+ s.name = GEM
16
+ s.version = GEM_VERSION
17
+ s.platform = Gem::Platform::RUBY
18
+ s.has_rdoc = true
19
+ s.extra_rdoc_files = ["LICENSE", 'TODO']
20
+ s.summary = SUMMARY
21
+ s.description = s.summary
22
+ s.author = AUTHOR
23
+ s.email = EMAIL
24
+ s.homepage = HOMEPAGE
25
+
26
+ s.add_dependency "sinatra", ">=0.9.2"
27
+ s.add_dependency "rubigen", ">= 1.5.2"
28
+ s.add_dependency "rack-test", "~>0.1.0"
29
+ s.add_dependency "webrat", "~>0.4.3"
30
+ s.add_dependency "fakeweb", "~>1.2.0"
31
+ s.add_dependency 'haml', "~>2.0.9"
32
+
33
+ s.require_path = 'lib'
34
+ s.autorequire = GEM
35
+ s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
36
+ end
37
+
38
+ Rake::GemPackageTask.new(spec) do |pkg|
39
+ pkg.gem_spec = spec
40
+ end
41
+
42
+ desc "install the gem locally"
43
+ task :install => [:package] do
44
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
45
+ end
46
+
47
+ desc "create a gemspec file"
48
+ task :make_spec do
49
+ File.open("#{GEM}.gemspec", "w") do |file|
50
+ file.puts spec.to_ruby
51
+ end
52
+ end
53
+
54
+ task :default => :spec
55
+
56
+ desc "Run specs"
57
+ Spec::Rake::SpecTask.new do |t|
58
+ t.spec_files = FileList['spec/**/*_spec.rb']
59
+ t.spec_opts = %w(-fs --color)
60
+ t.spec_opts << '--loadby' << 'random'
61
+
62
+ t.rcov_opts << '--exclude' << 'spec'
63
+ t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
64
+ t.rcov_opts << '--text-summary'
65
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
66
+ end
@@ -0,0 +1,4 @@
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
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require '<%= name %>'
3
+
4
+ ENV['<%= name.upcase %>_READKEY'] = /\w{18}/.gen # this should really be what twitter gives you
5
+ ENV['<%= name.upcase %>_READSECRET'] = /\w{24}/.gen # this should really be what twitter gives you
6
+
7
+ #DataMapper.setup(:default, "mysql://atmos:fail@localhost/<%= name.capitalize %>_production")
8
+
9
+ class <%= name.camelize %>Site < <%= name.camelize %>::App
10
+ set :public, File.expand_path(File.dirname(__FILE__), "public")
11
+ set :environment, :production
12
+ end
13
+
14
+ run <%= name.camelize %>Site
@@ -0,0 +1,58 @@
1
+ gem 'oauth'
2
+ require 'oauth'
3
+ gem 'json'
4
+ require 'json'
5
+ gem 'haml', '~>2.0.9'
6
+ require 'haml/util'
7
+ require 'haml/engine'
8
+ gem 'chronic'
9
+ require 'chronic'
10
+ gem 'curb'
11
+ require 'curb'
12
+ require 'logger'
13
+
14
+ gem 'data_objects', '~>0.9.11'
15
+ gem 'dm-core', '~>0.9.10'
16
+ gem 'dm-types', '~>0.9.10'
17
+ gem 'dm-validations', '~>0.9.10'
18
+ gem 'dm-timestamps', '~>0.9.10'
19
+ require 'dm-core'
20
+ require 'dm-types'
21
+ require 'dm-validations'
22
+ require 'dm-timestamps'
23
+ require 'sinatra/base'
24
+
25
+ module <%= name.camelize %>
26
+ module Log
27
+ def self.logger
28
+ if @logger.nil?
29
+ @logger = Logger.new("<%= name %>.log")
30
+ @logger.level = Logger::INFO
31
+ end
32
+ @logger
33
+ end
34
+ end
35
+
36
+ module OAuth
37
+ def self.consumer
38
+ ::OAuth::Consumer.new(ENV['<%= name.upcase %>_READKEY'],
39
+ ENV['<%= name.upcase %>_READSECRET'],
40
+ {:site => 'http://twitter.com'})
41
+ end
42
+ end
43
+
44
+ def self.retryable(options = {}, &block)
45
+ opts = { :tries => 1, :on => StandardError }.merge(options)
46
+ retry_exception, retries = opts[:on], opts[:tries]
47
+
48
+ begin
49
+ return yield
50
+ rescue retry_exception
51
+ retry if (retries -= 1) > 0
52
+ end
53
+ yield
54
+ end
55
+ end
56
+
57
+ require File.dirname(__FILE__)+'/<%= name %>/models/user'
58
+ require File.dirname(__FILE__)+'/<%= name %>/sinatra/app'