baby_erubis 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 168d382d8838cb51ab8a7d4965573adbf56426ff
4
- data.tar.gz: 446c12313a2cbc4c15d8373f69c99cea8b6503a6
3
+ metadata.gz: 7e3946547c49a8fd5ad9ad33de2b6d61165a0487
4
+ data.tar.gz: ff43eac6d25883186a8f8d988dc7fb4161971523
5
5
  SHA512:
6
- metadata.gz: fa2d86791075cc09060f7bc679cec2fba4aefb8f04b115bda1c8c87b7ecab6e5f63f3e6711a762e4ce37228bfe3bb935057de90084492f00c8b827e4853d74a5
7
- data.tar.gz: bf4cffef71cfc69d8145cf5539c734a675dd8456f709b24ef40bdc0ac6291ac49b31874e963dc21a0d7ad3feeb5d6de706b4d2d2527b1e31004782094923237f
6
+ metadata.gz: 60f8642bba8c12bebba15efed89be961768672adee6bc8b79217507fef598989b438811400521dad48986f38bff4ff908fdd9227fe5da39467ea6ac83121f92b
7
+ data.tar.gz: 11e3199d574a989877dfecef610b29328f951a0ccb8dba3165faf71a973c80c8e6b04d063cd572fa32fcda4a2b62facc8fb0c058d94c65e07045c32214aad04a
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2015 kuwata-lab.com
3
+ Copyright (c) 2014-2016 kuwata-lab.com
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  BabyErubis.rb
2
2
  =============
3
3
 
4
- $Release: 2.1.2 $
4
+ $Release: 2.2.0 $
5
5
 
6
6
  BabyErubis is an yet another eRuby implementation, based on Erubis.
7
7
 
@@ -226,7 +226,7 @@ because `BabyErubis/Renderer` module defines rendering methods:
226
226
  def index
227
227
  @items = ['A', 'B', 'C']
228
228
  ## renders 'templates/welcome.html.eruby'
229
- html = render_html(:welcome)
229
+ html = render_html(:index) # renders 'index.html.eruby'
230
230
  return html
231
231
  end
232
232
 
@@ -241,6 +241,15 @@ because `BabyErubis/Renderer` module defines rendering methods:
241
241
  * `eruby_render_text(template_name, layout: false, encoding: 'utf-8')` --
242
242
  renders plain template.
243
243
 
244
+ Template name can be Symbol or String:
245
+
246
+ html = render_html(:foo) # renders 'foo.html.eruby'
247
+ html = render_html("foo.html.eruby") # renders 'foo.html.eruby'
248
+
249
+ text = render_text(:foo) # renders 'foo.eruby'
250
+ text = render_text(:'foo.txt') # renders 'foo.txt.eruby'
251
+ text = render_text("foo.txt.eruby") # renders 'foo.txt.eruby'
252
+
244
253
  Layout template example:
245
254
 
246
255
  <%
@@ -430,6 +439,29 @@ Changes
430
439
  =======
431
440
 
432
441
 
442
+ Release 2.2.0 (2016-09-19)
443
+ --------------------------
444
+
445
+ * [change] `BabyErubis::Renderer#eruby_render_html()` and
446
+ `#eruby_render_text()` distinguish symbol and string template name:
447
+
448
+ ```
449
+ ## previous
450
+ html = eruby_render_html(:foo) # render 'foo.html.eruby'
451
+ html = eruby_render_html("foo") # render 'foo.html.eruby'
452
+ html = eruby_render_html("foo.html.eruby") # render 'foo.html.eruby.html.eruby'
453
+
454
+ ## current
455
+ html = eruby_render_html(:foo) # render 'foo.html.eruby'
456
+ html = eruby_render_html("foo") # render 'foo'
457
+ html = eruby_render_html("foo.html.eruby") # render 'foo.html.eruby'
458
+
459
+ text = eruby_render_text(:foo) # render 'foo.eruby'
460
+ text = eruby_render_text(:'foo.txt') # render 'foo.txt.eruby'
461
+ text = eruby_render_text("foo.txt.eruby") # render 'foo.txt.eruby'
462
+ ```
463
+
464
+
433
465
  Release 2.1.2 (2015-10-30)
434
466
  --------------------------
435
467
 
@@ -482,4 +514,4 @@ $License: MIT License $
482
514
  Copyright
