hoshi 1.0.2 → 1.0.3

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: 783544e05672de686759ab07a25195238ab6c52c
4
- data.tar.gz: e50b0f09a495af1e2741fb38f693d2989ce4f52d
3
+ metadata.gz: 5712bb65af3f082b487149e20c16dc7d7ad796e9
4
+ data.tar.gz: ad41a5906aaa48aaab16c0b912375c91a7d2f64d
5
5
  SHA512:
6
- metadata.gz: d16d0bef7793652ffc80b0c6e2d4830d60c742e44e2e3a88026950d081703485b703bead988d1e2e8e5febb75d79920ef239f4451bfc59452f879b6e8cbdefbf
7
- data.tar.gz: 1c27598f70ef353fd456b9fff8a64857f4a3b7cfdbfb216bedebda93315bc2f59e7e22ad1a61662d23e92ff07eba09ed01822547c551441a882d285b19130e8f
6
+ metadata.gz: 5d64a05cc2610dfb1d197aaea201c2511f733fafff11161f564b83f42f4a4154c3efe4ac41527e948d3afc13ca5e586d0a29637df3e25b8639926ae564eae490
7
+ data.tar.gz: 117bf21e0b303d8edcb7b4a86ccacd442bbd11a969eaad00ed7715db6cc141a20c633f384bd525e4f3bf14a939a56c1043eee063069a1170deb89fcb5d9c0ed1
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ spec = Gem::Specification.new { |s|
20
20
  s.summary = "Nice, object-oriented, first-class views."
21
21
  s.homepage = "http://debu.gs/#{s.name}"
22
22
  %w(metaid hpricot).each &s.method(:add_dependency)
23
- s.version = '1.0.2'
23
+ s.version = '1.0.3'
24
24
  }
25
25
 
