hoshi 1.0.0 → 1.0.1

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: 221a93d1028f8a61613f742d6d260f5678e83b1f
4
- data.tar.gz: 10addb7f304cb7fc5f533e77b48fae2442df608a
3
+ metadata.gz: d94fffbfa325feff79de2aa56200eabbb6b6cd3f
4
+ data.tar.gz: ea241fff24e0384e17ee484a25ae8b2ce0c7bee3
5
5
  SHA512:
6
- metadata.gz: a3e4b240018e7bc059f8eaa810c0c280587df6336645c44a5911d6a8b5fb9f41c44db2f934beb1eb5ec80c8f4375088d436f064b6b54d8bd10a6a4fde3422552
7
- data.tar.gz: dc0fb5a542d44f605f9133668c092ef1d03a745c76ef0bd2ed3ccd9528edc53477e4d251a67cd238c62d52fa5654a5b5bed7ed3afe07855821114f077b4b58ad
6
+ metadata.gz: e28120927da5cd877dae48cd6c2df0ac23f27525af4927337b6240720c53b4f695f71c21934981048fce6ec954671ccbd80168d4ef7363c3155af03556b8cf2c
7
+ data.tar.gz: 275632c8f6190be96e463cc3f4318c52f0ededd275691e7db76e37fc6a06e804f020f13e230bc8c9de7af36371ceb6fab4c769f1b055253344c39b321734b71b
data/README ADDED
@@ -0,0 +1,194 @@
1
+ = Hoshi
2
+
3
+ == Summary
4
+
5
+ Hoshi is a library for creating real, first-class HTML/XML views. So,
6
+ unlike template libraries, you can take advantage of mixins,
7
+ inheritance, and all the other wonderful features of Ruby's object
8
+ system. There is also support for easy RSS feeds and CGI.
9
+
10
+ Hoshi is designed to:
11
+ * Generate clean HTML/XHTML/XML with minimal effort
12
+ * Be easy for a coder to use and understand
13
+ * Take full advantage of Ruby's object sytem
14
+ * Be more readable and easier to write than bare HTML
15
+
16
+ It is semi-modeled after Markaby, but with a much more straightforward
17
+ implementation and different semantics (e.g., no instance_eval, so scope
18
+ inside a tag is as expected).
19
+
20
+ See doc/LICENSE for the license, doc/examples for examples.
21
+
22
+ == Installation
23
+
24
+ You can install via rubygems,
25
+
26
+ gem install hoshi
27
+
28
+ or by downloading from github (http://github.com/pete/hoshi).
29
+
30
+ == Usage
31
+
32
+ These examples and more featured in the fabulous doc/examples directory.
33
+ Also, there is a program included called html2hoshi (and associated
34
+ lib/html2hoshi.rb; see Hoshi.from_html) that takes HTML as input and
35
+ converts it to Ruby code using Hoshi.
36
+
37
+ === Class-based
38
+
39
+ These should be fairly straightforward:
40
+
41
+ require 'hoshi'
42
+
43
+ class Trivial < Hoshi::View :html5
44
+ def show
45
+ doctype
46
+ html {
47
+ head {
48
+ title "Hello, world!"
49
+ link :rel => 'stylesheet', :href => '/css/hoshi.css'
50
+ }
51
+
52
+ body {
53
+ h1 "Hello, world!"
54
+ p "This is a greeting to the world."
55
+ }
56
+ }
57
+ render
58
+ end
59
+ end
60
+
61
+ puts Trivial.new.show
62
+
63
+ You can get a little more complicated:
64
+
65
+ require 'hoshi'
66
+ require 'cgi'
67
+
68
+ module Layout
69
+ def main_page(t)
70
+ doctype
71
+ html {
72
+ head {
73
+ title t
74
+ script(:type => 'text/javascript') {
75
+ raw "alert(\"Hi, I'm some javascript, I suppose.\");"
76
+ }
77
+ }
78
+
79
+ body {
80
+ h1 t, :class => 'page_title'
81
+
82
+ yield
83
+ }
84
+ }
85
+ end
86
+
87
+ def list_page(t)
88
+ main_page(t) {
89
+ ul {
90
+ yield
91
+ }
92
+ }
93
+ end
94
+ end
95
+
96
+
97
+ class Fibonacci < Hoshi::View :xhtml1
98
+ include Layout
99
+
100
+ def list_page(n)
101
+ super("Fibonacci: f(0)..f(#{n})") {
102
+ fib_upto(n).map { |i| li i.to_s }
103
+ }
104
+ CGI.pretty(render)
105
+ end
106
+
107
+ private
108
+
109
+ def fib_upto n
110
+ a = Array.new(n)
111
+
112
+ 0.upto(n) { |i|
113
+ a[i] =
114
+ if i < 2
115
+ 1
116
+ else
117
+ a[i - 1] + a[i - 2]
118
+ end
119
+ }
120
+
121
+ a
122
+ end
123
+ end
124
+
125
+ puts Fibonacci.new.list_page(n)
126
+
127
+ === Block-based
128
+
129
+ For simpler cases where you only intend to produce markup, perhaps for use as a templating engine.
130
+
131
+ require 'hoshi'
132
+
133
+ str = Hoshi::View::HTML5.build {
134
+ doctype
135
+ html {
136
+ head {
137
+ title "Hello, world!"
138
+ link :rel => 'stylesheet', :href => '/css/hoshi.css'
139
+ }
140
+
141
+ body {
142
+ h1 "Hello, world!"
143
+ p "This is a greeting to the world."
144
+ }
145
+ }
146
+ }
147
+
148
+ puts str
149
+
150
+ == Bugs
151
+
152
+ There needs to be some work done on correcting the tags; I suspect I'm
153
+ missing or miscategorizing some of them.
154
+
155
+ I'd like to perhaps add a layer for serializing objects in the standard
156
+ HTML5 method (i.e., the Schema.org/microdata stuff). That's very
157
+ speculative at the moment.
158
+
159
+ There are some requirements that were expedient at the time (requiring
160
+ metaid and hpricot, embedding the gemspec in the Rakefile, etc.) that
161
+ could use cleanup. Hash is monkey-patched, and using the new Ruby 2
162
+ refinements feature would be nicer.
163
+
164
+ == Credits
165
+
166
+ Author:
167
+ Pete Elmore -- (pete(a)debu.gs)
168
+
169
+ Pretty heavily indebted to:
170
+ _why the lucky stiff's Markaby library
171
+
172
+ Initial design discussion:
173
+ Dan Yoder
174
+
175
+ Simple block version:
176
+ Nolan Darilek -- (nolan(a)thewordnerd.info)
177
+
178
+ Homie that be lookin' out for my broken deps:
179
+ Lars Lethonen
180
+
181
+ The guys that paid me to do the initial version:
182
+ AT&T Interactive.
183
+
184
+ Also, I guess I should credit Attractive Eighties Women
185
+ (http://attractiveeightieswomen.com/), since I was blasting them the
186
+ whole time I was developing this. Like, over and over. I couldn't stop
187
+ listening. My friends and family are becoming concerned. I don't feel
188
+ that I am yet ready to take the first step by admitting there is a
189
+ problem. Intervention may be required. This paragraph should probably
190
+ be considered a cry for help.
191
+
192
+ == Home page
193
+
194
+ http://debu.gs/hoshi
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ spec = Gem::Specification.new { |s|
8
8
  s.email = "pete@debu.gs"
9
9
  s.files = Dir["{lib,doc,bin,ext}/**/*"].delete_if {|f|
10
10
  /\/rdoc(\/|$)/i.match f
11
- } + %w(Rakefile)
11
+ } + %w(Rakefile README)
12
12
  s.require_path = 'lib'
13
13
  s.has_rdoc = true
14
14
  s.extra_rdoc_files = Dir['doc/*'].select(&File.method(:file?))
@@ -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.0'
23
+ s.version = '1.0.1'
24
24
  }
25
25
 
26
26
  Gem::PackageTask.new(spec) { |pkg|
data/doc/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008,2013 Peter Elmore (pete at debu.gs)
1
+ Copyright (c) 2008,2013 Pete Elmore (pete at debu.gs)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a
4
4
  copy of this software and associated documentation files (the "Software"),
@@ -1,9 +1,15 @@
1
1
  class Hash
2
2
  # Makes this hash fit to be put into a tag.
3
- # { :a => 1, :b => "two" }.to_html_options # => 'a="one" b="two"'
3
+ # { :a => 1, :b => "two", :c => true }.to_html_options # => 'a="one" b="two" c'
4
4
  def to_html_options double_quotes = true
5
5
  qchar = double_quotes ? '"' : "'"
6
- map { |k,v| "#{k}=#{qchar}#{v}#{qchar}" }.join(' ')
6
+ map { |k,v|
7
+ if v == true
8
+ k.to_s
9
+ else
10
+ "#{k}=#{qchar}#{v}#{qchar}"
11
+ end
12
+ }.join(' ')
7
13
  end
8
14
  end
9
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-09-18 00:00:00.000000000 Z
11
+ date: 2013-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metaid
@@ -77,6 +77,7 @@ files:
77
77
  - doc/TODO
78
78
  - bin/html2hoshi
79
79
  - Rakefile
80
+ - README
80
81
  homepage: http://debu.gs/hoshi
81
82
  licenses: []
82
83
  metadata: {}