rrails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changes.md CHANGED
@@ -1,4 +1,10 @@
1
+ v1.0.1 2012-10-21 23:58:00 +0900
2
+ - FEATURE: config file suport. you can put config file at conf/rrails.yml and auto loaded.(thanks quark-zju)
3
+ - MOD: support using gem's command. (for example you can use annotate command on rrails.) (thanks quark-zju)
4
+ - FIX: uninitialized constant warnings when reloading rrails fixed. (thanks quark-zju)
5
+
1
6
  v1.0.0 2012-10-16 01:03:00 +0900
7
+ ------------------------------------------------------------------------
2
8
  - XXX: It may have many imcopatible changes. "1.0.0" does not mean "stable version".
3
9
  - MOD: support UNIXDomainSocket instead of TCPSocket. And UnixDomainSocket is default behaviour. So you can be easy to run rrails in many rails project. But you should run rrails clinet under your project's directory.(thanks quark-zju)
4
10
  - MOD: "rails-server" command is obsolate. please use "rrails start" instead. see more about README.md. (thanks quark-zju)
data/README.md CHANGED
@@ -13,8 +13,8 @@ Without rrails:
13
13
 
14
14
  With rrails:
15
15
 
16
- $ source <(rrails shellrc)
17
- $ rrails start # optionally
16
+ $ source <(rrails shellrc) # set aliases for rails and rake
17
+ $ rrails start # start the server, optionally
18
18
 
19
19
  $ time ( rails generate >/dev/null )
20
20
  ( rails generate > /dev/null; ) 0.05s user 0.01s system 6% cpu 0.904 total
@@ -26,17 +26,26 @@ With rrails:
26
26
  * POSIX Environment (Linux 2.6 - , Mac OSX Montain Lion). Windows is not supported.
27
27
  * Ruby 1.9.3p194 or above
28
28
 
29
+ ## Installation
30
+
31
+ Install from shell:
32
+
33
+ gem install rrails
34
+
35
+ And it's done. No need to add rrails to Gemfile.
36
+
29
37
  ## Usage
30
38
 
31
- Run rails/rake commands using rrails:
39
+ Run rails/rake and other commands using rrails:
32
40
 
33
41
  $ export RAILS_ENV=development # optionally
34
- $ rrails rails generate model Yakiniku # first command, slow
42
+ $ rrails rails generate model Yakiniku # first command, server starts on demand, slow
35
43
  $ rrails rails server # fast
36
44
  $ rrails rails console # fast
37
45
  $ rrails rake db:migrate # fast
38
46
  $ rrails rake routes # fast
39
47
  $ rrails -- rake -T # '--' is needed. Otherwise '-T' will be parsed by rrails
48
+ $ rrails annotate # fast. "gem 'annotate'" should exist in Gemfile
40
49
 
41
50
  For more options, run:
42
51
 
@@ -102,6 +111,22 @@ You can control the server using:
102
111
  $ rrails reload
103
112
  $ rrails status
104
113
 
114
+ ### Configuration File
115
+
116
+ `config/rrails.yml` will be auto loaded as default configuration. Here is an example of `rrails.yml`:
117
+
118
+ ---
119
+ development:
120
+ loglevel: 1
121
+ logfile: 'log/rrails.development.log'
122
+ background: true
123
+ host: '0.0.0.0'
124
+ port: 5050
125
+ production:
126
+ loglevel: 2
127
+ logfile: 'log/rrails.production.log'
128
+ ondemand: false
129
+
105
130
  ## See Also
106
131
 
107
132
  * guard-rrails: https://github.com/walf443/guard-rrails
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
data/bin/rrails CHANGED
@@ -13,9 +13,15 @@ def chdir_to_project_root
13
13
  end
14
14
  end
15
15
 
16
+ # default options
17
+ options = {
18
+ ondemand: true,
19
+ config: './config/rrails.yml',
20
+ rails_env: ENV['RAILS_ENV'] || 'development',
21
+ }
22
+
16
23
  # parse options
17
24
  require 'optparse'
18
- options = { ondemand: true }
19
25
  opts = OptionParser.new
20
26
  opts.banner =<<'!'
21
27
  Usage: rrails [options] [-- rails_or_rake_cmds]
@@ -27,16 +33,30 @@ Options:
27
33
  !
28
34
  opts.on('-h', '--help', 'Show this document.') {}
29
35
  opts.on('-E', '--rails_env=s', 'Set Rails env.') {|v| options[:rails_env] = v}
36
+ opts.on('-C', '--config=s', "Set config file path. Default: #{options[:config]}") {|v| options[:config] = v}
30
37
  opts.on('-s', '--socket=s', 'Set RRails server socket file. If this is set, host and port are ignored.') {|v| options[:socket] = v}
31
38
  opts.on('--host=s', 'Set server hostname. Default: localhost.') {|v| options[:host] = v}
32
39
  opts.on('-p', '--port=i', 'Set server port. Default: decided by rails_env.') {|v| options[:port] = v}
33
- opts.on('--[no-]ondemand', '(Client) Start RRails server on demand. Default: true.') {|v| options[:ondemand] = v}
40
+ opts.on('--[no-]ondemand', "(Client) Start RRails server on demand. Default: #{options[:ondemand]}.") {|v| options[:ondemand] = v}
34
41
  opts.on('-t', '--[no-]pty', "(Client) Prepare a PTY. Default: decided by commands.") {|v| options[:pty] = v }
35
42
  opts.on('--logfile=s', '(Server) Set log file path. Default: (stderr).') {|v| options[:logfile] = v}