483
515
  =========
484
516
 
485
- $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
517
+ $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
data/Rakefile CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  ###
4
4
 
5
- RELEASE = ENV['rel'] || '2.1.1'
6
- COPYRIGHT = 'copyright(c) 2014-2015 kuwata-lab.com all rights reserved'
5
+ RELEASE = ENV['rel'] || '0.0.0'
6
+ COPYRIGHT = 'copyright(c) 2014-2016 kuwata-lab.com all rights reserved'
7
7
  LICENSE = 'MIT License'
8
8
 
9
9
  ###
@@ -35,6 +35,28 @@ task :clean do
35
35
  end
36
36
 
37
37
 
38
+ desc "udpate release number"
39
+ task :edit do
40
+ require_release_number()
41
+ spec_src = File.open('baby_erubis.gemspec') {|f| f.read }
42
+ spec = eval spec_src
43
+ spec.files.each do |fpath|
44
+ content = File.open(fpath, 'r+b:utf-8') do |f|
45
+ content = f.read
46
+ new_content = edit_content(content)
47
+ if new_content == content
48
+ puts "[ ] #{fpath}"
49
+ else
50
+ puts "[C] #{fpath}"
51
+ f.rewind()
52
+ f.truncate(0)
53
+ f.write(new_content)
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+
38
60
  desc "copy files into 'dist/#{RELEASE}'"
39
61
  task :dist => :clean do
40
62
  require_release_number()
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
4
+ ### $Release: 2.2.0 $
5
5
  ### $License: MIT License $
6
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
6
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
7
7
  ###
8
8
 
9
9
  require 'rubygems'
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.name = "baby_erubis"
14
14
  s.author = "makoto kuwata"
15
15
  s.email = "kwa(at)kuwata-lab.com"
16
- s.version = "$Release: 2.1.2 $".split()[1]
16
+ s.version = "$Release: 2.2.0 $".split()[1]
17
17
  s.license = "MIT License"
18
18
  s.platform = Gem::Platform::RUBY
19
19
  s.homepage = "https://github.com/kwatch/BabyErubis/tree/ruby"
@@ -2,8 +2,8 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  ###
5
- ### $Release: 2.1.2 $
6
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
5
+ ### $Release: 2.2.0 $
6
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
7
7
  ### $License: MIT License $
8
8
  ###
9
9
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -25,7 +25,7 @@
25
25
 
26
26
  module BabyErubis
27
27
 
28
- RELEASE = '$Release: 2.1.2 $'.split(' ')[1]
28
+ RELEASE = '$Release: 2.2.0 $'.split(' ')[1]
29
29
 
30
30
 
31
31
  class TemplateError < StandardError
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -35,6 +35,12 @@ module BabyErubis
35
35
  ## end
36
36
  ##
37
37
  ##
38
+ ## Notice:
39
+ ##
40
+ ## eruby_render_html(:welcome) # render 'welcome.html.eruby'
41
+ ## eruby_render_html('welcome') # render 'welcome'
42
+ ## eruby_render_html('welcome.html.eruby') # render 'welcome.html.eruby'
43
+ ##
38
44
  module Renderer
39
45
 
40
46
  ERUBY_PATH = ['.']
@@ -46,20 +52,22 @@ module BabyErubis
46
52
  ERUBY_CACHE = {}
47
53
 
48
54
  def eruby_render_html(template_name, layout: true, encoding: 'utf-8')
