guard-rails 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,4 +2,5 @@ rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
4
  - ree
5
+ - 2.0.0
5
6
  script: "bundle exec rake spec"
data/Gemfile CHANGED
@@ -5,13 +5,12 @@ gemspec
5
5
  gem 'rake'
6
6
  gem 'fakefs', :require => nil
7
7
  gem 'guard'
8
+ gem 'guard-bundler'
8
9
  gem 'guard-rspec'
9
10
 
10
- case RUBY_PLATFORM.downcase
11
- when /darwin/
12
- gem 'rb-fsevent', '>= 0.3.9'
13
- gem 'growl', '>= 1.0.3'
14
- when /linux/
15
- gem 'rb-inotify', '>= 0.5.1'
16
- gem 'libnotify', '>= 0.1.3'
17
- end
11
+ gem 'rb-fsevent', '>= 0.3.9'
12
+ gem 'rb-inotify', '>= 0.5.1'
13
+
14
+ # Notification System
15
+ gem 'terminal-notifier-guard', :require => RUBY_PLATFORM.downcase.include?("darwin") ? 'terminal-notifier-guard' : nil
16
+ gem 'libnotify', :require => RUBY_PLATFORM.downcase.include?("linux") ? 'libnotify' : nil
data/Guardfile CHANGED
@@ -1,7 +1,13 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec' do
4
+ guard 'bundler' do
5
+ watch('Gemfile')
6
+ watch(/^.+\.gemspec/)
7
+ end
8
+
9
+ guard 'rspec', :cli => "--color --format documentation" do
10
+ watch('Gemfile.lock')
5
11
  watch(%r{^spec/.+_spec\.rb})
6
12
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
13
  watch('spec/spec_helper.rb') { "spec" }
