Skip to content

Commit

Permalink
Refactored guard-jammit.
Browse files Browse the repository at this point in the history
This refactoring adds:

* Non cached Jammit packager
* Multiple new Jammit options
* RSpec test suite with Travis config
* Comprehensive README
* Yardoc
* Guardfile and Rakefile for testing
  • Loading branch information
netzpirat committed Jan 9, 2012
1 parent abeb2a1 commit ead5ba4
Show file tree
Hide file tree
Showing 18 changed files with 580 additions and 124 deletions.
5 changes: 0 additions & 5 deletions .document

This file was deleted.

14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
pkg/*
*.gem
*.rbc
.bundle
.rbx
.yardoc
doc
Gemfile.lock

## MAC OS
.DS_Store
.Trashes
.com.apple.timemachine.supported
.fseventsd
Desktop DB
Desktop DF

## TEXTMATE
*.tmproj
Expand Down
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm use 1.9.3
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- ree
- rbx
- jruby
8 changes: 8 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--readme README.md
--markup markdown
--markup-provider redcarpet
--title 'Guard::Jammit Documentation'
--hide-void-return
--protected
--private
lib/**/*.rb
18 changes: 16 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
source "http://rubygems.org"
source :rubygems

# Specify your gem's dependencies in guard-jammit.gemspec
gemspec

platform :ruby do
gem 'rb-readline'
end

require 'rbconfig'

if RbConfig::CONFIG['target_os'] =~ /darwin/i
gem 'ruby_gntp', '~> 0.3.4', :require => false
elsif RbConfig::CONFIG['target_os'] =~ /linux/i
gem 'libnotify', '~> 0.7.1', :require => false
elsif RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
gem 'win32console', :require => false
gem 'rb-notifu', '>= 0.0.4', :require => false
end
28 changes: 0 additions & 28 deletions Gemfile.lock

This file was deleted.