55
+ ext = self.class.const_get :ERUBY_HTML_EXT
56
+ tmpl_class = self.class.const_get :ERUBY_HTML
49
57
  return _eruby_render_template(template_name, layout) {|tmpl_name|
50
- ext = self.class.const_get :ERUBY_HTML_EXT
51
- _eruby_find_template("#{tmpl_name}#{ext}") {|fpath|
52
- tmpl_class = self.class.const_get :ERUBY_HTML
58
+ filename = tmpl_name.is_a?(Symbol) ? "#{tmpl_name}#{ext}" : tmpl_name
59
+ _eruby_find_template(filename) {|fpath|
53
60
  tmpl_class.new.from_file(fpath, encoding)
54
61
  }
55
62
  }
56
63
  end
57
64
 
58
65
  def eruby_render_text(template_name, layout: false, encoding: 'utf-8')
66
+ ext = self.class.const_get :ERUBY_TEXT_EXT
67
+ tmpl_class = self.class.const_get :ERUBY_TEXT
59
68
  return _eruby_render_template(template_name, layout) {|tmpl_name|
60
- ext = self.class.const_get :ERUBY_TEXT_EXT
61
- _eruby_find_template("#{tmpl_name}#{ext}") {|fpath|
62
- tmpl_class = self.class.const_get :ERUBY_TEXT
69
+ filename = tmpl_name.is_a?(Symbol) ? "#{tmpl_name}#{ext}" : tmpl_name
70
+ _eruby_find_template(filename) {|fpath|
63
71
  tmpl_class.new.from_file(fpath, encoding)
64
72
  }
65
73
  }
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -92,8 +92,6 @@ END
92
92
  describe '#eruby_render_html()' do
93
93
 
94
94
  it "renders html template." do
95
- obj = HelloClass.new(:items=>[10, 20, 30])
96
- actual = obj.eruby_render_html(:'welcome', layout: false)
97
95
  expected = <<'END'
98
96
  <h1>Example</h1>
99
97
  <ul>
@@ -102,6 +100,13 @@ END
102
100
  <li>30</li>
103
101
  </ul>
104
102
  END
103
+ #
104
+ obj = HelloClass.new(:items=>[10, 20, 30])
105
+ actual = obj.eruby_render_html(:'welcome', layout: false)
106
+ assert_equal expected, actual
107
+ #
108
+ obj = HelloClass.new(:items=>[10, 20, 30])
109
+ actual = obj.eruby_render_html('welcome.html.erb', layout: false)
105
110
  assert_equal expected, actual
106
111
  end
107
112
 
@@ -137,12 +142,17 @@ END
137
142
  describe '#eruby_render_text()' do
138
143
 
139
144
  it "renders text template" do
140
- obj = HelloClass.new(:title=>"Homhom", :date=>"2015-01-01")
141
- actual = obj.eruby_render_text(:'example.text', layout: false)
142
145
  expected = <<'END'
143
146
  title: Homhom
144
147
  date: 2015-01-01
145
148
  END
149
+ #
150
+ obj = HelloClass.new(:title=>"Homhom", :date=>"2015-01-01")
151
+ actual = obj.eruby_render_text(:'example.text', layout: false)
152
+ assert_equal expected, actual
153
+ #
154
+ obj = HelloClass.new(:title=>"Homhom", :date=>"2015-01-01")
155
+ actual = obj.eruby_render_text('example.text.erb', layout: false)
146
156
  assert_equal expected, actual
147
157
  end
148
158
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 2.1.2 $
5
- ### $Copyright: copyright(c) 2014-2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 2.2.0 $
5
+ ### $Copyright: copyright(c) 2014-2016 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baby_erubis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - makoto kuwata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-30 00:00:00.000000000 Z
11
+ date: 2016-09-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  BabyErubis is an yet another eRuby implementation, based on Erubis.
@@ -25,21 +25,21 @@ executables:
25
25
  extensions: []
26
26
  extra_rdoc_files: []
27
27
  files:
28
- - MIT-LICENSE
29
- - README.md
30
- - Rakefile
31
- - baby_erubis.gemspec
32
- - bin/baby_erubis
33
28
  - lib/baby_erubis.rb
34
29
  - lib/baby_erubis/rails.rb
35
30
  - lib/baby_erubis/renderer.rb
36
- - setup.rb
37
31
  - test/context_test.rb
38
32
  - test/rails_test.rb
39
33
  - test/renderer_test.rb
40
34
  - test/run_all.rb
41
35
  - test/script_test.rb
42
36
  - test/template_test.rb
37
+ - bin/baby_erubis
38
+ - README.md
39
+ - MIT-LICENSE
40
+ - setup.rb
41
+ - baby_erubis.gemspec
42
+ - Rakefile
43
43
  homepage: https://github.com/kwatch/BabyErubis/tree/ruby
44
44
  licenses:
45
45
  - MIT License
@@ -50,17 +50,17 @@ require_paths:
50
50
  - lib
51
51
  required_ruby_version: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 2.4.5.1
63
+ rubygems_version: 2.0.14.1
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: yet another eRuby implementation based on Erubis