data/README.md CHANGED
@@ -3,26 +3,41 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/guard-rails.png)](http://badge.fury.io/rb/guard-rails)
4
4
  [![Build Status](https://travis-ci.org/ranmocy/guard-rails.png)](https://travis-ci.org/ranmocy/guard-rails)
5
5
  [![Dependency Status](https://gemnasium.com/ranmocy/guard-rails.png)](https://gemnasium.com/ranmocy/guard-rails)
6
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/ranmocy/guard-rails)
6
+ [![Code Climate](https://codeclimate.com/github/ranmocy/guard-rails.png)](https://codeclimate.com/github/ranmocy/guard-rails)
7
7
 
8
- Want to restart your Rails development server whilst you work? Now you can!
8
+ ## Want to restart your Rails development server whilst you work? Now you can!
9
9
 
10
10
  guard 'rails', :port => 5000 do
11
11
  watch('Gemfile.lock')
12
12
  watch(%r{^(config|lib)/.*})
13
13
  end
14
14
 
15
- Lots of fun options!
15
+ ## Lots of fun options growing!
16
16
 
17
- * `:port` is the port number to run on (default `3000`)
18
- * `:environment` is the environment to use (default `development`)
19
- * `:start_on_start` will start the server when starting Guard (default `true`)
20
- * `:force_run` kills any process that's holding open the listen port before attempting to (re)start Rails (default `false`).
21
- * `:daemon` runs the server as a daemon, without any output to the terminal that ran `guard` (default `false`).
22
- * `:debugger` runs the server with the debugger enabled (default `false`). Required ruby-debug gem.
23
- * `:timeout` waits this number of seconds when restarting the Rails server before reporting there's a problem (default `20`).
24
- * `:server` lets you specify the webserver engine to use (try `:server => :thin`).
25
- * `:pid_file` specify your pid_file, so that maybe you can run multiple instances with same rails_env (default `tmp/pids/[RAILS_ENV].pid`).
26
- * `:zeus` support [zeus](https://github.com/burke/zeus) to boost rails init speed (default `false`).
17
+ * `:daemon` runs the server as a daemon, without any output to the terminal that ran `guard` (**default `false`**)
18
+ * `:debugger` enable the debugger in server. Required ruby-debug gem. (**default `false`**)
19
+ * `:environment` is the server environment (**default `development`**)
20
+ * `:force_run` kills any process that's holding the listen port before attempting to (re)start Rails (**default `false`**)
21
+ * `:pid_file` specify your pid\_file (**default `tmp/pids/[RAILS_ENV].pid`**)
22
+ * `:port` is the server port number (**default `3000`**)
23
+ * `:server` the webserver engine to use (**try `:server => :thin`**)
24
+ * `:start_on_start` will start the server when starting Guard (**default `true`**)
25
+ * `:timeout` waits when restarting the Rails server, in seconds (**default `30`**).
26
+ * `:zeus_plan` the [custom plan](https://github.com/burke/zeus/blob/master/docs/ruby/modifying.md) in zeus, only works when `zeus` option is `true` (**default `server`**)
27
+ * `:zeus` support [zeus](https://github.com/burke/zeus) to boost rails init speed (**default `false`**).
28
+ * `:CLI` construct the runner command as your willing! Will omit all options above except `pid_file`! (**default `rails server --pid tmp/pids/[RAILS_ENV].pid`**)
27
29
 
30
+ ## How-to
31
+
32
+ * **Multiple instances** use `pid_file` option to run multiple instances with same rails\_env
33
+
34
+ ## Contribute
28
35
  Feel free to fork'n'fix for any willing.
36
+
37
+ Or
38
+
39
+ Tell.me in: any.way
40
+
41
+ ## Philosophy
42
+
43
+ * [Semantic Version](http://semver.org/)
data/Rakefile CHANGED
@@ -1,26 +1,32 @@
1
- include Rake::DSL if defined?(Rake::DSL)
2
-
3
1
  require 'bundler'
4
2
  Bundler::GemHelper.install_tasks
3
+
5
4
  require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- desc 'Push everywhere!'
8
- task :publish do
9
- system %{git push origin}
10
- system %{git push guard}
11
- system %{git push gitcafe}
7
+ require 'rake/version_task'
8
+ Rake::VersionTask.new do |task|
9
+ task.with_git_tag = true
12
10
  end
13
11
 
14
- RSpec::Core::RakeTask.new(:spec)
12
+ include Rake::DSL if defined?(Rake::DSL)
13
+ RVM_PREFIX = "rvm 1.8.7@guard-rails,1.9.3-p327@guard-rails,2.0.0@guard-rails do"
14
+
15
15
 
16
16
  namespace :spec do
17
17
  desc "Run on three Rubies"
18
18
  task :platforms do
19
- prefix = "rvm 1.8.7,1.9.2,ree,1.9.3 do"
20
- system %{#{prefix} bundle}
21
- system %{#{prefix} bundle exec rake spec}
19
+ system %{#{RVM_PREFIX} bundle}
20
+ system %{#{RVM_PREFIX} bundle exec rake spec}
22
21
  exit $?.exitstatus if $?.exitstatus != 0
23
22
  end
24
23
  end
25
24
 
26
25
  task :default => 'spec:platforms'
26
+
27
+ desc 'Push everywhere!'
28
+ task :publish do
29
+ system %{git push origin}
30
+ system %{git push guard}
31
+ system %{git push gitcafe}
32
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
data/guard-rails.gemspec CHANGED
@@ -1,9 +1,8 @@
1
1
  $:.push File.expand_path("../lib", __FILE__)
2
- require "guard/rails/version"
3
2
 
4
3
  Gem::Specification.new do |s|
5
4
  s.name = "guard-rails"
6
- s.version = GuardRails::VERSION
5
+ s.version = File.open('VERSION') { |f| f.read }
7
6
  s.platform = Gem::Platform::RUBY
8
7
  s.authors = ["John Bintz", "Wanzhang Sheng"]
9
8
  s.email = ["john@coswellproductions.com", "Ranmocy@gmail.com"]
@@ -19,6 +18,7 @@ Gem::Specification.new do |s|
19
18
  s.require_paths = ["lib"]
20
19
 
21
20
  s.add_dependency 'guard', '>= 0.2.2'
21
+ s.add_dependency 'version', '>= 1.0.0'
22
22
 
23
23
  s.add_development_dependency 'rspec', '>= 2.6.0'
24
24
  s.add_development_dependency 'mocha', '>= 0.13.1'
data/lib/guard/rails.rb CHANGED
@@ -2,22 +2,29 @@ require 'guard'
2
2
  require 'guard/guard'
3
3
  require 'guard/rails/runner'
4
4
  require 'rbconfig'
5
+ require "version"
5
6
 
6
7
  module Guard
7
8
  class Rails < ::Guard::Guard
9
+ # Use gem `version` to support versioning
10
+ is_versioned
11
+
8
12
  attr_reader :options, :runner
9
13
 
10
14
  DEFAULT_OPTIONS = {
11
- :port => 3000,
12
- :environment => 'development',
13
- :start_on_start => true,
14
- :force_run => false,
15
- :timeout => 30,
16
- :server => nil,
17
- :debugger => false,
18
- :pid_file => nil,
19
- :zeus => false,
20
- }
15
+ :CLI => nil,
16
+ :daemon => false,
17
+ :debugger => false,
18
+ :environment => 'development',
19
+ :force_runs => false,
20
+ :pid_file => nil, # construct the filename based on options[:environment] on runtime
21
+ :port => 3000,
22
+ :server => nil, # specified by rails
23
+ :start_on_start => true,
24
+ :timeout => 30,
25
+ :zeus_plan => 'server',
26
+ :zeus => false,
27
+ }
21
28
 
22
29
  def initialize(watchers = [], options = {})
23
30
  super
@@ -57,4 +64,3 @@ module Guard
57
64
  alias :run_on_change :run_on_changes
58
65
  end
59
66
  end
60
-
@@ -34,19 +34,25 @@ module Guard
34
34
  end
35
35
 
36
36
  def build_rails_command
37
+ return %{sh -c 'cd #{Dir.pwd} && #{options[:CLI]} --pid #{pid_file} &'} if options[:CLI]
38
+
37
39
  rails_options = [
40
+ options[:daemon] && '-d',
41
+ options[:debugger] && '-u',
38
42
  '-e', options[:environment],
39
- '-p', options[:port],
40
43
  '--pid', pid_file,
41
- options[:daemon] ? '-d' : '',
42
- options[:debugger] ? '-u' : '',
43
- options[:server].nil? ? '' : options[:server],
44
+ '-p', options[:port],
45
+ options[:server] || '',
46
+ ]
47
+
48
+ zeus_options = [
49
+ options[:zeus_plan] || 'server',
44
50
  ]
45
51
 
46
52
  # omit env when use zeus
47
- rails_runner = options[:zeus] ? 'zeus' : "RAILS_ENV=#{options[:environment]} rails"
53
+ rails_runner = options[:zeus] ? "zeus #{zeus_options.join(' ')}" : "RAILS_ENV=#{options[:environment]} rails server"
48
54
 
49
- %{sh -c 'cd #{Dir.pwd} && #{rails_runner} server #{rails_options.join(' ')} &'}
55
+ %{sh -c 'cd #{Dir.pwd} && #{rails_runner} #{rails_options.join(' ')} &'}
50
56
  end
51
57
 
52
58
  def pid_file
@@ -34,20 +34,47 @@ describe Guard::RailsRunner do
34
34
  end
35
35
 
36
36
  describe '#build_rails_command' do
37
- context 'no daemon' do
38
- it "should not have a daemon switch" do
37
+ context "CLI" do
38
+ let(:custom_cli) { 'custom_CLI_command' }
39
+ let(:options) { default_options.merge(:CLI => custom_cli) }
40
+ it "should have only custom CLI" do
41
+ runner.build_rails_command.should match(%r{&& #{custom_cli} --pid })
42
+ end
43
+
44
+ let(:custom_pid_file) { "tmp/pids/rails_dev.pid" }
45
+ let(:options) { default_options.merge(:CLI => custom_cli, :pid_file => custom_pid_file) }
46
+ it "should use custom pid_file" do
47
+ pid_file_path = File.expand_path custom_pid_file
48
+ runner.build_rails_command.should match(%r{&& #{custom_cli} --pid #{pid_file_path}})
49
+ end
50
+ end
51
+
52
+ context "daemon" do
53
+ it "should should not have daemon switch" do
39
54
  runner.build_rails_command.should_not match(%r{ -d})
40
55
  end
41
56
  end
42
57
 
43
- context 'daemon' do
58
+ context "no daemon" do
44
59
  let(:options) { default_options.merge(:daemon => true) }
45
-
46
60
  it "should have a daemon switch" do
47
61
  runner.build_rails_command.should match(%r{ -d})
48
62
  end
49
63
  end
50
64
 
65
+ context "development" do
66
+ it "should have environment switch to development" do
67
+ runner.build_rails_command.should match(%r{ -e development})
68
+ end
69
+ end
70
+
71
+ context "test" do
72
+ let(:options) { default_options.merge(:environment => 'test') }
73
+ it "should have environment switch to test" do
74
+ runner.build_rails_command.should match(%r{ -e test})
75
+ end
76
+ end
77
+
51
78
  context 'debugger' do
52
79
  let(:options) { default_options.merge(:debugger => true) }
53
80
 
@@ -80,6 +107,31 @@ describe Guard::RailsRunner do
80
107
  runner.build_rails_command.should match(%r{ --pid #{pid_file_path}})
81
108
  end
82
109
  end
110
+
111
+ context "zeus enabled" do
112
+ let(:options) { default_options.merge(:zeus => true) }
113
+ it "should have zeus in command" do
114
+ runner.build_rails_command.should match(%r{ zeus server })
115
+ end
116
+
117
+ context "custom zeus plan" do
118
+ let(:options) { default_options.merge(:zeus => true, :zeus_plan => 'test_server') }
119
+ it "should use custom zeus plan" do
120
+ runner.build_rails_command.should match(%r{ zeus test_server})
121
+ end
122
+ end
123
+ end
124
+
125
+ context "zeus disabled" do
126
+ it "should not have zeus in command" do
127
+ runner.build_rails_command.should_not match(%r{ zeus server })
128
+ end
129
+
130
+ let(:options) { default_options.merge(:zeus_plan => 'test_server') }
131
+ it "should have no effect of command" do
132
+ runner.build_rails_command.should_not match(%r{test_server})
133
+ end
134
+ end
83
135
  end
84
136
 
85
137
  describe '#start' do
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rails
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.3.0
4
5
  prerelease:
5
- version: 0.2.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Bintz
@@ -10,56 +10,72 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-03 00:00:00.000000000 Z
13
+ date: 2013-02-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- version_requirements: !ruby/object:Gem::Requirement
16
+ name: guard
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
20
  - - ! '>='
19
21
  - !ruby/object:Gem::Version
20
22
  version: 0.2.2
21
- none: false
23
+ type: :runtime
22
24
  prerelease: false
23
- name: guard
24
- requirement: !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ! '>='
27
29
  - !ruby/object:Gem::Version
28
30
  version: 0.2.2
31
+ - !ruby/object:Gem::Dependency
32
+ name: version
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 1.0.0
30
39
  type: :runtime
31
- - !ruby/object:Gem::Dependency
40
+ prerelease: false
32
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
33
43
  requirements:
34
44
  - - ! '>='
35
45
  - !ruby/object:Gem::Version
36
- version: 2.6.0
37
- none: false
38
- prerelease: false
46
+ version: 1.0.0
47
+ - !ruby/object:Gem::Dependency
39
48
  name: rspec
40
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
41
51
  requirements:
42
52
  - - ! '>='
43
53
  - !ruby/object:Gem::Version
44
54
  version: 2.6.0
45
- none: false
46
55
  type: :development
47
- - !ruby/object:Gem::Dependency
56
+ prerelease: false
48
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
49
59
  requirements:
50
60
  - - ! '>='
51
61
  - !ruby/object:Gem::Version
52
- version: 0.13.1
53
- none: false
54
- prerelease: false
62
+ version: 2.6.0
63
+ - !ruby/object:Gem::Dependency
55
64
  name: mocha
56
65
  requirement: !ruby/object:Gem::Requirement
66
+ none: false
57
67
  requirements:
58
68
  - - ! '>='
59
69
  - !ruby/object:Gem::Version
60
70
  version: 0.13.1
61
- none: false
62
71
  type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 0.13.1
63
79
  description: Restart Rails when things change in your app
64
80
  email:
65
81
  - john@coswellproductions.com
@@ -74,12 +90,12 @@ files:
74
90
  - Guardfile
75
91
  - README.md
76
92
  - Rakefile
93
+ - VERSION
77
94
  - guard-rails.gemspec
78
95
  - lib/guard-rails.rb
79
96
  - lib/guard/rails.rb
80
97
  - lib/guard/rails/runner.rb
81
98
  - lib/guard/rails/templates/Guardfile
82
- - lib/guard/rails/version.rb
83
99
  - spec/lib/guard/rails/runner_spec.rb
84
100
  - spec/lib/guard/rails_spec.rb
85
101
  - spec/spec_helper.rb
@@ -90,26 +106,26 @@ rdoc_options: []
90
106
  require_paths:
91
107
  - lib
92
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
93
110
  requirements:
94
111
  - - ! '>='
95
112
  - !ruby/object:Gem::Version
96
113
  version: '0'
97
114
  segments:
98
115
  - 0
99
- hash: 4523290980617449306
100
- none: false
116
+ hash: 2850314987821883862
101
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
102
119
  requirements:
103
120
  - - ! '>='
104
121
  - !ruby/object:Gem::Version
105
122
  version: '0'
106
123
  segments:
107
124
  - 0
108
- hash: 4523290980617449306
109
- none: false
125
+ hash: 2850314987821883862
110
126
  requirements: []
111
127
  rubyforge_project: guard-rails
112
- rubygems_version: 1.8.24
128
+ rubygems_version: 1.8.23
113
129
  signing_key:
114
130
  specification_version: 3
115
131
  summary: Guard your Rails to always be there.
@@ -1,4 +0,0 @@
1
- module GuardRails
2
- VERSION = '0.2.3'
3
- end
4
-