rails-sh 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.6
1
+ 1.2.7
@@ -10,6 +10,7 @@ Command.define 'help' do
10
10
  t, tasks PATTERN print rake tasks
11
11
  exit exit from rails-sh
12
12
  restart restart rails-sh
13
+ reload reload the environment
13
14
  !, system execute a system command
14
15
  eval eval as ruby script\e[0m
15
16
  HELP
@@ -37,6 +38,10 @@ Command.define 'restart' do
37
38
  exec File.expand_path('../../../../bin/rails-sh', __FILE__)
38
39
  end
39
40
 
41
+ Command.define 'reload' do
42
+ Rails::Sh.reload!
43
+ end
44
+
40
45
  Command.define 'exit' do
41
46
  exit
42
47
  end
@@ -0,0 +1,21 @@
1
+ module Rails
2
+ module Sh
3
+ module HookForFork
4
+ def before_fork(&block)
5
+ @before_fork = block
6
+ end
7
+
8
+ def after_fork(&block)
9
+ @after_fork = block
10
+ end
11
+
12
+ def run_before_fork(&block)
13
+ @before_fork.call if @before_fork
14
+ end
15
+
16
+ def run_after_fork(&block)
17
+ @after_fork.call if @after_fork
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/rails/sh/rake.rb CHANGED
@@ -4,6 +4,8 @@ require 'stringio'
4
4
  module Rails
5
5
  module Sh
6
6
  module Rake
7
+ extend HookForFork
8
+
7
9
  class << self
8
10
  def init
9
11
  $stdout = StringIO.new
@@ -33,22 +35,6 @@ module Rails
33
35
  def task_names
34
36
  ::Rake.application.tasks.map{|t| t.name}
35
37
  end
36
-
37
- def before_fork(&block)
38
- @before_fork = block
39
- end
40
-
41
- def after_fork(&block)
42
- @after_fork = block
43
- end
44
-
45
- def run_before_fork(&block)
46
- @before_fork.call if @before_fork
47
- end
48
-
49
- def run_after_fork(&block)
50
- @after_fork.call if @after_fork
51
- end
52
38
  end
53
39
  end
54
40
  end
data/lib/rails/sh.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  require 'readline'
2
+ require 'rails/sh/hook_for_fork'
2
3
  require 'rails/sh/rake'
3
4
  require 'rails/sh/command'
4
5
  require 'rails/sh/commands'
5
6
 
6
7
  module Rails
7
8
  module Sh
9
+ extend HookForFork
10
+
8
11
  RAILS_SUB_COMMANDS = ['generate', 'destroy', 'plugin', 'benchmarker', 'profiler',
9
12
  'console', 'server', 'dbconsole', 'application', 'runner']
10
13
 
@@ -47,22 +50,6 @@ module Rails
47
50
  end
48
51
  end
49
52
 
50
- def before_fork(&block)
51
- @before_fork = block
52
- end
53
-
54
- def after_fork(&block)
55
- @after_fork = block
56
- end
57
-
58
- def run_before_fork(&block)
59
- @before_fork.call if @before_fork
60
- end
61
-
62
- def run_after_fork(&block)
63
- @after_fork.call if @after_fork
64
- end
65
-
66
53
  def setup_readline
67
54
  Readline.basic_word_break_characters = ""
68
55
  Readline.completion_proc = lambda do |word|
@@ -89,6 +76,7 @@ module Rails
89
76
  run_before_fork
90
77
  pid = fork do
91
78
  run_after_fork
79
+ reload!
92
80
  ARGV.clear
93
81
  ARGV.concat line.split(/\s+/)
94
82
  puts "\e[42m$ rails #{ARGV.join(" ")}\e[0m"
@@ -96,6 +84,10 @@ module Rails
96
84
  end
97
85
  Process.waitpid(pid)
98
86
  end
87
+
88
+ def reload!
89
+ ActionDispatch::Callbacks.new(Proc.new {}, false).call({})
90
+ end
99
91
  end
100
92
  end
101
93
  end
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.2.6"
8
+ s.version = "1.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jugyo"]
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "lib/rails/sh.rb",
32
32
  "lib/rails/sh/command.rb",
33
33
  "lib/rails/sh/commands.rb",
34
+ "lib/rails/sh/hook_for_fork.rb",
34
35
  "lib/rails/sh/rake.rb",
35
36
  "rails-sh.gemspec",
36
37
  "spec/rails/sh/command_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.2.6
5
+ version: 1.2.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - jugyo
@@ -79,6 +79,7 @@ files:
79
79
  - lib/rails/sh.rb
80
80
  - lib/rails/sh/command.rb
81
81
  - lib/rails/sh/commands.rb
82
+ - lib/rails/sh/hook_for_fork.rb
82
83
  - lib/rails/sh/rake.rb
83
84
  - rails-sh.gemspec
84
85
  - spec/rails/sh/command_spec.rb