singem 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +63 -0
- data/TODO +1 -0
- data/bin/singem +26 -0
- data/lib/generators/cucumber/USAGE +5 -0
- data/lib/generators/cucumber/cucumber_generator.rb +82 -0
- data/lib/generators/cucumber/templates/LICENSE +20 -0
- data/lib/generators/cucumber/templates/README.md +4 -0
- data/lib/generators/cucumber/templates/Rakefile +73 -0
- data/lib/generators/cucumber/templates/TODO +4 -0
- data/lib/generators/cucumber/templates/config.ru.erb +11 -0
- data/lib/generators/cucumber/templates/features/basics.feature.erb +6 -0
- data/lib/generators/cucumber/templates/features/step_definitions/basics.rb.erb +8 -0
- data/lib/generators/cucumber/templates/features/support/env.rb.erb +32 -0
- data/lib/generators/cucumber/templates/lib/templates.rb.erb +9 -0
- data/lib/generators/cucumber/templates/lib/templates/app.rb.erb +7 -0
- data/lib/generators/cucumber/templates/spec/fixtures.rb.erb +0 -0
- data/lib/generators/cucumber/templates/spec/spec_helper.rb.erb +40 -0
- data/lib/generators/cucumber/templates/spec/templates_spec.rb.erb +8 -0
- data/lib/generators/singem/USAGE +5 -0
- data/lib/generators/singem/singem_generator.rb +77 -0
- data/lib/generators/singem/templates/LICENSE +20 -0
- data/lib/generators/singem/templates/README.md +4 -0
- data/lib/generators/singem/templates/Rakefile +66 -0
- data/lib/generators/singem/templates/TODO +4 -0
- data/lib/generators/singem/templates/config.ru.erb +11 -0
- data/lib/generators/singem/templates/lib/templates.rb.erb +9 -0
- data/lib/generators/singem/templates/lib/templates/app.rb.erb +7 -0
- data/lib/generators/singem/templates/spec/fixtures.rb.erb +0 -0
- data/lib/generators/singem/templates/spec/spec_helper.rb.erb +40 -0
- data/lib/generators/singem/templates/spec/templates_spec.rb.erb +8 -0
- data/lib/generators/twitter/USAGE +5 -0
- data/lib/generators/twitter/templates/LICENSE +20 -0
- data/lib/generators/twitter/templates/README.md +4 -0
- data/lib/generators/twitter/templates/Rakefile +66 -0
- data/lib/generators/twitter/templates/TODO +4 -0
- data/lib/generators/twitter/templates/config.ru.erb +14 -0
- data/lib/generators/twitter/templates/lib/templates.rb.erb +58 -0
- data/lib/generators/twitter/templates/lib/templates/models/user.rb.erb +38 -0
- data/lib/generators/twitter/templates/lib/templates/sinatra/app.rb.erb +66 -0
- data/lib/generators/twitter/templates/lib/templates/views/about.haml +5 -0
- data/lib/generators/twitter/templates/lib/templates/views/failed.haml +4 -0
- data/lib/generators/twitter/templates/lib/templates/views/home.haml +1 -0
- data/lib/generators/twitter/templates/spec/fixtures.rb.erb +0 -0
- data/lib/generators/twitter/templates/spec/spec_helper.rb.erb +75 -0
- data/lib/generators/twitter/templates/spec/templates_spec.rb.erb +59 -0
- data/lib/generators/twitter/twitter_generator.rb +81 -0
- data/lib/singen.rb +0 -0
- data/spec/singem_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- metadata +184 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Corey Donohoe
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
singem
|
2
|
+
======
|
3
|
+
|
4
|
+
*S*inatra *G*em Generator
|
5
|
+
|
6
|
+
Installation
|
7
|
+
============
|
8
|
+
|
9
|
+
% sudo gem install singem
|
10
|
+
|
11
|
+
Or build it yourself
|
12
|
+
|
13
|
+
% rake repackage
|
14
|
+
% rake install
|
15
|
+
|
16
|
+
Usage
|
17
|
+
=====
|
18
|
+
|
19
|
+
Basic Sinatra App, no sessions, cucumber testing
|
20
|
+
------------------------------------------------
|
21
|
+
% singem foo
|
22
|
+
% cd foo
|
23
|
+
% rake
|
24
|
+
|
25
|
+
Basic Sinatra App, no sessions, rspec rack-test
|
26
|
+
-----------------------------------------------
|
27
|
+
% singem --old-school foo
|
28
|
+
% cd foo
|
29
|
+
% rake
|
30
|
+
|
31
|
+
Basic Twitter OAuth App,
|
32
|
+
------------------------------
|
33
|
+
% singem --twitter foo
|
34
|
+
% cd foo
|
35
|
+
% rake
|
36
|
+
% open http://twitter.com/oauth_clients
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
GEM = "singem"
|
8
|
+
GEM_VERSION = "0.0.2"
|
9
|
+
AUTHOR = "Corey Donohoe"
|
10
|
+
EMAIL = "atmos@atmos.org"
|
11
|
+
HOMEPAGE = "http://github.com/atmos/singem"
|
12
|
+
SUMMARY = "A gem that provides generators for sinatra apps, ready to go with rack-test/webrat/randexp and others"
|
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.3.0"
|
29
|
+
s.add_dependency "webrat", "~>0.4.4"
|
30
|
+
s.add_dependency "fakeweb", "~>1.2.0"
|
31
|
+
s.add_dependency 'haml', "~>2.0.9"
|
32
|
+
|
33
|
+
s.bindir = "bin"
|
34
|
+
s.executables = %w( singem )
|
35
|
+
s.require_path = 'lib'
|
36
|
+
s.autorequire = GEM
|
37
|
+
s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
desc "Run specs"
|
43
|
+
Spec::Rake::SpecTask.new do |t|
|
44
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
45
|
+
t.spec_opts = %w(-fs --color)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
50
|
+
pkg.gem_spec = spec
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "install the gem locally"
|
54
|
+
task :install => [:package] do
|
55
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "create a gemspec file"
|
59
|
+
task :make_spec do
|
60
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
61
|
+
file.puts spec.to_ruby
|
62
|
+
end
|
63
|
+
end
|
data/bin/singem
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
require File.dirname(__FILE__) + "/../lib/newgem"
|
8
|
+
puts "#{File.basename($0)} #{Newgem::VERSION}"
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
|
14
|
+
require "pp"
|
15
|
+
RubiGen::Base.use_application_sources! :rubygems
|
16
|
+
RubiGen::Base.prepend_sources(*[
|
17
|
+
RubiGen::PathSource.new(:app, File.join(File.dirname(__FILE__), "..", "lib/generators"))
|
18
|
+
])
|
19
|
+
|
20
|
+
if ARGV.delete "--twitter"
|
21
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'twitter', :backtrace => true)
|
22
|
+
elsif ARGV.delete "--old-school"
|
23
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'singem', :backtrace => true)
|
24
|
+
else
|
25
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'cucumber', :backtrace => true)
|
26
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class CucumberGenerator < 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
|
+
|
25
|
+
# Create stubs
|
26
|
+
m.template "config.ru.erb", "config.ru.example"
|
27
|
+
m.template "lib/templates.rb.erb", "lib/#{name}.rb"
|
28
|
+
m.template "lib/templates/app.rb.erb", "lib/#{name}/app.rb"
|
29
|
+
|
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
|
+
# rspec stubs
|
36
|
+
m.template "spec/spec_helper.rb.erb", "spec/spec_helper.rb"
|
37
|
+
m.template "spec/templates_spec.rb.erb", "spec/#{name}_spec.rb"
|
38
|
+
m.template "spec/fixtures.rb.erb", "spec/fixtures.rb"
|
39
|
+
|
40
|
+
%w(LICENSE Rakefile README.md).each do |file|
|
41
|
+
m.template file, file
|
42
|
+
end
|
43
|
+
%w(TODO).each do |file|
|
44
|
+
m.file file, file
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
def banner
|
51
|
+
<<-EOS
|
52
|
+
Creates a simple RubyGems scaffold.
|
53
|
+
|
54
|
+
USAGE: #{spec.name} name --simple"
|
55
|
+
EOS
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_options!(opts)
|
59
|
+
opts.separator ''
|
60
|
+
opts.separator 'Options:'
|
61
|
+
# For each option below, place the default
|
62
|
+
# at the top of the file next to "default_options"
|
63
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
64
|
+
# "Some comment about this option",
|
65
|
+
# "Default: none") { |x| options[:author] = x }
|
66
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
67
|
+
end
|
68
|
+
|
69
|
+
def extract_options
|
70
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
71
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
72
|
+
# raw instance variable value.
|
73
|
+
# @author = options[:author]
|
74
|
+
end
|
75
|
+
|
76
|
+
# Installation skeleton. Intermediate directories are automatically
|
77
|
+
# created so don't sweat their absence here.
|
78
|
+
BASEDIRS = %w(
|
79
|
+
lib
|
80
|
+
spec
|
81
|
+
)
|
82
|
+
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,73 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
GEM = "<%= name %>"
|
9
|
+
GEM_VERSION = "0.0.1"
|
10
|
+
AUTHOR = "Your Name"
|
11
|
+
EMAIL = "Your Email"
|
12
|
+
HOMEPAGE = "http://example.com"
|
13
|
+
SUMMARY = "A sinatra app that provides..."
|
14
|
+
|
15
|
+
spec = Gem::Specification.new do |s|
|
16
|
+
s.name = GEM
|
17
|
+
s.version = GEM_VERSION
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.extra_rdoc_files = ["LICENSE", 'TODO']
|
21
|
+
s.summary = SUMMARY
|
22
|
+
s.description = s.summary
|
23
|
+
s.author = AUTHOR
|
24
|
+
s.email = EMAIL
|
25
|
+
s.homepage = HOMEPAGE
|
26
|
+
|
27
|
+
s.add_dependency "sinatra", ">=0.9.2"
|
28
|
+
s.add_dependency "rubigen", ">= 1.5.2"
|
29
|
+
s.add_dependency "rack-test", "~>0.1.0"
|
30
|
+
s.add_dependency "webrat", "~>0.4.3"
|
31
|
+
s.add_dependency "fakeweb", "~>1.2.0"
|
32
|
+
s.add_dependency 'haml', "~>2.0.9"
|
33
|
+
|
34
|
+
s.require_path = 'lib'
|
35
|
+
s.autorequire = GEM
|
36
|
+
s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,features}/**/*")
|
37
|
+
end
|
38
|
+
|
39
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
40
|
+
pkg.gem_spec = spec
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "install the gem locally"
|
44
|
+
task :install => [:package] do
|
45
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "create a gemspec file"
|
49
|
+
task :make_spec do
|
50
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
51
|
+
file.puts spec.to_ruby
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
task :default => :features
|
56
|
+
|
57
|
+
desc "Run cucumber"
|
58
|
+
Cucumber::Rake::Task.new do |t|
|
59
|
+
t.cucumber_opts = %w{--format pretty}
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
desc "Run specs"
|
64
|
+
Spec::Rake::SpecTask.new do |t|
|
65
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
66
|
+
t.spec_opts = %w(-fs --color)
|
67
|
+
t.spec_opts << '--loadby' << 'random'
|
68
|
+
|
69
|
+
t.rcov_opts << '--exclude' << 'spec'
|
70
|
+
t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
|
71
|
+
t.rcov_opts << '--text-summary'
|
72
|
+
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
73
|
+
end
|
@@ -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,32 @@
|
|
1
|
+
require 'spec'
|
2
|
+
require 'webrat'
|
3
|
+
require 'rack/test'
|
4
|
+
require File.dirname(__FILE__)+'/../../lib/<%= name %>'
|
5
|
+
module <%= name.camelize %>::AppHelpers
|
6
|
+
begin
|
7
|
+
gem 'safariwatir', '~>0.3.3'
|
8
|
+
require 'safariwatir'
|
9
|
+
def browser
|
10
|
+
@browser ||= Watir::Safari.new
|
11
|
+
end
|
12
|
+
rescue LoadError => e
|
13
|
+
end
|
14
|
+
|
15
|
+
def app_host
|
16
|
+
'http://localhost:9393/migration'
|
17
|
+
end
|
18
|
+
|
19
|
+
def app
|
20
|
+
@app = Rack::Builder.new do
|
21
|
+
run <%= name.camelize %>::App
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
World(Rack::Test::Methods)
|
27
|
+
World(Webrat::Matchers)
|
28
|
+
World(<%= name.camelize %>::AppHelpers)
|
29
|
+
|
30
|
+
Before do
|
31
|
+
# insert before filtery things here
|
32
|
+
end
|
File without changes
|
@@ -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
|