5 changes: 5 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
guard 'rspec', :rvm => ['1.8.7', '1.9.3'] do
watch('spec/spec_helper.rb') { 'spec' }
watch(%r{spec/.+_spec.rb})
watch(%r{lib/(.+).rb}) { |m| "spec/#{ m[1] }_spec.rb" }
end
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009 Pelle Braendgaard
Copyright (c) 2009-2012 Pelle Braendgaard, Michael Kessler

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
160 changes: 160 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Guard::Jammit [![Build Status](https://secure.travis-ci.org/netzpirat/guard-jammit.png)](http://travis-ci.org/netzpirat/guard-jammit)

Guard::Jammit watches your assets to automatically package them using [Jammit](http://documentcloud.github.com/jammit/).

Tested on MRI Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest versions of JRuby and Rubinius.

If you have any questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
(irc.freenode.net).

## Install

### Guard and Guard::Jammit

The simplest way to install Guard is to use [Bundler](http://gembundler.com/).
Please make sure to have [Guard][] installed.

Add Guard::Jammit to your `Gemfile`:

```ruby
group :development, :test do
gem 'guard-jammit'
end
```

Add the default Guard::Jammit template to your `Guardfile` by running:

```bash
$ guard init jammit
```

## Usage

Please read the [Guard usage documentation](https://github.com/guard/guard#readme).

## Guardfile

Guard::Jammit can be adapted to all kind of projects. Please read the
[Guard documentation](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.

```ruby
guard :jammit do
watch(%r{^public/javascripts/(.*)\.js$})
watch(%r{^public/stylesheets/(.*)\.css$})
end
```

## Options

There are many options that can customize Guard::Jammit to your needs. Options are simply supplied as hash when
defining the Guard in your `Guardfile`:

```ruby
guard :jammit, :package_on_start => true, :notifications => :false do
...
end
```

### General options

The general options configures the environment that is needed to run Guard::Jammit:

```ruby
:config_path => 'assets.yml' # YAML configuration file to use for Jammit
# default: 'config/assets.yml'

:output_folder => '' # Overwrite to configured output folder
# default: nil

:base_url => 'http://www.site.com' # Base URL for building the MHTML stylesheets
# default: nil

:public_root => 'htdocs' # Overwrite to configured public root
# default: nil

:force => true # Force package generation.
# default: false

:package_names => [:admin, :deps] # The package names to package.
# default: nil
```

### Workflow options

The workflow options define how Guard::Jammit behaves on Guard states.

```ruby
:package_on_start => true # Initial package when Guard starts
# default: false
```

### System notifications options

These options affects what system notifications (growl, libnotify or notifu) are shown after a spec run:

```ruby
:notifications => false # Show success and error notifications.
# default: true

:hide_success => true # Disable successful package run notification.
# default: false
```

## Issues

You can report issues and feature requests to [GitHub Issues](https://github.com/netzpirat/guard-jammit/issues). Try to figure out
where the issue belongs to: Is it an issue with Guard itself or with Guard::Jammit? Please don't
ask question in the issue tracker, instead join us in our [Google group](http://groups.google.com/group/guard-dev) or on
`#guard` (irc.freenode.net).

When you file an issue, please try to follow to these simple rules if applicable:

* Make sure you run Guard with `bundle exec` first.
* Add debug information to the issue by running Guard with the `--verbose` option.
* Add your `Guardfile` and `Gemfile` to the issue.
* Make sure that the issue is reproducible with your description.

## Development

- Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard-jammit/master/frames).
- Source hosted at [GitHub](https://github.com/netzpirat/guard-jammit).

Pull requests are very welcome! Please try to follow these simple rules if applicable:

* Please create a topic branch for every separate change you make.
* Make sure your patches are well tested.
* Update the [Yard](http://yardoc.org/) documentation.
* Update the README.
* Please **do not change** the version number.

For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
`#guard` (irc.freenode.net).

## Contributors

* [John Bintz](https://github.com/johnbintz)

## License

(The MIT License)

Copyright (c) 2009-2012 Pelle Braendgaard, Michael Kessler

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 0 additions & 19 deletions README.textile

This file was deleted.

36 changes: 35 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
require 'bundler/gem_tasks'
require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec

namespace(:spec) do
desc "Run all specs on multiple ruby versions (requires rvm)"
task(:portability) do
travis_config_file = File.expand_path("../.travis.yml", __FILE__)
begin
travis_options ||= YAML::load_file(travis_config_file)
rescue => ex
puts "Travis config file '#{travis_config_file}' could not be found: #{ex.message}"
return
end

travis_options['rvm'].each do |version|
system <<-BASH
bash -c 'source ~/.rvm/scripts/rvm;
rvm #{version};
ruby_version_string_size=`ruby -v | wc -m`
echo;
for ((c=1; c<$ruby_version_string_size; c++)); do echo -n "="; done
echo;
echo "`ruby -v`";
for ((c=1; c<$ruby_version_string_size; c++)); do echo -n "="; done
echo;
RBXOPT="-Xrbc.db" bundle install;
RBXOPT="-Xrbc.db" bundle exec rspec spec -f doc 2>&1;'
BASH
end
end
end
46 changes: 19 additions & 27 deletions guard-jammit.gemspec
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "guard/jammit/version"
$:.push File.expand_path('../lib', __FILE__)
require 'guard/jammit/version'

Gem::Specification.new do |s|
s.name = "guard-jammit"
s.version = Guard::Jammit::VERSION
s.authors = ["Pelle Braendgaard"]
s.email = ["pelle@stakeventures.com"]
s.name = 'guard-jammit'
s.version = Guard::JammitVersion::VERSION
s.authors = ['Pelle Braendgaard', 'Michael Kessler']
s.email = ['pelle@stakeventures.com', 'michi@netzpiraten.ch']
s.homepage = %q{http://github.com/guard/guard-jammit}
s.summary = %q{Guard plugin for Jammit}
s.description = %q{This is a guard plugin to watch javascript and stylesheets to afterwards run jammit.}
s.description = %q{Watches your assets to automatically package them using Jammit.}

s.rubyforge_project = "guard-jammit"
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = 'guard-jammit'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_dependency 'guard', '>= 0.8.3'
s.add_dependency 'jammit'

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<guard>, [">= 0"])
s.add_runtime_dependency(%q<jammit>, [">= 0"])
else
s.add_dependency(%q<guard>, [">= 0"])
s.add_dependency(%q<jammit>, [">= 0"])
end
else
s.add_dependency(%q<guard>, [">= 0"])
s.add_dependency(%q<jammit>, [">= 0"])
end
s.add_development_dependency 'bundler', '~> 1.0'
s.add_development_dependency 'guard-rspec', '~> 0.6'
s.add_development_dependency 'rspec', '~> 2.8'
s.add_development_dependency 'yard'
s.add_development_dependency 'redcarpet'
s.add_development_dependency 'pry'

s.files = Dir.glob('{lib}/**/*') + %w[LICENSE README.md]
s.require_path = 'lib'
end
Loading

0 comments on commit ead5ba4

Please sign in to comment.