sinatra_rake_tasks 0.2.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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.md +44 -0
- data/Rakefile +33 -0
- data/lib/openhood/rake/ci.rb +31 -0
- data/lib/openhood/rake/console.rb +62 -0
- data/lib/openhood/rake/cucumber.rb +19 -0
- data/lib/openhood/rake/rspec.rb +13 -0
- data/lib/openhood/rake/sequel.rb +63 -0
- data/lib/sinatra_rake_tasks.rb +5 -0
- data/sinatra_rake_tasks.gemspec +64 -0
- metadata +141 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Joseph Halter & Jonathan Tron
|
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,44 @@
|
|
1
|
+
sinatra_rake_tasks
|
2
|
+
==================
|
3
|
+
|
4
|
+
Basic Usage
|
5
|
+
-----------
|
6
|
+
|
7
|
+
Copy/Paste the following lines in your Rakefile :
|
8
|
+
|
9
|
+
require 'sinatra_rake_tasks'
|
10
|
+
OpenHood::Rake::SpecTask.new
|
11
|
+
OpenHood::Rake::CucumberTask.new
|
12
|
+
OpenHood::Rake::SequelTask.new
|
13
|
+
OpenHood::Rake::CITask.new
|
14
|
+
OpenHood::Rake::ConsoleTask.new
|
15
|
+
|
16
|
+
Add basic directories :
|
17
|
+
|
18
|
+
# For SequelTask and ConsoleTask :
|
19
|
+
mkdir config
|
20
|
+
mkdir migrations
|
21
|
+
|
22
|
+
# For SpecTask :
|
23
|
+
mkdir spec
|
24
|
+
|
25
|
+
# For CucumberTask :
|
26
|
+
mkdir features
|
27
|
+
|
28
|
+
And you get :
|
29
|
+
|
30
|
+
rake -T
|
31
|
+
|
32
|
+
rake ci:all # Run all features and specs
|
33
|
+
rake console # Pseudo console
|
34
|
+
rake db:migrate # Migrate the database through scripts in db/migrate.
|
35
|
+
rake db:migrate:redo # Rollbacks the database one migration and re migrate up.
|
36
|
+
rake db:rollback # Rolls the schema back to the previous version.
|
37
|
+
rake db:version # Retrieves the current schema version number
|
38
|
+
rake features # Run Cucumber features
|
39
|
+
rake spec # Run specs
|
40
|
+
|
41
|
+
Copyright
|
42
|
+
---------
|
43
|
+
|
44
|
+
Copyright (c) 2009 Joseph Halter & Jonathan Tron. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.version = "0.2.0"
|
8
|
+
gem.name = "sinatra_rake_tasks"
|
9
|
+
gem.summary = %Q{OpenHood Sinatra Rake Tasks}
|
10
|
+
gem.description = %Q{Default tasks we're using in our apps}
|
11
|
+
gem.email = "team@openhood.com"
|
12
|
+
gem.homepage = "http://github.com/openhood/sinatra_rake_tasks"
|
13
|
+
gem.authors = ["Jonathan Tron", "Joseph Halter"]
|
14
|
+
gem.add_dependency "rspec", '>= 2.0.0.a'
|
15
|
+
gem.add_dependency "cucumber", '>= 0.6.2'
|
16
|
+
gem.add_dependency "sequel", '>= 3.8.0'
|
17
|
+
gem.add_dependency "bond"
|
18
|
+
gem.add_development_dependency "yard"
|
19
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
|
+
end
|
21
|
+
Jeweler::GemcutterTasks.new
|
22
|
+
rescue LoadError
|
23
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'yard'
|
28
|
+
YARD::Rake::YardocTask.new
|
29
|
+
rescue LoadError
|
30
|
+
task :yardoc do
|
31
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
module OpenHood
|
5
|
+
module Rake
|
6
|
+
class CITask < ::Rake::TaskLib
|
7
|
+
include Gem if RUBY_VERSION.to_f >= 1.9
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
namespace :ci do
|
11
|
+
desc 'Run all features and specs'
|
12
|
+
task :all do
|
13
|
+
ENV['RACK_ENV'] = 'test'
|
14
|
+
error = 0
|
15
|
+
|
16
|
+
rake_bin = "#{File.join(Config::CONFIG['bindir'], 'rake')} "
|
17
|
+
|
18
|
+
["#{rake_bin} spec", "#{rake_bin} features"].each do |command|
|
19
|
+
if system command
|
20
|
+
error += $?.to_i
|
21
|
+
else
|
22
|
+
error += 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
at_exit {exit error} if(error != 0)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require "sequel"
|
4
|
+
require "sequel/extensions/migration"
|
5
|
+
|
6
|
+
module OpenHood
|
7
|
+
module Rake
|
8
|
+
class ConsoleTask < ::Rake::TaskLib
|
9
|
+
def base_path
|
10
|
+
File.expand_path('.')
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
File.join(base_path, "migrations")
|
15
|
+
end
|
16
|
+
|
17
|
+
def config
|
18
|
+
environment = ENV["RACK_ENV"] || "development"
|
19
|
+
@config ||= YAML.load_file(File.join(base_path, "config", "#{environment}.yml"))
|
20
|
+
end
|
21
|
+
|
22
|
+
def connection
|
23
|
+
Sequel.connect(config[:db][:uri])
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
desc "Pseudo console"
|
28
|
+
task :console do
|
29
|
+
connection
|
30
|
+
require "readline"
|
31
|
+
require "bond"
|
32
|
+
puts "Enable completion..."
|
33
|
+
require "bond/completion"
|
34
|
+
|
35
|
+
# read history
|
36
|
+
history_file = File.join(ENV["HOME"], ".myrb_history")
|
37
|
+
if File.exists?(history_file)
|
38
|
+
puts "Restore history..."
|
39
|
+
IO.readlines(history_file).each{|e| Readline::HISTORY << e.chomp}
|
40
|
+
end
|
41
|
+
|
42
|
+
# load models
|
43
|
+
puts "Load models..."
|
44
|
+
Dir.glob(File.join(base_path, "models", "*.rb")).each do |m|
|
45
|
+
require m
|
46
|
+
end
|
47
|
+
|
48
|
+
# eval input
|
49
|
+
puts ""
|
50
|
+
while (input = Readline.readline('>> ', true)) != "exit"
|
51
|
+
begin puts "=> #{eval(input).inspect}"; rescue Exception; puts "Error: #{$!}" end
|
52
|
+
end
|
53
|
+
puts ""
|
54
|
+
|
55
|
+
# write back to history
|
56
|
+
puts "Save history..."
|
57
|
+
File.open(history_file, "w") {|f| f.write Readline::HISTORY.to_a.join("\n") }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
module OpenHood
|
7
|
+
module Rake
|
8
|
+
class CucumberTask < ::Cucumber::Rake::Task
|
9
|
+
def initialize(name=:features)
|
10
|
+
super(name) do |t|
|
11
|
+
t.fork = true
|
12
|
+
opts = []
|
13
|
+
opts << ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty'), '-r', 'features']
|
14
|
+
t.cucumber_opts = opts.join(" ")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require "sequel"
|
4
|
+
require "sequel/extensions/migration"
|
5
|
+
|
6
|
+
module OpenHood
|
7
|
+
module Rake
|
8
|
+
class SequelTask < ::Rake::TaskLib
|
9
|
+
def base_path
|
10
|
+
File.expand_path('.')
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
File.join(base_path, "migrations")
|
15
|
+
end
|
16
|
+
|
17
|
+
def config
|
18
|
+
environment = ENV["RACK_ENV"] || "development"
|
19
|
+
@config ||= YAML.load_file(File.join(base_path, "config", "#{environment}.yml"))
|
20
|
+
end
|
21
|
+
|
22
|
+
def connection
|
23
|
+
Sequel.connect(config[:db][:uri])
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_options
|
27
|
+
{:table => :"#{config[:app_name]}_schema_info", :column => :version}
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
desc "Sequel migration"
|
32
|
+
namespace :db do
|
33
|
+
namespace :migrate do
|
34
|
+
desc "Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x"
|
35
|
+
task :redo => [ "db:rollback", "db:migrate" ]
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
|
39
|
+
task :migrate do
|
40
|
+
connection
|
41
|
+
options = default_options
|
42
|
+
options[:target] = ENV["VERSION"].to_i if ENV["VERSION"]
|
43
|
+
Sequel::Migrator.run(Sequel::Model.db, path, options)
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Rolls the schema back to the previous version. Specify the number of steps with STEP=n"
|
47
|
+
task :rollback do
|
48
|
+
connection
|
49
|
+
step = ENV["STEP"] ? ENV["STEP"].to_i : 1
|
50
|
+
target = Sequel::Migrator.get_current_migration_version(Sequel::Model.db) - step
|
51
|
+
Sequel::Migrator.run(Sequel::Model.db, path, default_options.merge({:target => target}))
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Retrieves the current schema version number"
|
55
|
+
task :version do
|
56
|
+
connection
|
57
|
+
puts "Current version: #{Sequel::Migrator.get_current_migration_version(Sequel::Model.db, default_options)}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sinatra_rake_tasks}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jonathan Tron", "Joseph Halter"]
|
12
|
+
s.date = %q{2010-03-02}
|
13
|
+
s.description = %q{Default tasks we're using in our apps}
|
14
|
+
s.email = %q{team@openhood.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"lib/openhood/rake/ci.rb",
|
26
|
+
"lib/openhood/rake/console.rb",
|
27
|
+
"lib/openhood/rake/cucumber.rb",
|
28
|
+
"lib/openhood/rake/rspec.rb",
|
29
|
+
"lib/openhood/rake/sequel.rb",
|
30
|
+
"lib/sinatra_rake_tasks.rb",
|
31
|
+
"sinatra_rake_tasks.gemspec"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/openhood/sinatra_rake_tasks}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.6}
|
37
|
+
s.summary = %q{OpenHood Sinatra Rake Tasks}
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<rspec>, [">= 2.0.0.a"])
|
45
|
+
s.add_runtime_dependency(%q<cucumber>, [">= 0.6.2"])
|
46
|
+
s.add_runtime_dependency(%q<sequel>, [">= 3.8.0"])
|
47
|
+
s.add_runtime_dependency(%q<bond>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.a"])
|
51
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
52
|
+
s.add_dependency(%q<sequel>, [">= 3.8.0"])
|
53
|
+
s.add_dependency(%q<bond>, [">= 0"])
|
54
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.a"])
|
58
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
59
|
+
s.add_dependency(%q<sequel>, [">= 3.8.0"])
|
60
|
+
s.add_dependency(%q<bond>, [">= 0"])
|
61
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra_rake_tasks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jonathan Tron
|
13
|
+
- Joseph Halter
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-03-02 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
- a
|
33
|
+
version: 2.0.0.a
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cucumber
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 6
|
46
|
+
- 2
|
47
|
+
version: 0.6.2
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: sequel
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 3
|
59
|
+
- 8
|
60
|
+
- 0
|
61
|
+
version: 3.8.0
|
62
|
+
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: bond
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: yard
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id005
|
88
|
+
description: Default tasks we're using in our apps
|
89
|
+
email: team@openhood.com
|
90
|
+
executables: []
|
91
|
+
|
92
|
+
extensions: []
|
93
|
+
|
94
|
+
extra_rdoc_files:
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
|
+
files:
|
98
|
+
- .document
|
99
|
+
- .gitignore
|
100
|
+
- LICENSE
|
101
|
+
- README.md
|
102
|
+
- Rakefile
|
103
|
+
- lib/openhood/rake/ci.rb
|
104
|
+
- lib/openhood/rake/console.rb
|
105
|
+
- lib/openhood/rake/cucumber.rb
|
106
|
+
- lib/openhood/rake/rspec.rb
|
107
|
+
- lib/openhood/rake/sequel.rb
|
108
|
+
- lib/sinatra_rake_tasks.rb
|
109
|
+
- sinatra_rake_tasks.gemspec
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: http://github.com/openhood/sinatra_rake_tasks
|
112
|
+
licenses: []
|
113
|
+
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options:
|
116
|
+
- --charset=UTF-8
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
requirements: []
|
134
|
+
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 1.3.6
|
137
|
+
signing_key:
|
138
|
+
specification_version: 3
|
139
|
+
summary: OpenHood Sinatra Rake Tasks
|
140
|
+
test_files: []
|
141
|
+
|