thor_tasks 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/README.rdoc +7 -0
- data/Rakefile +2 -0
- data/lib/tasks/spec.thor +55 -0
- data/lib/tasks/spork.thor +19 -0
- data/lib/thor_tasks/version.rb +3 -0
- data/lib/thor_tasks.rb +19 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/tasks/spec.thor_spec.rb +11 -0
- data/spec/tasks/spork.thor_spec.rb +7 -0
- data/thor_tasks.gemspec +21 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
data/Rakefile
ADDED
data/lib/tasks/spec.thor
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
class Spec < Thor
|
2
|
+
include Thor::Actions
|
3
|
+
|
4
|
+
desc "controller [NAME]", "runs rspec for controllers"
|
5
|
+
def controller(name="*")
|
6
|
+
run "rspec spec/controllers/#{name}_controller_spec.rb"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "helper [NAME]", "runs rspec for helpers"
|
10
|
+
def helper(name = "*")
|
11
|
+
run "rspec spec/helpers/#{name}_helper_spec.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "model [NAME]", "runs rspec for models"
|
15
|
+
def model(name = "*")
|
16
|
+
run "rspec spec/models/#{name}_spec.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "request [NAME]", "runs rspec for requests"
|
20
|
+
def request(name = "*")
|
21
|
+
run "rspec spec/requests/#{name}_spec.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "routing [NAME]", "runs rspec for routing"
|
25
|
+
def routing(name = "*")
|
26
|
+
run "rspec spec/routing/#{name}_spec.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "view [CONTROLLER] [ACTION]", "runs rspec for views"
|
30
|
+
def view(controller = "*", action = "*")
|
31
|
+
run "rspec spec/views/#{controller}/#{action}*_spec.rb"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "list [TYPE}]", "lists specs for TYPE, see thor spec:list --help for more info."
|
35
|
+
method_options :help => false
|
36
|
+
def list(name = "*")
|
37
|
+
available_types = [
|
38
|
+
'controllers', 'helpers', 'models', 'requests', 'routing', 'views'
|
39
|
+
]
|
40
|
+
if options[:help]
|
41
|
+
puts "Available types for thor spec:list are"
|
42
|
+
available_types.each do |t|
|
43
|
+
puts " #{t}"
|
44
|
+
end
|
45
|
+
puts "Running thor spec:list without specifying a type will list all specs from all types."
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
Dir["spec/#{name}/*_spec.rb"].each do |f|
|
50
|
+
f = f.split("_")[0]
|
51
|
+
f = name == "*" ? f.partition("/")[2] : f.gsub("spec/#{name}/", "")
|
52
|
+
puts " #{f}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Spork < Thor
|
2
|
+
include Thor::Actions
|
3
|
+
|
4
|
+
desc "start", "starts Spork in the background"
|
5
|
+
def start
|
6
|
+
run "(bundle exec spork &)"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "stop", "stops Spork"
|
10
|
+
def stop
|
11
|
+
Process.kill(:TERM, `ps -ef | grep spork | grep -v grep | awk '{ print $2 }'`.to_i)
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "restart", "restarts Spork"
|
15
|
+
def restart
|
16
|
+
invoke :stop
|
17
|
+
invoke :start
|
18
|
+
end
|
19
|
+
end
|
data/lib/thor_tasks.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
module ThorTasks
|
5
|
+
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
desc "Installs thor tasks into your Rails application."
|
8
|
+
|
9
|
+
def self.source_root
|
10
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'tasks'))
|
11
|
+
end
|
12
|
+
|
13
|
+
def copy_tasks
|
14
|
+
copy_file "spec.thor", "lib/tasks/spec.thor"
|
15
|
+
copy_file "spork.thor", "lib/tasks/spork.thor"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spec do
|
4
|
+
it { should respond_to :controller }
|
5
|
+
it { should respond_to :helper }
|
6
|
+
it { should respond_to :model }
|
7
|
+
it { should respond_to :request }
|
8
|
+
it { should respond_to :routing }
|
9
|
+
it { should respond_to :view }
|
10
|
+
it { should respond_to :list }
|
11
|
+
end
|
data/thor_tasks.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "thor_tasks/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "thor_tasks"
|
7
|
+
s.version = ThorTasks::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Travis Haynes"]
|
10
|
+
s.email = ["travis.j.haynes@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Some helpful thor tasks}
|
13
|
+
s.description = %q{A collection of helpful thor tasks to use in Ruby on Rails projects.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "thor_tasks"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thor_tasks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Travis Haynes
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-09 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: A collection of helpful thor tasks to use in Ruby on Rails projects.
|
22
|
+
email:
|
23
|
+
- travis.j.haynes@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- README.rdoc
|
34
|
+
- Rakefile
|
35
|
+
- lib/tasks/spec.thor
|
36
|
+
- lib/tasks/spork.thor
|
37
|
+
- lib/thor_tasks.rb
|
38
|
+
- lib/thor_tasks/version.rb
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
- spec/tasks/spec.thor_spec.rb
|
41
|
+
- spec/tasks/spork.thor_spec.rb
|
42
|
+
- thor_tasks.gemspec
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: ""
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: thor_tasks
|
71
|
+
rubygems_version: 1.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Some helpful thor tasks
|
75
|
+
test_files: []
|
76
|
+
|