guard-erb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in guard-erb.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 TODO: Write your name
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,37 @@
1
+ # Guard::Erb
2
+
3
+ A guard extension that compiles .erb files
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'guard-erb'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install guard-erb
18
+
19
+ ## Usage
20
+
21
+ Please read [Guard usage doc](https://github.com/guard/guard#readme).
22
+
23
+ ## Guardfile
24
+
25
+ ```ruby
26
+ guard 'erb', :input => 'app/views/index.html.erb', :output => "public/index.html" do
27
+ watch (%r{app/views/index.html.erb})
28
+ end
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/guard-erb.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/guard/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Omar Ramos"]
6
+ gem.version = Guard::ErbVersion::VERSION
7
+ gem.email = ["omar@digitaltree.com"]
8
+ gem.description = %q{guard-erb automatically compiles a erb file into the specified directory}
9
+ gem.summary = %q{Guard for compiling erb files}
10
+ gem.homepage = "https://github.com/omarramos/guard-erb"
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "guard-erb"
16
+ gem.require_paths = ["lib"]
17
+
18
+ gem.add_dependency 'guard', '>= 0.2.2'
19
+ end
@@ -0,0 +1,3 @@
1
+ guard 'erb', :input => 'app/views/index.html.erb', :output => "public/index.html" do
2
+ watch (%r{app/views/index.html.erb})
3
+ end
data/lib/guard/erb.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'erb'
4
+
5
+ module Guard
6
+ class Erb < Guard
7
+ def initialize(watchers=[], options={})
8
+ @input = options[:input]
9
+ @output = options[:output]
10
+ super(watchers, options)
11
+ end
12
+
13
+ def start
14
+ compile
15
+ end
16
+
17
+ def reload
18
+ compile
19
+ end
20
+
21
+ def run_all
22
+ compile
23
+ end
24
+
25
+ def run_on_change(paths)
26
+ compile
27
+ end
28
+
29
+ private
30
+ def import(file)
31
+ UI.info "importing erb file #{file}"
32
+ ::ERB.new(File.read(file)).result(binding)
33
+ end
34
+
35
+ def compile
36
+ begin
37
+ template = import(@input)
38
+ File.open(@output,'w'){ |f| f.write(template) }
39
+ UI.info "Compiling #{@input} to #{@output}"
40
+ Notifier.notify "Compiling #{@input} to #{@output}", :title => 'Erb'
41
+ UI.info "Compiled #{@output}"
42
+ true
43
+ rescue Exception => e
44
+ UI.error "Compiling #{@input} failed: #{e}"
45
+ Notifier.notify "Compiling #{@input} failed: #{e}", :title => 'Erb', :image => :failed
46
+ false
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module ErbVersion
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-erb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Omar Ramos
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: guard
16
+ requirement: &70278705907900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70278705907900
25
+ description: guard-erb automatically compiles a erb file into the specified directory
26
+ email:
27
+ - omar@digitaltree.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - guard-erb.gemspec
38
+ - lib/guard/erb-guard/Guardfile
39
+ - lib/guard/erb.rb
40
+ - lib/guard/version.rb
41
+ homepage: https://github.com/omarramos/guard-erb
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.11
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Guard for compiling erb files
65
+ test_files: []