guard-erb 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -18,7 +18,11 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Please read [Guard usage doc](https://github.com/guard/guard#readme).
21
+ Nested erb support via the import method
22
+ ```eruby
23
+ <%= import('erbfile.html.erb', { foo: bar }) %>
24
+ ```
25
+ For guard usage please read [Guard usage doc](https://github.com/guard/guard#readme).
22
26
 
23
27
  ## Guardfile
24
28
 
@@ -1,9 +1,11 @@
1
1
  require 'guard'
2
2
  require 'guard/guard'
3
3
  require 'erb'
4
+ require 'struct_erb'
4
5
 
5
6
  module Guard
6
7
  class Erb < Guard
8
+
7
9
  def initialize(watchers=[], options={})
8
10
  @input = options[:input]
9
11
  @output = options[:output]
@@ -22,14 +24,14 @@ module Guard
22
24
  compile
23
25
  end
24
26
 
25
- def run_on_change(paths)
27
+ def run_on_changes(paths)
26
28
  compile
27
29
  end
28
30
 
29
31
  private
30
- def import(file)
31
- UI.info "importing erb file #{file}"
32
- ::ERB.new(File.read(file)).result(binding)
32
+
33
+ def import(file, locals={})
34
+ ::StructErb.new(locals).render(File.read(file))
33
35
  end
34
36
 
35
37
  def compile
@@ -47,4 +49,5 @@ module Guard
47
49
  end
48
50
  end
49
51
  end
52
+
50
53
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module ErbVersion
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,14 @@
1
+ require 'erb'
2
+ require 'ostruct'
3
+
4
+ class StructErb < OpenStruct
5
+
6
+ def import(file, locals={})
7
+ ::StructErb.new(locals).render(File.read(file))
8
+ end
9
+
10
+ def render(template)
11
+ ::ERB.new(template).result(binding)
12
+ end
13
+
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-erb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-17 00:00:00.000000000 Z
12
+ date: 2014-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70278705907900 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 0.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70278705907900
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.2
25
30
  description: guard-erb automatically compiles a erb file into the specified directory
26
31
  email:
27
32
  - omar@digitaltree.com
@@ -35,9 +40,10 @@ files:
35
40
  - README.md
36
41
  - Rakefile
37
42
  - guard-erb.gemspec
38
- - lib/guard/erb-guard/Guardfile
39
43
  - lib/guard/erb.rb
44
+ - lib/guard/erb/templates/Guardfile
40
45
  - lib/guard/version.rb
46
+ - lib/struct_erb.rb
41
47
  homepage: https://github.com/omarramos/guard-erb
42
48
  licenses: []
43
49
  post_install_message:
@@ -58,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
64
  version: '0'
59
65
  requirements: []
60
66
  rubyforge_project:
61
- rubygems_version: 1.8.11
67
+ rubygems_version: 1.8.23
62
68
  signing_key:
63
69
  specification_version: 3
64
70
  summary: Guard for compiling erb files