rails-sh 1.1.8 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rails/sh/command.rb +1 -1
- data/lib/rails/sh/commands.rb +2 -26
- data/lib/rails/sh/rake.rb +28 -0
- data/lib/rails/sh.rb +7 -1
- data/rails-sh.gemspec +2 -1
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/lib/rails/sh/command.rb
CHANGED
data/lib/rails/sh/commands.rb
CHANGED
@@ -14,32 +14,8 @@ Command.define 'help' do
|
|
14
14
|
HELP
|
15
15
|
end
|
16
16
|
|
17
|
-
Command.define '
|
18
|
-
Rails.
|
19
|
-
all_routes = Rails.application.routes.routes
|
20
|
-
|
21
|
-
if controller.present?
|
22
|
-
all_routes = all_routes.select{ |route| route.defaults[:controller] == controller }
|
23
|
-
end
|
24
|
-
|
25
|
-
routes = all_routes.collect do |route|
|
26
|
-
|
27
|
-
reqs = route.requirements.dup
|
28
|
-
reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
|
29
|
-
reqs = reqs.empty? ? "" : reqs.inspect
|
30
|
-
|
31
|
-
{:name => route.name.to_s, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
|
32
|
-
end
|
33
|
-
|
34
|
-
routes.reject! { |r| r[:path] =~ %r{/rails/info/properties} } # Skip the route if it's internal info route
|
35
|
-
|
36
|
-
name_width = routes.map{ |r| r[:name].length }.max
|
37
|
-
verb_width = routes.map{ |r| r[:verb].length }.max
|
38
|
-
path_width = routes.map{ |r| r[:path].length }.max
|
39
|
-
|
40
|
-
routes.each do |r|
|
41
|
-
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
|
42
|
-
end
|
17
|
+
Command.define 'rake' do |arg|
|
18
|
+
Rails::Sh::Rake.invoke(arg)
|
43
19
|
end
|
44
20
|
|
45
21
|
Command.define 'system' do |arg|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Rails
|
5
|
+
module Sh
|
6
|
+
module Rake
|
7
|
+
class << self
|
8
|
+
def init
|
9
|
+
$stdout = StringIO.new
|
10
|
+
::Rake.application = ::Rake::Application.new
|
11
|
+
::Rake.application.init
|
12
|
+
::Rake.application.load_rakefile
|
13
|
+
::Rake.application[:environment].invoke
|
14
|
+
ensure
|
15
|
+
$stdout = STDOUT
|
16
|
+
end
|
17
|
+
|
18
|
+
def invoke(name)
|
19
|
+
Process.waitpid(fork { ::Rake.application[name].invoke })
|
20
|
+
end
|
21
|
+
|
22
|
+
def task_names
|
23
|
+
::Rake.application.tasks.map{|t| t.name}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/rails/sh.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'readline'
|
2
2
|
require 'rails/sh/patch_for_kernel'
|
3
|
+
require 'rails/sh/rake'
|
3
4
|
require 'rails/sh/command'
|
4
5
|
require 'rails/sh/commands'
|
5
6
|
|
@@ -10,6 +11,7 @@ module Rails
|
|
10
11
|
|
11
12
|
class << self
|
12
13
|
def start
|
14
|
+
Rails::Sh::Rake.init
|
13
15
|
puts "Rails.env: #{Rails.env}"
|
14
16
|
puts "type `help` to print help"
|
15
17
|
setup_readline
|
@@ -30,7 +32,11 @@ module Rails
|
|
30
32
|
def setup_readline
|
31
33
|
Readline.basic_word_break_characters = ""
|
32
34
|
Readline.completion_proc = lambda do |word|
|
33
|
-
(
|
35
|
+
(
|
36
|
+
Command.command_names.map { |name| name.to_s } +
|
37
|
+
RAILS_SUB_COMMANDS +
|
38
|
+
Rails::Sh::Rake.task_names.map { |name| "rake #{name}" }
|
39
|
+
).grep(/#{Regexp.quote(word)}/)
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
data/rails-sh.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails-sh}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jugyo"]
|
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/rails/sh/command.rb",
|
33
33
|
"lib/rails/sh/commands.rb",
|
34
34
|
"lib/rails/sh/patch_for_kernel.rb",
|
35
|
+
"lib/rails/sh/rake.rb",
|
35
36
|
"rails-sh.gemspec",
|
36
37
|
"spec/rails/sh/command_spec.rb",
|
37
38
|
"spec/rails/sh_spec.rb",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rails-sh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- jugyo
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/rails/sh/command.rb
|
81
81
|
- lib/rails/sh/commands.rb
|
82
82
|
- lib/rails/sh/patch_for_kernel.rb
|
83
|
+
- lib/rails/sh/rake.rb
|
83
84
|
- rails-sh.gemspec
|
84
85
|
- spec/rails/sh/command_spec.rb
|
85
86
|
- spec/rails/sh_spec.rb
|
@@ -98,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
99
|
requirements:
|
99
100
|
- - ">="
|
100
101
|
- !ruby/object:Gem::Version
|
101
|
-
hash:
|
102
|
+
hash: 4602907216406005952
|
102
103
|
segments:
|
103
104
|
- 0
|
104
105
|
version: "0"
|