guard-webpack 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a4a9dc38f4b5e0f4ae340f2bf01c2f40600d096
4
- data.tar.gz: e5d4065c06faa6ffbe6daf6aa9494ce7676eb6f7
3
+ metadata.gz: d8b235e14f3e29416722eb385c9a1b8738ca13a2
4
+ data.tar.gz: 0fad6068220f49408ca76983cc2d1eff649fabe8
5
5
  SHA512:
6
- metadata.gz: 355a4338c74e28bcbd35acad4196379105790815f5d1b4d0ffb9e4a2c3c770a2254cb373451b3fbfbd7b0e16c2e9d50879a358cee9ce9b872fa448e6169bf325
7
- data.tar.gz: bf35deede585e99961808223e8e43539fcb2f2cf56f0cea52c2968988064b91d6ca35e2838206db7a1843a1b4175db8eecfa970b5cdfca19aec31aba6d2018a2
6
+ metadata.gz: a4208130ddae1e6c265c97492e99630f3a28da88d76ff0153f8e6046efa520ecc44ee0e33a52e487b38fd3927dc1657dda8d5c3c9acbca8c9f46823b963941d6
7
+ data.tar.gz: 43191e2d12702c3747c2de4c7517284eec699904e2c1c578869be65490c6a7c8e3a62d2019cf1a2c6a228da4bdcbe8c79d13e73aa340cd54816ab13ed77c8378
data/README.md CHANGED
@@ -43,6 +43,10 @@ colors: true # use colors in displaying webpack output, default: true
43
43
  progress: true # display a progress bar for long compiles, default: true
44
44
  ```
45
45
 
46
+ ## Notes on Guard 1.x
47
+
48
+ Guard::Webpack strives to support older versions of Guard (including the `Guard::Guard`, rather than `Guard::Plugin` syntax. However, support may be limited. Options, as specified above, are not supported for versions of Guard below 2.0.
49
+
46
50
  ## Contributing
47
51
 
48
52
  1. Fork it ( https://github.com/gisikw/guard-webpack/fork )
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_runtime_dependency 'guard', '~> 2.0'
20
+ spec.add_runtime_dependency 'guard', '< 3.0'
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.6"
23
23
  spec.add_development_dependency "rake"
data/lib/guard/webpack.rb CHANGED
@@ -1,8 +1,7 @@
1
- require 'guard/webpack/version'
2
- require 'guard/webpack/runner'
3
-
4
1
  module Guard
5
- class Webpack < Guard::Plugin
2
+ class Webpack < ::Guard.const_get(::Guard.const_defined?(:Plugin) ? :Plugin : :Guard)
3
+ require 'guard/webpack/version'
4
+ require 'guard/webpack/runner'
6
5
 
7
6
  DEFAULT_OPTIONS = {
8
7
  progress: true,
@@ -11,10 +10,11 @@ module Guard
11
10
 
12
11
  attr_accessor :runner
13
12
 
14
- def initialize(options = {})
15
- with_defaults(options) do |opts|
13
+ def initialize(*args)
14
+ with_defaults(args[-1]) do |opts|
16
15
  super(opts)
17
16
  @runner = Runner.new(opts)
17
+ @runner.start
18
18
  end
19
19
  end
20
20
 
@@ -1,76 +1,71 @@
1
- module Guard
2
- class Webpack < Plugin
3
- class Runner
1
+ class Guard::Webpack::Runner
2
+ attr_accessor :options, :thread
4
3
 
5
- attr_accessor :options, :thread
6
-
7
- def initialize(options)
8
- @options = options
9
- end
10
-
11
- def restart; stop; start; end
4
+ def initialize(options)
5
+ @options = options
6
+ end
12
7
 
13
- def start
14
- unless_running do
15
- @thread = Thread.new { run_webpack }
16
- ::Guard::UI.info "Webpack watcher started."
17
- end
18
- end
8
+ def restart; stop; start; end
19
9
 
20
- def stop
21
- if_running do
22
- @thread.kill
23
- ::Guard::UI.info "Webpack watcher stopped."
24
- end
25
- end
10
+ def start
11
+ unless_running do
12
+ @thread = Thread.new { run_webpack }
13
+ ::Guard::UI.info "Webpack watcher started."
14
+ end
15
+ end
26
16
 
27
- private
17
+ def stop
18
+ if_running do
19
+ @thread.kill
20
+ ::Guard::UI.info "Webpack watcher stopped."
21
+ end
22
+ end
28
23
 
29
- def local_webpack
30
- bin = File.join(Dir.pwd,'node_modules/webpack/bin/webpack.js')
31
- File.exists?(bin) && bin
32
- end
24
+ private
33
25
 
34
- def global_webpack
35
- system("command -v webpack >/dev/null") && 'webpack'
36
- end
26
+ def local_webpack
27
+ bin = File.join(Dir.pwd,'node_modules/webpack/bin/webpack.js')
28
+ File.exists?(bin) && bin
29
+ end
37
30
 
38
- def no_webpack
39
- # TODO: This is a bad error.
40
- raise 'Webpack binary not found'
41
- end
31
+ def global_webpack
32
+ system("command -v webpack >/dev/null") && 'webpack'
33
+ end
42
34
 
43
- def webpack_bin
44
- local_webpack || global_webpack || no_webpack
45
- end
35
+ def no_webpack
36
+ # TODO: This is a bad error.
37
+ raise 'Webpack binary not found'
38
+ end
46
39
 
47
- def option_flags
48
- output = ""
49
- output += " --colors" if @options[:colors]
50
- output += " --progress" if @options[:progress]
51
- output
52
- end
40
+ def webpack_bin
41
+ local_webpack || global_webpack || no_webpack
42
+ end
53
43
 
54
- def run_webpack
55
- begin
56
- pid = fork{ exec("#{webpack_bin} --watch #{option_flags}") }
57
- Process.wait(pid)
58
- rescue
59
- # TODO: Be more discerning.
60
- ::Guard::UI.error "Webpack unable to start (are you sure it's installed?)"
61
- ensure
62
- Process.kill('TERM',pid)
63
- end
64
- end
44
+ def option_flags
45
+ output = ""
46
+ output += " --colors" if @options[:colors]
47
+ output += " --progress" if @options[:progress]
48
+ output
49
+ end
65
50
 
66
- def unless_running
67
- yield if !@thread || !@thread.alive?
68
- end
51
+ def run_webpack
52
+ begin
53
+ pid = fork{ exec("#{webpack_bin} --watch #{option_flags}") }
54
+ Process.wait(pid)
55
+ rescue
56
+ # TODO: Be more discerning.
57
+ ::Guard::UI.error "Webpack unable to start (are you sure it's installed?)"
58
+ ensure
59
+ Process.kill('TERM',pid)
60
+ end
61
+ end
69
62
 
70
- def if_running
71
- yield if @thread && @thread.alive?
72
- end
63
+ def unless_running
64
+ yield if !@thread || !@thread.alive?
65
+ end
73
66
 
74
- end
67
+ def if_running
68
+ yield if @thread && @thread.alive?
75
69
  end
70
+
76
71
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module WebpackVersion
3
- VERSION = "0.0.2"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-webpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gisi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-14 00:00:00.000000000 Z
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement