smalruby-editor 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of smalruby-editor might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bba65985f93de25c7ede4ae1209629ceacfc555
4
- data.tar.gz: 2a00938abb121e6fadedd63a90651ed1447ad109
3
+ metadata.gz: f31eaf9af5535997978a26b3695281bea1b42f0b
4
+ data.tar.gz: b16de89a95361cfccf5442beff5574bcf5739cd1
5
5
  SHA512:
6
- metadata.gz: 4907348138e9023b4797aa13d0f4d9da12e65fb50a7365ad605b4747ab0fad5ce3fce2793e40fdc1564f77cfbf9ba620c0c534cedf990ba7892053622eeaf60e
7
- data.tar.gz: fb0d6aa2e423b19e1e99e9c0a2c48268cf37ddf5e2429451e751b4c8c0202cd4c3f7e0a93657f757e87ec5758a5894018c0e2bc92fbb5bdb005e0c4850641b8e
6
+ metadata.gz: 0a98b1fafc323e05da037379b47f980af46bf674c4d2b414c0dd87df077e70aa02e936bfef4aca8446a90856813cb8220e7eb44ad10ec353118d038e54f326a2
7
+ data.tar.gz: 7e4027a9eed4347b503e2a7911c61b7d2393a13393ff1cafef19ce9831f18a455b4a7158d95002a362c9f44b7df6479dbc438b94e65999f19045566151175ada
@@ -2,6 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  require 'pathname'
5
+ require 'socket'
5
6
 
6
7
  ENV['RAILS_ENV'] = 'standalone'
7
8
  ENV['SMALRUBY_EDITOR_HOME'] ||= Pathname('~/.smalruby-editor').expand_path.to_s
@@ -20,9 +21,35 @@ require 'rails/commands/server'
20
21
  module Rails
21
22
  class Server < ::Rack::Server
22
23
  def start
24
+ if (pid_path = Pathname(options[:pid])).exist?
25
+ pid = pid_path.read.to_i
26
+ if SmalrubyEditor.windows?
27
+ require 'csv'
28
+ s = `tasklist /FI "IMAGENAME eq ruby.exe" /FO csv`
29
+ s.force_encoding('CP932')
30
+ csv = CSV.parse(s)
31
+ csv.shift # ヘッダを除去
32
+ pids = csv.map { |row| row[1].to_i }
33
+ if pids.include?(pid)
34
+ Process.kill('KILL', pid)
35
+ end
36
+ pid_path.unlink
37
+ else
38
+ Timeout.timeout(5) do
39
+ begin
40
+ while Process.kill(0, pid) > 0
41
+ Process.kill('TERM', pid)
42
+ sleep(1)
43
+ end
44
+ rescue Errno::ESRCH
45
+ end
46
+ end
47
+ end
48
+ end
49
+
23
50
  url = "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}"
24
51
  puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
25
- puts "=> smalruby-editor #{SmalrubyEditor::VERSION} starting in #{Rails.env} on #{url}"
52
+ puts "=> smalruby-editor #{SmalrubyEditor::VERSION} starting in #{Rails.env} on #{url} (#{pid_path})"
26
53
  puts "=> Run `smalruby-editor -h` for more startup options"
27
54
  trap(:INT) { exit }
28
55
  puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
@@ -35,17 +62,7 @@ module Rails
35
62
  console.level = Rails.logger.level
36
63
 
37
64
  Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
38
-
39
- if ActiveRecord::Migrator.needs_migration?
40
- ActiveRecord::Migration.verbose = true
41
- begin
42
- ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths)
43
- ensure
44
- ActiveRecord::Migration.verbose = false
45
- end
46
- end
47
65
  end
48
-
49
66
  super
50
67
  ensure
51
68
  # The '-h' option calls exit before @options is set.
@@ -60,7 +77,7 @@ module Rails
60
77
  environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
61
78
  daemonize: false,
62
79
  debugger: false,
63
- pid: Pathname(ENV['SMALRUBY_EDITOR_HOME']).join("tmp/pids/server.pid").to_s,
80
+ pid: Pathname(ENV['SMALRUBY_EDITOR_HOME']).join("tmp/pids/server_#{Socket.gethostname}.pid").to_s,
64
81
  config: File.expand_path("config.ru")
65
82
  })
66
83
  end
@@ -78,27 +95,29 @@ module Rails
78
95
  options
79
96
  end
80
97
  alias_method_chain :parse_options, :start_callback
98
+
99
+ def wrapped_app_with_migration
100
+ if !@wrapped_app
101
+ wrapped_app_without_migration
102
+
103
+ if ActiveRecord::Migrator.needs_migration?
104
+ ActiveRecord::Migration.verbose = true
105
+ begin
106
+ ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths)
107
+ ensure
108
+ ActiveRecord::Migration.verbose = false
109
+ end
110
+ end
111
+ end
112
+ @wrapped_app
113
+ end
114
+ alias_method_chain :wrapped_app, :migration
81
115
  end
82
116
  end
83
117
 
84
118
  Rails::Server.new.tap do |server|
85
119
  require APP_PATH
86
120
  Dir.chdir(Rails.application.root)
87
- if (pid_path = Pathname(server.default_options[:pid])).exist?
88
- if SmalrubyEditor.windows?
89
- pid = pid_path.read.to_i
90
- require 'csv'
91
- s = `tasklist /FI "IMAGENAME eq ruby.exe" /FO csv`
92
- s.force_encoding('CP932')
93
- csv = CSV.parse(s)
94
- csv.shift # ヘッダを除去
95
- pids = csv.map { |row| row[1].to_i }
96
- if pids.include?(pid)
97
- Process.kill('KILL', pid)
98
- end
99
- pid_path.unlink
100
- end
101
- end
102
121
  server.start
103
122
  end
104
123
  # rubocop:enable all
@@ -1,3 +1,3 @@
1
1
  module SmalrubyEditor
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smalruby-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-01 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -507,7 +507,7 @@ files:
507
507
  - public/assets/jquery-ui/ui-icons_888888_256x240-ce584ffa171c3ea9a018cf0d7bec65c8.png
508
508
  - public/assets/jquery-ui/ui-icons_cd0a0a_256x240-747e96029e8dedcabc224e5f7d1f2ede.png
509
509
  - public/assets/loading-e77296be32d066d3e29d3bf9803fa417.gif
510
- - public/assets/manifest-ffc1bf227b15208b38f552b56f9f8c04.json
510
+ - public/assets/manifest-514520c20d8e98306b1bb2d0437f7575.json
511
511
  - public/assets/msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js
512
512
  - public/assets/msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js.gz
513
513
  - public/assets/msg/ja-243b0a55ef1086ef2180af94c422cb5e.js