guard-jammit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Pelle Braendgaard
1
+ Copyright (c) 2009-2012 Pelle Braendgaard, Michael Kessler
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,160 @@
1
+ # Guard::Jammit [![Build Status](https://secure.travis-ci.org/netzpirat/guard-jammit.png)](http://travis-ci.org/netzpirat/guard-jammit)
2
+
3
+ Guard::Jammit watches your assets to automatically package them using [Jammit](http://documentcloud.github.com/jammit/).
4
+
5
+ Tested on MRI Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest versions of JRuby and Rubinius.
6
+
7
+ If you have any questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
8
+ (irc.freenode.net).
9
+
10
+ ## Install
11
+
12
+ ### Guard and Guard::Jammit
13
+
14
+ The simplest way to install Guard is to use [Bundler](http://gembundler.com/).
15
+ Please make sure to have [Guard][] installed.
16
+
17
+ Add Guard::Jammit to your `Gemfile`:
18
+
19
+ ```ruby
20
+ group :development, :test do
21
+ gem 'guard-jammit'
22
+ end
23
+ ```
24
+
25
+ Add the default Guard::Jammit template to your `Guardfile` by running:
26
+
27
+ ```bash
28
+ $ guard init jammit
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Please read the [Guard usage documentation](https://github.com/guard/guard#readme).
34
+
35
+ ## Guardfile
36
+
37
+ Guard::Jammit can be adapted to all kind of projects. Please read the
38
+ [Guard documentation](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.
39
+
40
+ ```ruby
41
+ guard :jammit do
42
+ watch(%r{^public/javascripts/(.*)\.js$})
43
+ watch(%r{^public/stylesheets/(.*)\.css$})
44
+ end
45
+ ```
46
+
47
+ ## Options
48
+
49
+ There are many options that can customize Guard::Jammit to your needs. Options are simply supplied as hash when
50
+ defining the Guard in your `Guardfile`:
51
+
52
+ ```ruby
53
+ guard :jammit, :package_on_start => true, :notifications => :false do
54
+ ...
55
+ end
56
+ ```
57
+
58
+ ### General options
59
+
60
+ The general options configures the environment that is needed to run Guard::Jammit:
61
+
62
+ ```ruby
63
+ :config_path => 'assets.yml' # YAML configuration file to use for Jammit
64
+ # default: 'config/assets.yml'
65
+
66
+ :output_folder => '' # Overwrite to configured output folder
67
+ # default: nil
68
+
69
+ :base_url => 'http://www.site.com' # Base URL for building the MHTML stylesheets
70
+ # default: nil
71
+
72
+ :public_root => 'htdocs' # Overwrite to configured public root
73
+ # default: nil
74
+
75
+ :force => true # Force package generation.
76
+ # default: false
77
+
78
+ :package_names => [:admin, :deps] # The package names to package.
79
+ # default: nil
80
+ ```
81
+
82
+ ### Workflow options
83
+
84
+ The workflow options define how Guard::Jammit behaves on Guard states.
85
+
86
+ ```ruby
87
+ :package_on_start => true # Initial package when Guard starts
88
+ # default: false
89
+ ```
90
+
91
+ ### System notifications options
92
+
93
+ These options affects what system notifications (growl, libnotify or notifu) are shown after a spec run:
94
+
95
+ ```ruby
96
+ :notifications => false # Show success and error notifications.
97
+ # default: true
98
+
99
+ :hide_success => true # Disable successful package run notification.
100
+ # default: false
101
+ ```
102
+
103
+ ## Issues
104
+
105
+ You can report issues and feature requests to [GitHub Issues](https://github.com/netzpirat/guard-jammit/issues). Try to figure out
106
+ where the issue belongs to: Is it an issue with Guard itself or with Guard::Jammit? Please don't
107
+ ask question in the issue tracker, instead join us in our [Google group](http://groups.google.com/group/guard-dev) or on
108
+ `#guard` (irc.freenode.net).
109
+
110
+ When you file an issue, please try to follow to these simple rules if applicable:
111
+
112
+ * Make sure you run Guard with `bundle exec` first.
113
+ * Add debug information to the issue by running Guard with the `--verbose` option.
114
+ * Add your `Guardfile` and `Gemfile` to the issue.
115
+ * Make sure that the issue is reproducible with your description.
116
+
117
+ ## Development
118
+
119
+ - Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard-jammit/master/frames).
120
+ - Source hosted at [GitHub](https://github.com/netzpirat/guard-jammit).
121
+
122
+ Pull requests are very welcome! Please try to follow these simple rules if applicable:
123
+
124
+ * Please create a topic branch for every separate change you make.
125
+ * Make sure your patches are well tested.
126
+ * Update the [Yard](http://yardoc.org/) documentation.
127
+ * Update the README.
128
+ * Please **do not change** the version number.
129
+
130
+ For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
131
+ `#guard` (irc.freenode.net).
132
+
133
+ ## Contributors
134
+
135
+ * [John Bintz](https://github.com/johnbintz)
136
+
137
+ ## License
138
+
139
+ (The MIT License)
140
+
141
+ Copyright (c) 2009-2012 Pelle Braendgaard, Michael Kessler
142
+
143
+ Permission is hereby granted, free of charge, to any person obtaining
144
+ a copy of this software and associated documentation files (the
145
+ 'Software'), to deal in the Software without restriction, including
146
+ without limitation the rights to use, copy, modify, merge, publish,
147
+ distribute, sublicense, and/or sell copies of the Software, and to
148
+ permit persons to whom the Software is furnished to do so, subject to
149
+ the following conditions:
150
+
151
+ The above copyright notice and this permission notice shall be
152
+ included in all copies or substantial portions of the Software.
153
+
154
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
155
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
156
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
157
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
158
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
159
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
160
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,63 +1,99 @@
1
1
  require 'guard'
2
2
  require 'guard/guard'
3
3
  require 'jammit'
4
+
4
5
  module Guard
6
+
7
+ # The Jammit Guard that gets notifications about the following
8
+ # Guard events: `start`, `stop`, `reload`, `run_all` and `run_on_change`.
9
+ #
5
10
  class Jammit < Guard
6
11
 
12
+ DEFAULT_OPTIONS = {
13
+ :config_path => ::Jammit::DEFAULT_CONFIG_PATH,
14
+ :output_folder => nil,
15
+ :base_url => nil,
16
+ :public_root => nil,
17
+ :force => false,
18
+ :package_names => nil,
19
+ :package_on_start => true,
20
+ :notification => true,
21
+ :hide_success => false
22
+ }
23
+
24
+ # Initialize Guard::Jammit.
25
+ #
26
+ # @param [Array<Guard::Watcher>] watchers the watchers in the Guard block
27
+ # @param [Hash] options the options for the Guard
28
+ # @option options [String] :output_folder the output folder
29
+ # @option options [String] :base_url the base URL for the MHTML stylesheet
30
+ # @option options [String] :public_root the public root folder
31
+ # @option options [Boolean] :force force packaging
32
+ # @option options [Array<String>] package_names the package names to package
33
+ # @option options [Boolean] :package_on_start package when Guard starts
34
+ # @option options [Boolean] :notification show notifications
35
+ # @option options [Boolean] :hide_success hide success message notification
36
+ #
7
37
  def initialize(watchers = [], options = {})
8
- super
9
- @options.merge(options)
38
+ options = DEFAULT_OPTIONS.merge(options)
39
+ super(watchers, options)
10
40
  end
11
41
 
12
- # ================
13
- # = Guard method =
14
- # ================
15
-
16
- # If one of those methods raise an exception, the Guard instance
17
- # will be removed from the active guard.
18
-
19
- # Call once when guard starts
20
- # Please override initialize method to init stuff
42
+ # Gets called once when Guard starts.
43
+ #
44
+ # @raise [:task_has_failed] when run_on_change has failed
45
+ #
21
46
  def start
22
- jammit
23
- end
47
+ ensure_rails_env!
24
48
 
25
- # Call with Ctrl-C signal (when Guard quit)
26
- def stop
27
- true
28
- end
49
+ ::Guard::UI.info "Using Jammit version #{::Jammit::VERSION}"
29
50
 
30
- # Call with Ctrl-Z signal
31
- # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
32
- def reload
33
- jammit
51
+ jammit if @options[:package_on_start]
34
52
  end
35
53
 
36
- # Call with Ctrl-/ signal
37
- # This method should be principally used for long action like running all specs/tests/...
54
+ # Gets called when all files should be packaged.
55
+ #
56
+ # @raise [:task_has_failed] when run_on_change has failed
57
+ #
38
58
  def run_all
39
59
  jammit
40
60
  end
41
61
 
42
- # Call on file(s) modifications
62
+ # Gets called when watched paths and files have changes.
63
+ #
64
+ # @param [Array<String>] paths the changed paths and files
65
+ # @raise [:task_has_failed] when run_on_change has failed
66
+ #
43
67
  def run_on_change(paths)
44
68
  jammit
45
69
  end
46
70
 
71
+ # Runs Jammit to package the assets
72
+ #
47
73
  def jammit
48
74
  begin
49
- ::Jammit.load_configuration @options[:config] || ::Jammit::DEFAULT_CONFIG_PATH
50
- ::Guard::UI.info("Jamming #{@options[:config]}")
51
- ::Guard::Notifier.notify("Jamming #{@options[:config]}", :title => 'Jammit')
52
- ::Jammit.packager.force = false
53
- ::Jammit.packager.precache_all
54
- true
75
+ Thread.current[:jammit_packager] = nil
76
+
77
+ ::Jammit.package! @options
78
+
79
+ ::Guard::UI.info 'Jammit successfull packaged the assets.'
80
+ ::Guard::Notifier.notify('Jammit successfull packaged the assets.', :title => 'Jammit') if @options[:notification] && !@options[:hide_success]
81
+
55
82
  rescue Exception => e
56
- ::Guard::UI.error("Jammit failed (#{e})")
57
- ::Guard::Notifier.notify('Jammit failed', :title => 'Jammit', :image => :failed)
58
- false
83
+ ::Guard::UI.error("Jammit failed to package the assets: #{e.message}")
84
+ ::Guard::Notifier.notify('Jammit failed to package the assets.', :title => 'Jammit', :image => :failed) if @options[:notification]
85
+ end
86
+ end
87
+
88
+ private
89
+
90
+ # Ensures that Rails env is available when Rails is only partially loaded
91
+ #
92
+ def ensure_rails_env!
93
+ if defined?(::Rails) && !::Rails.respond_to?(:env)
94
+ require 'rails'
59
95
  end
60
96
  end
61
97
 
62
98
  end
63
- end
99
+ end
@@ -1,4 +1,4 @@
1
- guard 'jammit' do
2
- watch(/^public\/javascripts\/(.*)\.js/)
3
- watch(/^public\/stylesheets\/(.*)\.css/)
1
+ guard :jammit do
2
+ watch(%r{^public/javascripts/(.*)\.js$})
3
+ watch(%r{^public/stylesheets/(.*)\.css$})
4
4
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
- module Jammit
3
- VERSION = "0.2.0"
2
+ module JammitVersion
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,86 +1,152 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: guard-jammit
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
4
5
  prerelease:
5
- version: 0.2.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Pelle Braendgaard
9
+ - Michael Kessler
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
-
13
- date: 2011-08-24 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
13
+ date: 2012-01-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: guard
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70303456951120 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.3
24
23
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: jammit
28
24
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70303456951120
26
+ - !ruby/object:Gem::Dependency
27
+ name: jammit
28
+ requirement: &70303456950600 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
35
34
  type: :runtime
36
- version_requirements: *id002
37
- description: This is a guard plugin to watch javascript and stylesheets to afterwards run jammit.
38
- email:
35
+ prerelease: false
36
+ version_requirements: *70303456950600
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: &70303456950060 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: '1.0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70303456950060
48
+ - !ruby/object:Gem::Dependency
49
+ name: guard-rspec
50
+ requirement: &70303456949540 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '0.6'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70303456949540
59
+ - !ruby/object:Gem::Dependency
60
+ name: rspec
61
+ requirement: &70303456949040 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: '2.8'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *70303456949040
70
+ - !ruby/object:Gem::Dependency
71
+ name: yard
72
+ requirement: &70303456948660 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *70303456948660
81
+ - !ruby/object:Gem::Dependency
82
+ name: redcarpet
83
+ requirement: &70303456948040 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *70303456948040
92
+ - !ruby/object:Gem::Dependency
93
+ name: pry
94
+ requirement: &70303456947440 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *70303456947440
103
+ - !ruby/object:Gem::Dependency
104
+ name: rake
105
+ requirement: &70303456946880 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: *70303456946880
114
+ description: Watches your assets to automatically package them using Jammit.
115
+ email:
39
116
  - pelle@stakeventures.com
117
+ - michi@netzpiraten.ch
40
118
  executables: []
41
-
42
119
  extensions: []
43
-
44
120
  extra_rdoc_files: []
45
-
46
- files:
47
- - .document
48
- - .gitignore
49
- - Gemfile
50
- - Gemfile.lock
51
- - LICENSE
52
- - README.textile
53
- - Rakefile
54
- - guard-jammit.gemspec
55
- - lib/guard/jammit.rb
121
+ files:
56
122
  - lib/guard/jammit/templates/Guardfile
57
123
  - lib/guard/jammit/version.rb
124
+ - lib/guard/jammit.rb
125
+ - LICENSE
126
+ - README.md
58
127
  homepage: http://github.com/guard/guard-jammit
59
128
  licenses: []
60
-
61
129
  post_install_message:
62
130
  rdoc_options: []
63
-
64
- require_paths:
131
+ require_paths:
65
132
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
133
+ required_ruby_version: !ruby/object:Gem::Requirement
67
134
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: "0"
72
- required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
140
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: 1.3.6
78
145
  requirements: []
79
-
80
146
  rubyforge_project: guard-jammit
81
- rubygems_version: 1.8.5
147
+ rubygems_version: 1.8.10
82
148
  signing_key:
83
149
  specification_version: 3
84
150
  summary: Guard plugin for Jammit
85
151
  test_files: []
86
-
152
+ has_rdoc:
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in guard-jammit.gemspec
4
- gemspec
@@ -1,28 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- guard-jammit (0.2.0)
5
- guard
6
- jammit
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- POpen4 (0.1.4)
12
- Platform (>= 0.4.0)
13
- open4
14
- Platform (0.4.0)
15
- guard (0.6.2)
16
- thor (~> 0.14.6)
17
- jammit (0.6.3)
18
- yui-compressor (>= 0.9.3)
19
- open4 (1.1.0)
20
- thor (0.14.6)
21
- yui-compressor (0.9.6)
22
- POpen4 (>= 0.1.4)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- guard-jammit!
@@ -1,19 +0,0 @@
1
- h1. Guard Jammit Plug-in
2
-
3
- Let you configure a Guard that will run jammit whenever a javascript or stylesheet is updated.
4
-
5
- h2. Quick Start
6
-
7
- Edit the Gemfile for it to looks like:
8
-
9
- bc. source "http://rubygems.org"
10
- gem 'guard-jammit'
11
-
12
- You can now download missing gems and initialize the guard
13
-
14
- bc. $ bundle install
15
- $ guard init
16
- $ guard init jammit
17
- $ guard
18
-
19
-
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require 'bundler/gem_tasks'
@@ -1,37 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "guard/jammit/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "guard-jammit"
7
- s.version = Guard::Jammit::VERSION
8
- s.authors = ["Pelle Braendgaard"]
9
- s.email = ["pelle@stakeventures.com"]
10
- s.homepage = %q{http://github.com/guard/guard-jammit}
11
- s.summary = %q{Guard plugin for Jammit}
12
- s.description = %q{This is a guard plugin to watch javascript and stylesheets to afterwards run jammit.}
13
-
14
- s.rubyforge_project = "guard-jammit"
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
-
21
- if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
- s.specification_version = 3
24
-
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<guard>, [">= 0"])
27
- s.add_runtime_dependency(%q<jammit>, [">= 0"])
28
- else
29
- s.add_dependency(%q<guard>, [">= 0"])
30
- s.add_dependency(%q<jammit>, [">= 0"])
31
- end
32
- else
33
- s.add_dependency(%q<guard>, [">= 0"])
34
- s.add_dependency(%q<jammit>, [">= 0"])
35
- end
36
-
37
- end