guard-shotgun 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86d8bdbb8c06897e94cd051a246f966acad6a34d
4
+ data.tar.gz: 95f189ab7cd2ec78329c512cd0e9be3f8585549e
5
+ SHA512:
6
+ metadata.gz: 6cd8119159f0c77415562f8152dd311b82b54e3452b45e73d426a605369d362d246e27fda4bb52fa061c3452d23eceb908e15962f0e4ba55260aa1d368fd93bd
7
+ data.tar.gz: 78d16d3146bea63b589bc79d9a26194e5edaad84ba9d305d954e3be41a1d6d0bd8223e59ba5ef88ff324a3dbe7c8296265cd86b65878da0c0f72e5d38bd40172
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  .bundle
3
- Gemfile.lock
4
3
  pkg/*
5
4
  vendor/bundle*
5
+ /*.ruby-version
6
+ *.ruby-gemset
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guard-shotgun (0.3.0)
5
+ ffi
6
+ guard (~> 1.0)
7
+ spoon
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ coderay (1.1.0)
13
+ diff-lcs (1.2.5)
14
+ ffi (1.9.3)
15
+ formatador (0.2.5)
16
+ guard (1.8.3)
17
+ formatador (>= 0.2.4)
18
+ listen (~> 1.3)
19
+ lumberjack (>= 1.0.2)
20
+ pry (>= 0.9.10)
21
+ thor (>= 0.14.6)
22
+ listen (1.3.1)
23
+ rb-fsevent (>= 0.9.3)
24
+ rb-inotify (>= 0.9)
25
+ rb-kqueue (>= 0.2)
26
+ lumberjack (1.0.9)
27
+ method_source (0.8.2)
28
+ pry (0.10.1)
29
+ coderay (~> 1.1.0)
30
+ method_source (~> 0.8.1)
31
+ slop (~> 3.4)
32
+ rake (10.1.1)
33
+ rb-fsevent (0.9.4)
34
+ rb-inotify (0.9.5)
35
+ ffi (>= 0.5.0)
36
+ rb-kqueue (0.2.3)
37
+ ffi (>= 0.5.0)
38
+ rspec (3.1.0)
39
+ rspec-core (~> 3.1.0)
40
+ rspec-expectations (~> 3.1.0)
41
+ rspec-mocks (~> 3.1.0)
42
+ rspec-core (3.1.2)
43
+ rspec-support (~> 3.1.0)
44
+ rspec-expectations (3.1.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.1.0)
47
+ rspec-mocks (3.1.0)
48
+ rspec-support (~> 3.1.0)
49
+ rspec-support (3.1.0)
50
+ slop (3.6.0)
51
+ spoon (0.0.4)
52
+ ffi
53
+ thor (0.19.1)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ guard-shotgun!
60
+ rake
61
+ rspec
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Copyright (c) 2011 Fletcher Nichol
2
- Copyright (c) 2012 Romain Champourlier
3
2
  Copyright (c) 2012 Colin Rymer
3
+ Copyright (c) 2014 Romain Champourlier
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,19 +1,23 @@
1
1
  # Guard::Shotgun
2
2
 
3
- Guard::Shotgun automatically starts and restarts Sinatra (through `rackup`) when needed. As useful as Shotgun when developing a Sinatra app.
3
+ Guard::Shotgun automatically starts and restarts Rack applications (through `rackup`) when needed. As useful as Shotgun when developing a Rack app.
4
4
 
5
- * Tested on Ruby 1.9.2-p290 only.
5
+ Tested on:
6
+
7
+ * Ruby 1.9.2-p290
8
+ * Ruby 2.0.0-p247
6
9
 
7
10
  ## Why?
8
11
 
9
- * You are **developing with Sinatra** and you have to **restart your development server each time you change your source code**?
12
+ * You are **developing with Rack** and you have to **restart your development server each time you change your source code**?
10
13
  * You are **using Shotgun** to do this, but well, the **latest version is not showing the logs anymore** in your console, which makes developing a little harder?
14
+ * Reloading your whole Rack app with each request seems a bit overkill? Seems better to only reload it on a file change?
11
15
 
12
16
  If you have answered 'yes' to any of these questions, you may find some use to this plugin.
13
17
 
14
18
  ## Install
15
19
 
16
- Please be sure to have [Guard](http://github.com/guard/guard) installed before continue.
20
+ Please be sure to have [Guard](http://github.com/guard/guard) installed before continuing.
17
21
 
18
22
  Install the gem:
19
23
 
@@ -21,7 +25,7 @@ Install the gem:
21
25
 
22
26
  Or add it to your Gemfile (inside development group):
23
27
 
24
- gem 'guard-shotgun', :git => https://github.com/rchampourlier/guard-shotgun.git
28
+ gem 'guard-shotgun', :git => 'https://github.com/rchampourlier/guard-shotgun.git'
25
29
 
26
30
  Add guard definition to your Guardfile by running this command:
27
31
 
@@ -29,9 +33,9 @@ Add guard definition to your Guardfile by running this command:
29
33
 
30
34
  ## Usage
31
35
 
32
- This guard plugin is intended to be used when **developing a Sinatra application**, loaded through `rackup`.
36
+ This guard plugin is intended to be used when **developing a Rack application**, loaded through `rackup`.
33
37
 
34
- **It allows automatic reloading of your Sinatra server when a file is changed.**
38
+ **It allows automatic reloading of your Rack server when a file is changed.**
35
39
 
36
40
  > It provides the same service as the **Shotgun** gem, relying on **Guard** to watch for your files.
37
41
 
@@ -44,28 +48,75 @@ For example, to look at the `main.rb` file in your application directory, just s
44
48
  guard 'shotgun' do
45
49
  watch('main.rb')
46
50
  end
47
-
51
+
52
+ **Common config**
53
+
54
+ Here we watch Ruby files within the `app` and `lib` directories, as well as the `config.ru` file. We also use Thin as a server instead of the default WEBRick.
55
+
56
+ guard 'shotgun', :server => 'thin' do
57
+ watch %r{^(app|lib)/.*\.rb}
58
+ watch 'config.ru'
59
+ end
60
+
48
61
  Please read [Guard doc](http://github.com/guard/guard#readme) for more info about Guardfile DSL.
49
62
 
50
63
 
51
64
  ## Options
52
65
 
53
- Currently there is no option.
66
+ * `server`: the name of the server to use. The option is passed to the `rackup` command. You may use for example `WEBrick` (default), `thin`...
67
+ * `port`: the port on which to run the server, the option is also passed to the `rackup` command.
68
+
69
+
70
+ ## Testing
71
+
72
+ There is currently no spec :S. I intend to write some (won't need much). You may however go to the `spec/dummy_app` directory and run:
73
+
74
+ ```
75
+ bundle install
76
+ bundle exec guard
77
+ ```
78
+
79
+ This way, you can check it's working correctly. You can play with the `spec/dummy_app/app/base_app.rb` file and introduce some bug so that you may see a failing start is correctly handled too.
80
+
81
+
82
+ ## Compatibility with Guard
83
+
84
+ * 0.2.0 is compatible (and dependent on) Guard ~> 1.0
54
85
 
55
86
  ## History
56
87
 
57
- #### v0.0.4
88
+ #### 0.3.0
89
+
90
+ * Adding dependency on Guard ~> 1.0
91
+ * Fixed an issue when autoloading the Notifier class
92
+ * Minor changes to README, repo and dummy_app
93
+
94
+ #### 0.2.0
95
+
96
+ * Merged an update by Colin Rymer
97
+
98
+ #### 0.1.0
99
+
100
+ * Essentially repository cleanup and README update.
101
+
102
+ #### 0.0.6
103
+
104
+ * Improved start/stop management:
105
+ * Exiting Guard will trigger INT signal instead of TERM, stopping WEBRick gently.
106
+ * Failure to start will be detected too after a 10 seconds timeout, and the app will just get reloaded when you change a file.
107
+
108
+ #### 0.0.4
58
109
 
59
- Killing Sinatra when reloading on change without waiting for requests to be completed.
110
+ Killing Rack when reloading on change without waiting for requests to be completed.
60
111
 
61
- #### v0.0.3
112
+ #### 0.0.3
62
113
 
63
114
  Initial release
64
115
 
65
116
  ## TODOs
66
117
 
67
118
  * Add some options: host, port...
68
- * Allow starting Sinatra applications without using rackup.
119
+ * Allow starting Rack applications without using rackup.
69
120
  * Tests.
70
121
 
71
122
  Help is welcome!
data/Rakefile CHANGED
@@ -1,13 +1 @@
1
- begin
2
- require 'jeweler'
3
- Jeweler::Tasks.new do |gemspec|
4
- gemspec.name = "guard-shotgun"
5
- gemspec.summary = "Guard gem for Sinatra (shotgun-like)"
6
- gemspec.description = "Guard gem for Sinatra (shotgun-like)"
7
- gemspec.email = "romain@softr.li"
8
- gemspec.homepage = "http://github.com/rchampourlier/guard-shotgun"
9
- gemspec.authors = ["romain@softr.li"]
10
- end
11
- rescue LoadError
12
- puts "Jeweler not available. Install it with: gem install jeweler"
13
- end
1
+ require "bundler/gem_tasks"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.3.0
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.description = 'This gem provides a Guard that restarts Rack apps when watched files are modified similar. Similar to the wonderful Shotgun by rtomayko'
11
11
  gem.summary = 'Shotgun-like Guard for Rack apps'
12
12
  gem.date = Date.today.to_s
13
- gem.homepage = "http://github.com/crymer11/guard-shotgun"
13
+ gem.homepage = "http://github.com/rchampourlier/guard-shotgun"
14
14
  gem.license = 'MIT'
15
15
  gem.executables = []
16
16
  gem.files = `git ls-files`.split("\n")
@@ -22,9 +22,11 @@ Gem::Specification.new do |gem|
22
22
  gem.require_paths = ["lib"]
23
23
  gem.required_ruby_version = '>= 1.9'
24
24
 
25
- gem.add_dependency 'guard', '~> 1.5.4'
26
- gem.add_dependency 'ffi', '~> 1.2.0'
27
- gem.add_dependency 'spoon', '~> 0.0.1'
25
+ gem.add_dependency 'guard', "~> 1.0"
26
+ gem.add_dependency 'ffi'
27
+ gem.add_dependency 'spoon'
28
28
 
29
+ gem.add_development_dependency 'rake'
30
+ gem.add_development_dependency 'rspec'
29
31
  end
30
32
 
data/lib/guard/shotgun.rb CHANGED
@@ -8,9 +8,11 @@ module Guard
8
8
  class Shotgun < Guard
9
9
  VALID_ARGS = %w{server host port env daemonize pid option}
10
10
 
11
- autoload :Notifier, 'guard/shotgun/notifier'
11
+ require File.expand_path('../shotgun/notifier', __FILE__)
12
12
  attr_accessor :pid
13
13
 
14
+ STARTUP_TIMEOUT = 10 # seconds
15
+
14
16
  def initialize(watchers=[], options={})
15
17
  super
16
18
  @options = {
@@ -35,8 +37,13 @@ module Guard
35
37
  @pid = Spoon.spawnp 'rackup', *options_array, config_file
36
38
  end
37
39
  wait_for_port
38
- Notifier.notify(@reloaded ? 'reloaded' : 'up')
39
- @reloaded = false
40
+ if running?
41
+ Notifier.notify(@reloaded ? 'reloaded' : 'up')
42
+ @reloaded = false
43
+ else
44
+ UI.info "Rack failed to start."
45
+ Notifier.notify('failed')
46
+ end
40
47
  end
41
48
 
42
49
  # Call with Ctrl-C signal (when Guard quit)
@@ -109,7 +116,8 @@ module Guard
109
116
  end
110
117
 
111
118
  def wait_for_port
112
- while true do
119
+ timeout_time = Time.now + STARTUP_TIMEOUT
120
+ while Time.now < timeout_time do
113
121
  sleep 0.2
114
122
  break if port_open?(@options[:host], @options[:port])
115
123
  end
@@ -8,14 +8,17 @@ module Guard
8
8
  "Sinatra up and running"
9
9
  when 'reloaded'
10
10
  "Sinatra reloaded"
11
+ when 'failed'
12
+ 'Sinatra failed to start'
11
13
  end
12
14
  end
13
15
 
14
16
  # failed | success
15
17
  def self.guard_image(result)
16
- icon = if result == 'ready'
18
+ case result
19
+ when 'reloaded', 'up'
17
20
  :success
18
- else
21
+ when 'failed'
19
22
  :failed
20
23
  end
21
24
  end
@@ -26,7 +29,6 @@ module Guard
26
29
 
27
30
  ::Guard::Notifier.notify(message, :title => 'guard-shotgun', :image => image)
28
31
  end
29
-
30
32
  end
31
33
  end
32
- end
34
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module ShotgunVersion
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
Binary file
@@ -0,0 +1 @@
1
+ ruby-2.1
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'sinatra', :require => "sinatra/base"
4
+
5
+ group :development, :test do
6
+ gem 'guard', '~> 1'
7
+
8
+ # Requirements for the manually inserted guard-shotgun
9
+ gem 'spoon'
10
+ gem 'ffi'
11
+ end
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coderay (1.1.0)
5
+ ffi (1.9.3)
6
+ formatador (0.2.5)
7
+ guard (1.8.3)
8
+ formatador (>= 0.2.4)
9
+ listen (~> 1.3)
10
+ lumberjack (>= 1.0.2)
11
+ pry (>= 0.9.10)
12
+ thor (>= 0.14.6)
13
+ listen (1.3.1)
14
+ rb-fsevent (>= 0.9.3)
15
+ rb-inotify (>= 0.9)
16
+ rb-kqueue (>= 0.2)
17
+ lumberjack (1.0.9)
18
+ method_source (0.8.2)
19
+ pry (0.10.1)
20
+ coderay (~> 1.1.0)
21
+ method_source (~> 0.8.1)
22
+ slop (~> 3.4)
23
+ rack (1.5.2)
24
+ rack-protection (1.5.3)
25
+ rack
26
+ rb-fsevent (0.9.4)
27
+ rb-inotify (0.9.5)
28
+ ffi (>= 0.5.0)
29
+ rb-kqueue (0.2.3)
30
+ ffi (>= 0.5.0)
31
+ sinatra (1.4.5)
32
+ rack (~> 1.4)
33
+ rack-protection (~> 1.4)
34
+ tilt (~> 1.3, >= 1.3.4)
35
+ slop (3.6.0)
36
+ spoon (0.0.4)
37
+ ffi
38
+ thor (0.19.1)
39
+ tilt (1.4.1)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ ffi
46
+ guard (~> 1)
47
+ sinatra
48
+ spoon
@@ -0,0 +1,5 @@
1
+ require File.expand_path('../../../lib/guard/shotgun', __FILE__)
2
+
3
+ guard 'shotgun' do
4
+ watch(%r{^(app|assets|lib|config)/(.)*.(rb|css|js|haml)})
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'rspec/core'
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :default => :spec
5
+
6
+ desc "Run all specs in spec directory (excluding plugin specs)"
7
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,7 @@
1
+ class BaseApp < Sinatra::Base
2
+ #raise "Failing app"
3
+
4
+ get '/' do
5
+ "Hello world, naturally!"
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ ENV["RACK_ENV"] ||= "development"
2
+
3
+ require File.join(File.dirname(__FILE__), 'config/boot')
4
+ require File.join(File.dirname(__FILE__), 'app/base_app')
5
+
6
+ run BaseApp
@@ -0,0 +1,6 @@
1
+ # boot.rb
2
+
3
+ # Load dependencies
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+ Bundler.require
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-shotgun
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.2.0
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - romain@softr.li
@@ -10,56 +9,78 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-12-06 00:00:00.000000000 Z
12
+ date: 2014-09-16 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
- version_requirements: !ruby/object:Gem::Requirement
15
+ name: guard
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.5.4
21
- none: false
22
- name: guard
20
+ version: '1.0'
23
21
  type: :runtime
24
22
  prerelease: false
25
- requirement: !ruby/object:Gem::Requirement
23
+ version_requirements: !ruby/object:Gem::Requirement
26
24
  requirements:
27
- - - ~>
25
+ - - "~>"
28
26
  - !ruby/object:Gem::Version
29
- version: 1.5.4
30
- none: false
27
+ version: '1.0'
31
28
  - !ruby/object:Gem::Dependency
32
- version_requirements: !ruby/object:Gem::Requirement
29
+ name: ffi
30
+ requirement: !ruby/object:Gem::Requirement
33
31
  requirements:
34
- - - ~>
32
+ - - ">="
35
33
  - !ruby/object:Gem::Version
36
- version: 1.2.0
37
- none: false
38
- name: ffi
34
+ version: '0'
39
35
  type: :runtime
40
36
  prerelease: false
41
- requirement: !ruby/object:Gem::Requirement
37
+ version_requirements: !ruby/object:Gem::Requirement
42
38
  requirements:
43
- - - ~>
39
+ - - ">="
44
40
  - !ruby/object:Gem::Version
45
- version: 1.2.0
46
- none: false
41
+ version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
- version_requirements: !ruby/object:Gem::Requirement
43
+ name: spoon
44
+ requirement: !ruby/object:Gem::Requirement
49
45
  requirements:
50
- - - ~>
46
+ - - ">="
51
47
  - !ruby/object:Gem::Version
52
- version: 0.0.1
53
- none: false
54
- name: spoon
48
+ version: '0'
55
49
  type: :runtime
56
50
  prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
57
72
  requirement: !ruby/object:Gem::Requirement
58
73
  requirements:
59
- - - ~>
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
60
82
  - !ruby/object:Gem::Version
61
- version: 0.0.1
62
- none: false
83
+ version: '0'
63
84
  description: This gem provides a Guard that restarts Rack apps when watched files
64
85
  are modified similar. Similar to the wonderful Shotgun by rtomayko
65
86
  email:
@@ -71,8 +92,11 @@ extra_rdoc_files:
71
92
  - LICENSE
72
93
  - README.md
73
94
  files:
74
- - .gitignore
95
+ - ".gitignore"
96
+ - ".ruby-gemset"
97
+ - ".ruby-version"
75
98
  - Gemfile
99
+ - Gemfile.lock
76
100
  - LICENSE
77
101
  - README.md
78
102
  - Rakefile
@@ -82,31 +106,48 @@ files:
82
106
  - lib/guard/shotgun/notifier.rb
83
107
  - lib/guard/shotgun/templates/Guardfile
84
108
  - lib/guard/shotgun/version.rb
109
+ - spec/dummy_app/.DS_Store
110
+ - spec/dummy_app/.ruby-version
111
+ - spec/dummy_app/Gemfile
112
+ - spec/dummy_app/Gemfile.lock
113
+ - spec/dummy_app/Guardfile
114
+ - spec/dummy_app/Rakefile
115
+ - spec/dummy_app/app/base_app.rb
116
+ - spec/dummy_app/config.ru
117
+ - spec/dummy_app/config/boot.rb
85
118
  - spec/spec_helper.rb
86
- homepage: http://github.com/crymer11/guard-shotgun
119
+ homepage: http://github.com/rchampourlier/guard-shotgun
87
120
  licenses:
88
121
  - MIT
122
+ metadata: {}
89
123
  post_install_message:
90
124
  rdoc_options: []
91
125
  require_paths:
92
126
  - lib
93
127
  required_ruby_version: !ruby/object:Gem::Requirement
94
128
  requirements:
95
- - - ! '>='
129
+ - - ">="
96
130
  - !ruby/object:Gem::Version
97
131
  version: '1.9'
98
- none: false
99
132
  required_rubygems_version: !ruby/object:Gem::Requirement
100
133
  requirements:
101
- - - ! '>='
134
+ - - ">="
102
135
  - !ruby/object:Gem::Version
103
136
  version: '0'
104
- none: false
105
137
  requirements: []
106
138
  rubyforge_project:
107
- rubygems_version: 1.8.23
139
+ rubygems_version: 2.2.2
108
140
  signing_key:
109
- specification_version: 3
141
+ specification_version: 4
110
142
  summary: Shotgun-like Guard for Rack apps
111
143
  test_files:
144
+ - spec/dummy_app/.DS_Store
145
+ - spec/dummy_app/.ruby-version
146
+ - spec/dummy_app/Gemfile
147
+ - spec/dummy_app/Gemfile.lock
148
+ - spec/dummy_app/Guardfile
149
+ - spec/dummy_app/Rakefile
150
+ - spec/dummy_app/app/base_app.rb
151
+ - spec/dummy_app/config.ru
152
+ - spec/dummy_app/config/boot.rb
112
153
  - spec/spec_helper.rb