26
26
  Gem::PackageTask.new(spec) { |pkg|
data/lib/hoshi/tag.rb CHANGED
@@ -23,14 +23,16 @@ module Hoshi
23
23
  # gets you this:
24
24
  # <div onclick="alert('Hi.');">Click for an alert.</div>
25
25
  def render(inside = nil, opts = {})
26
- inside = inside.to_s
26
+ inside = inside
27
27
 
28
- s = "<#{name} #{opts.to_html_options}".strip
29
- if inside.empty? && close_type == :self
28
+ s = "<#{name} #{opts.to_html_options}"
29
+ s.chomp! ' '
30
+ if((!inside || inside.empty?) && close_type == :self)
30
31
  return s << " />"
31
32
  end
32
33
 
33
- s << ">" << inside
34
+ s << ">"
35
+ s << inside if inside
34
36
 
35
37
  if close_type == :none
36
38
  s << "\n"
data/lib/hoshi/view.rb CHANGED
@@ -94,6 +94,7 @@ module Hoshi
94
94
  Dir["#{File.dirname(__FILE__)}/view/*.rb"].each { |view| require view }
95
95
 
96
96
  def initialize
97
+ @tcache = {}
97
98
  clear!
98
99
  end
99
100
 
@@ -103,6 +104,10 @@ module Hoshi
103
104
  self.current = tree
104
105
  end
105
106
 
107
+ def otag(*a)
108
+ @tcache[a] ||= Tag.new(*a)
109
+ end
110
+
106
111
  # Adds a comment.
107
112
  def comment(*a)
108
113
  if a.include?('--')
@@ -119,7 +124,7 @@ module Hoshi
119
124
  # Appends a tag to the current document, for when a tag is only needed
120
125
  # once or has a name that is not a valid method name.
121
126
  def tag(tname, close_type = nil, *opts, &b)
122
- t = Tag.new(tname, close_type)
127
+ t = otag(tname, close_type)
123
128
 
124
129
  if b
125
130
  old, self.current = current, []
@@ -138,7 +143,7 @@ module Hoshi
138
143
  # view object in place. Useful for things like
139
144
  # p "Here is a paragraph and a #{_a 'link', :href => '/'}."
140
145
  def _tag(tname, close_type = nil, inside = '', opts = {})
141
- t = Tag.new(tname, close_type)
146
+ t = otag(tname, close_type)
142
147
  t.render(inside, opts)
143
148
  end
144
149
 
@@ -5,19 +5,22 @@ class Hoshi::View
5
5
  dtd! "<!DOCTYPE html>"
6
6
 
7
7
  tags *%w(
8
- a abbr address area article aside audio b base bb bdi
9
- bdo blockquote body button canvas caption cite code col
10
- colgroup command data datagrid datalist dd del details
11
- dfn div dl dt em embed eventsource fieldset figcaption
12
- figure footer form h1 h2 h3 h4 h5 h6 head header hgroup
13
- hr html i iframe img input ins kbd keygen label legend
14
- li link mark map menu meta meter nav noscript object ol
15
- optgroup option output p param pre progress q ruby rp rt
16
- s samp script section select small source span strong
17
- style sub summary sup table tbody td textarea tfoot th
18
- thead time title tr track u ul var video wbr
8
+ a abbr address area article aside audio b base
9
+ bb bdi bdo blockquote body button canvas caption
10
+ cite code col colgroup command data datagrid
11
+ datalist dd del details dfn div dl dt em embed
12
+ eventsource fieldset figcaption figure footer
13
+ form h1 h2 h3 h4 h5 h6 head header hgroup html i
14
+ iframe ins kbd keygen label legend li mark map
15
+ menu meter nav noscript object ol optgroup
16
+ option output p param pre progress q ruby rp rt
17
+ s samp script section select small source span
18
+ strong style sub summary sup table tbody td
19
+ textarea tfoot th thead time title tr track u ul
20
+ var video wbr
21
+ )
22
+ open_tags *%w(
23
+ br hr img input link meta
19
24
  )
20
- open_tags *%w(br)
21
25
  end
22
26
  end
23
-
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Elmore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2016-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metaid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hpricot
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description:
@@ -47,36 +47,36 @@ extra_rdoc_files:
47
47
  - doc/LICENSE
48
48
  - doc/TODO
49
49
  files:
50
- - lib/html2hoshi.rb
51
- - lib/hoshi/view.rb
50
+ - README
51
+ - Rakefile
52
+ - bin/html2hoshi
53
+ - doc/LICENSE
54
+ - doc/TODO
55
+ - doc/examples/blocks.rb
56
+ - doc/examples/env.cgi
57
+ - doc/examples/inline_tags.rb
58
+ - doc/examples/layouts.rb
59
+ - doc/examples/rss2.rb
60
+ - doc/examples/trivial.rb
61
+ - lib/hoshi.rb
62
+ - lib/hoshi/monkey_patches.rb
52
63
  - lib/hoshi/tag.rb
53
- - lib/hoshi/view/xhtml1.rb
64
+ - lib/hoshi/view-tag.rb
65
+ - lib/hoshi/view.rb
54
66
  - lib/hoshi/view/html.rb
67
+ - lib/hoshi/view/html3.rb
55
68
  - lib/hoshi/view/html4.rb
56
69
  - lib/hoshi/view/html4_frameset.rb
57
- - lib/hoshi/view/xhtml1_frameset.rb
58
- - lib/hoshi/view/html5.rb
59
- - lib/hoshi/view/xhtml1_strict.rb
60
- - lib/hoshi/view/xhtml.rb
61
70
  - lib/hoshi/view/html4_transitional.rb
62
- - lib/hoshi/view/xhtml2.rb
63
- - lib/hoshi/view/html3.rb
71
+ - lib/hoshi/view/html5.rb
64
72
  - lib/hoshi/view/rss2.rb
73
+ - lib/hoshi/view/xhtml.rb
74
+ - lib/hoshi/view/xhtml1.rb
75
+ - lib/hoshi/view/xhtml1_frameset.rb
76
+ - lib/hoshi/view/xhtml1_strict.rb
65
77
  - lib/hoshi/view/xhtml1_transitional.rb
66
- - lib/hoshi/view-tag.rb
67
- - lib/hoshi/monkey_patches.rb
68
- - lib/hoshi.rb
69
- - doc/examples/layouts.rb
70
- - doc/examples/inline_tags.rb
71
- - doc/examples/blocks.rb
72
- - doc/examples/env.cgi
73
- - doc/examples/trivial.rb
74
- - doc/examples/rss2.rb
75
- - doc/LICENSE
76
- - doc/TODO
77
- - bin/html2hoshi
78
- - Rakefile
79
- - README
78
+ - lib/hoshi/view/xhtml2.rb
79
+ - lib/html2hoshi.rb
80
80
  homepage: http://debu.gs/hoshi
81
81
  licenses: []
82
82
  metadata: {}
@@ -86,17 +86,17 @@ require_paths:
86
86
  - lib
87
87
  required_ruby_version: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project: hoshi-view
99
- rubygems_version: 2.0.14
99
+ rubygems_version: 2.2.2
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Nice, object-oriented, first-class views.