guard-webpack 0.0.1

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: e984321951acdcfcdeb46bf89d3d563ccde10912
4
+ data.tar.gz: 705d86d89f5cbc14630b18397215f207d20b691f
5
+ SHA512:
6
+ metadata.gz: 539e551293774a9818b95acbfb81d9d2793d517a76188a1513ebad5081e35e6173f5b5d5450754a743b7f71f450703e3cdf776061900960edf5168310b346e94
7
+ data.tar.gz: a6665998071dd72c0218c167b8c2ff1731a2093e9b7986030b41c03fc58bbbcec9dda9119e22abeebf3a22140561815b875ca4ccafeec49ab8939291c6745293
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ *.swo
5
+ *.DS_Store*
6
+ .bundle
7
+ .config
8
+ .yardoc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
21
+ *.bundle
22
+ *.so
23
+ *.o
24
+ *.a
25
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in guard-webpack.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kevin Gisi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Guard::Webpack [![Gem Version](https://badge.fury.io/rb/guard-webpack.png)](http://badge.fury.io/rb/guard-webpack)
2
+
3
+ Guard::Webpack spins up a [Webpack](http://webpack.github.io) watcher in a background thread.
4
+
5
+ ## Installation
6
+
7
+ Please ensure you have [Guard](http://github.com/guard/guard) installed before you continue.
8
+
9
+ Add the following to your application's Gemfile:
10
+
11
+ group :development do
12
+ gem 'guard-webpack'
13
+ end
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Add Guard::Webpack to your Guardfile by running:
20
+
21
+ $ guard init webpack
22
+
23
+ ## Usage
24
+
25
+ Please refer to the [Guard usage doc](http://github.com/guard/guard#readme)
26
+
27
+ ## Example Guardfile
28
+
29
+ At present, Guard::Webpack assumes you already have Webpack configured via a `webpack.config.js` file. Please refer to [this Webpack tutorial](https://github.com/petehunt/webpack-howto) for help getting that configured.
30
+
31
+ You can, however, add additional options to your Guardfile, as seen below:
32
+
33
+ ```ruby
34
+ guard :webpack, colors: false
35
+ ```
36
+
37
+ ## Options
38
+
39
+ ### List of available options
40
+
41
+ ```ruby
42
+ colors: true # use colors in displaying webpack output, default: true
43
+ progress: true # display a progress bar for long compiles, default: true
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/gisikw/guard-webpack/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'guard/webpack/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "guard-webpack"
8
+ spec.version = Guard::WebpackVersion::VERSION
9
+ spec.authors = ["Kevin Gisi"]
10
+ spec.email = ["kevin@kevingisi.com"]
11
+ spec.summary = %q{Guard plugin for Webpack}
12
+ spec.homepage = "https://github.com/gisikw/guard-webpack"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency 'guard', '~> 2.0'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+
25
+ end
@@ -0,0 +1,34 @@
1
+ require 'guard/webpack/version'
2
+ require 'guard/webpack/runner'
3
+
4
+ module Guard
5
+ class Webpack < Guard::Plugin
6
+
7
+ DEFAULT_OPTIONS = {
8
+ progress: true,
9
+ colors: true
10
+ }
11
+
12
+ attr_accessor :runner
13
+
14
+ def initialize(options = {})
15
+ with_defaults(options) do |opts|
16
+ super(opts)
17
+ @runner = Runner.new(opts)
18
+ end
19
+ end
20
+
21
+ def run_on_modifications(p); @runner.restart; end
22
+ def run_all; @runner.restart; end
23
+ def reload; @runner.retart; end
24
+ def start; @runner.start; end
25
+ def stop; @runner.stop; end
26
+
27
+ private
28
+
29
+ def with_defaults(options)
30
+ yield DEFAULT_OPTIONS.merge(options)
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,73 @@
1
+ module Guard
2
+ class Webpack < Plugin
3
+ class Runner
4
+
5
+ attr_accessor :options, :thread
6
+
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
11
+ def restart; stop; start; end
12
+
13
+ def start
14
+ unless_running do
15
+ @thread = Thread.new { run_webpack }
16
+ ::Guard::UI.info "Webpack watcher started."
17
+ end
18
+ end
19
+
20
+ def stop
21
+ if_running do
22
+ @thread.kill
23
+ ::Guard::UI.info "Webpack watcher stopped."
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def local_webpack
30
+ bin = File.join(Dir.pwd,'node_modules/webpack/bin/webpack.js')
31
+ File.exists?(bin) && bin
32
+ end
33
+
34
+ def global_webpack
35
+ system("command -v webpack >/dev/null") && 'webpack'
36
+ end
37
+
38
+ def no_webpack
39
+ # TODO: This is a bad error.
40
+ raise 'Webpack binary not found'
41
+ end
42
+
43
+ def webpack_bin
44
+ local_webpack || global_webpack || no_webpack
45
+ end
46
+
47
+ def option_flags
48
+ output = ""
49
+ output += " --colors" if @options[:colors]
50
+ output += " --progress" if @options[:progress]
51
+ output
52
+ end
53
+
54
+ def run_webpack
55
+ begin
56
+ system("#{webpack_bin} --watch #{option_flags}")
57
+ rescue
58
+ # TODO: Be more discerning.
59
+ ::Guard::UI.error "Webpack unable to start (are you sure it's installed?)"
60
+ end
61
+ end
62
+
63
+ def unless_running
64
+ yield if !@thread || !@thread.alive?
65
+ end
66
+
67
+ def if_running
68
+ yield if @thread && @thread.alive?
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1 @@
1
+ guard :webpack
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module WebpackVersion
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-webpack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Gisi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: guard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - kevin@kevingisi.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - guard-webpack.gemspec
68
+ - lib/guard/webpack.rb
69
+ - lib/guard/webpack/runner.rb
70
+ - lib/guard/webpack/templates/Guardfile
71
+ - lib/guard/webpack/version.rb
72
+ homepage: https://github.com/gisikw/guard-webpack
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.5
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Guard plugin for Webpack
96
+ test_files: []