43
+ opts.on('--loglevel=i', '(Server) Set log level (0 to 3). Default: 0.') {|v| options[:loglevel] = v}
36
44
  opts.on('--pidfile=s', '(Server) Set RRails server pidfile file.') {|v| options[:pidfile] = v}
37
45
  opts.on('-b', '--[no-]background', '(Server) Run in background.') {|v| options[:background] = v}
38
46
  opts.parse!(ARGV)
39
47
 
48
+ # load user config
49
+ config_path = options[:config]
50
+ if File.exists?(config_path)
51
+ require 'yaml'
52
+ config = YAML::load_file('config/rrails.yml')
53
+ config = config[options[:rails_env]] || config
54
+ options.merge!(Hash[[*config.map {|k, *v| [k.to_sym, *v]}]])
55
+ end
56
+
57
+ # make sure command line options override others
58
+ opts.parse!(ARGV)
59
+
40
60
  # run client or server
41
61
  case ARGV.first
42
62
  when nil, ''
data/lib/rrails/client.rb CHANGED
@@ -20,9 +20,6 @@ module RemoteRails
20
20
 
21
21
  @rails_env = options[:rails_env] || ENV['RAILS_ENV'] || 'development'
22
22
 
23
- @socket = "#{options[:socket] || './tmp/sockets/rrails-'}#{@rails_env}.socket"
24
- @host = options[:host] || 'localhost'
25
- @port = options[:port] || DEFAULT_PORT[@rails_env]
26
23
 
27
24
  @use_pty = options[:pty]
28
25
  @ondemand_callback = options[:ondemand_callback]
@@ -32,8 +29,12 @@ module RemoteRails
32
29
  @cmd = Shellwords.join(@cmd)
33
30
  end
34
31
 
35
- if (options[:host] || options[:port]) && (!options[:socket])
32
+ if (options[:host] || options[:port]) && !options[:socket]
36
33
  @socket = nil
34
+ @host = options[:host] || 'localhost'
35
+ @port = options[:port] || DEFAULT_PORT[@rails_env]
36
+ else
37
+ @socket = "#{options[:socket] || './tmp/sockets/rrails-'}#{@rails_env}.socket"
37
38
  end
38
39
 
39
40
  if @use_pty.nil?
data/lib/rrails/server.rb CHANGED
@@ -25,14 +25,16 @@ module RemoteRails
25
25
  @rails_env = options[:rails_env] || ENV['RAILS_ENV'] || "development"
26
26
  @pidfile = "#{options[:pidfile] || './tmp/pids/rrails-'}#{@rails_env}.pid"
27
27
  @background = options[:background] || false
28
- @host = options[:host] || 'localhost'
29
- @port = options[:port] || DEFAULT_PORT[@rails_env]
30
- @socket = "#{options[:socket] || './tmp/sockets/rrails-'}#{@rails_env}.socket"
31
28
  if (options[:host] || options[:port]) && !options[:socket]
32
- @socket = nil
29
+ @socket = nil
30
+ @host = options[:host] || 'localhost'
31
+ @port = options[:port] || DEFAULT_PORT[@rails_env]
32
+ else
33
+ @socket = "#{options[:socket] || './tmp/sockets/rrails-'}#{@rails_env}.socket"
33
34
  end
34
35
  @app_path = File.expand_path('./config/application')
35
36
  @logger = Logger.new(options[:logfile] ? options[:logfile] : (@background ? nil : STDERR))
37
+ @logger.level = options[:loglevel] || 0
36
38
  end
37
39
 
38
40
  def stop
@@ -70,7 +72,7 @@ module RemoteRails
70
72
 
71
73
  def start
72
74
  # check previous process
73
- raise RuntimeError.new('RRails is already running') if alive?
75
+ raise RuntimeError.new('rrails is already running') if alive?
74
76
 
75
77
  if @background
76
78
  pid = Process.fork do
@@ -267,7 +269,17 @@ module RemoteRails
267
269
  $0 = Gem.bin_path('rake')
268
270
  ::Rake.application.run
269
271
  else
270
- STDERR.puts "#{cmd} is not supported in RRails."
272
+ # unknown binary, try to locate its location
273
+ bin_path = begin
274
+ Gem.bin_path(cmd)
275
+ rescue
276
+ STDERR.puts "rrails: command not found: #{cmd}"
277
+ STDERR.puts "Install missing gem executables with `bundle install`"
278
+ exit(127)
279
+ end
280
+
281
+ # then load it
282
+ load bin_path
271
283
  end
272
284
  end
273
285
 
data/lib/rrails.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  module RemoteRails
2
- DEFAULT_PORT = {
3
- "development" => 5656,
4
- "test" => 5657,
5
- "production" => 5658,
6
- }
2
+
3
+ if not defined?(DEFAULT_PORT)
4
+ DEFAULT_PORT = {
5
+ "development" => 5656,
6
+ "test" => 5657,
7
+ "production" => 5658,
8
+ }
9
+ end
10
+
7
11
  end
data/rrails.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rrails"
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Keiji, Yoshimi"]
12
- s.date = "2012-10-15"
12
+ s.date = "2012-10-21"
13
13
  s.description = "remote run rails/rake command"
14
14
  s.email = "walf443@gmail.com"
15
15
  s.executables = ["rrails", "rrails-server"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-15 00:00:00.000000000 Z
12
+ date: 2012-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: 4515075186478304892
136
+ hash: 3781868682991120205
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements: