smartgen 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.5.1
2
+ -----
3
+
4
+ * Smartgen::ObjectHash is used as default value for metadata parameter when rendering files
5
+ * Forcing exit when user press CTRL+C when Watcher is running.
6
+
1
7
  0.5.0
2
8
  -----
3
9
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smartgen (0.5.0)
4
+ smartgen (0.5.1)
5
5
  RedCloth (= 4.2.3)
6
6
  activesupport (>= 2.3.5)
7
7
  bluecloth (>= 2.0.9)
@@ -5,7 +5,7 @@ module Smartgen
5
5
  # Renders the markup file using the given layout.
6
6
  #
7
7
  # It exposes +markup_file+ variable and its +metadata+ to the ERB layout.
8
- def render(layout, markup_file, metadata={})
8
+ def render(layout, markup_file, metadata=Smartgen::ObjectHash.new)
9
9
  ::ERB.new(layout).result(binding)
10
10
  end
11
11
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Smartgen
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
@@ -69,6 +69,7 @@ module Smartgen
69
69
  Kernel.trap 'INT' do
70
70
  puts "Stopping watcher..."
71
71
  directory_watcher.stop
72
+ Kernel.exit 0
72
73
  end
73
74
  end
74
75
  end
@@ -26,7 +26,7 @@ describe Smartgen::ObjectHash do
26
26
  should respond_to(key)
27
27
  end
28
28
  end
29
-
29
+
30
30
  describe "inexistent key" do
31
31
  it "should not respond to" do
32
32
  capture(:stderr) { subject.should_not respond_to("invalid_key") }
@@ -15,6 +15,12 @@ describe Smartgen::Renderer::ERB do
15
15
  subject.render(layout, markup_file).should == "<html><body>#{contents}</body></html>"
16
16
  end
17
17
 
18
+ it "should render the given layout without setting metadata, but using methods to access metadata in template" do
19
+ layout = "<html><body><%= markup_file.contents %><div><%= metadata.some_key %></div></body></html>"
20
+
21
+ capture(:stderr) { subject.render(layout, markup_file).should == "<html><body>#{contents}<div>{}</div></body></html>" }
22
+ end
23
+
18
24
  it "should render the given layout with metadata variable" do
19
25
  layout = "<html><body><%= markup_file.contents %><div><%= metadata[:some_key] %></div></body></html>"
20
26
  subject.render(layout, markup_file, Smartgen::ObjectHash.new(:some_key => 'some_value')).should == "<html><body>#{contents}<div>some_value</div></body></html>"
@@ -63,6 +63,7 @@ describe Smartgen::Watcher do
63
63
  context "when user hits ctrl+c" do
64
64
  it "should exit gracefully" do
65
65
  directory_watcher.should_receive(:stop)
66
+ Kernel.should_receive(:exit).with(0)
66
67
  Kernel.should_receive(:trap).with('INT').and_yield
67
68
  capture(:stdout) { subject.start }
68
69
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 0
9
- version: 0.5.0
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Vicente Mundim
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-13 00:00:00 -02:00
17
+ date: 2011-03-02 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency