hoshi 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -4
- data/doc/TODO +1 -0
- data/doc/examples/layouts.rb +0 -1
- data/lib/hoshi/monkey_patches.rb +10 -0
- data/lib/hoshi/view/html.rb +7 -0
- data/lib/hoshi/view/rss2.rb +1 -1
- data/lib/hoshi/view-tag-fallback.rb +19 -0
- data/lib/hoshi/view-tag.rb +20 -0
- data/lib/hoshi/view.rb +8 -18
- data/lib/hoshi.rb +0 -1
- metadata +62 -70
data/Rakefile
CHANGED
@@ -20,8 +20,8 @@ spec = Gem::Specification.new { |s|
|
|
20
20
|
s.rubyforge_project = 'hoshi-view'
|
21
21
|
s.summary = "Nice, object-oriented, first-class views."
|
22
22
|
s.homepage = "http://debu.gs/#{s.name}"
|
23
|
-
%w(
|
24
|
-
s.version = '0.1.
|
23
|
+
%w(metaid hpricot).each &s.method(:add_dependency)
|
24
|
+
s.version = '0.1.4'
|
25
25
|
}
|
26
26
|
|
27
27
|
Rake::GemPackageTask.new(spec) { |pkg|
|
@@ -29,6 +29,6 @@ Rake::GemPackageTask.new(spec) { |pkg|
|
|
29
29
|
}
|
30
30
|
|
31
31
|
task(:install => :package) {
|
32
|
-
g =
|
33
|
-
system "gem install -l #{g}"
|
32
|
+
g = "pkg/#{spec.name}-#{spec.version}.gem"
|
33
|
+
system "sudo gem install -l #{g}"
|
34
34
|
}
|
data/doc/TODO
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
TODO for 1.0:
|
2
2
|
* Separate the tags by close type in the various View sub-classes. (The most
|
3
3
|
tedious thing on the list, but required for compliance.)
|
4
|
+
* Still not too happy about the way RSS feeds are done, going to rework.
|
4
5
|
|
5
6
|
TODO for later:
|
6
7
|
* Have html2hoshi do a smarter job of deciding doctypes, not using permissive!
|
data/doc/examples/layouts.rb
CHANGED
data/lib/hoshi/monkey_patches.rb
CHANGED
@@ -6,3 +6,13 @@ class Hash
|
|
6
6
|
map { |k,v| "#{k}=#{qchar}#{v}#{qchar}" }.join(' ')
|
7
7
|
end
|
8
8
|
end
|
9
|
+
|
10
|
+
# We've dropped facets, and are now shooting for compatibility across Ruby
|
11
|
+
# versions, so we add Symbol#to_proc unless it exists.
|
12
|
+
unless((Symbol.instance_method(:to_proc) rescue nil))
|
13
|
+
class Symbol
|
14
|
+
def to_proc
|
15
|
+
proc { |obj, *args| obj.send(self, *args) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/hoshi/view/html.rb
CHANGED
@@ -12,5 +12,12 @@ class Hoshi::View
|
|
12
12
|
def cdata str
|
13
13
|
append! "<![CDATA[\n" + str + "\n]]>"
|
14
14
|
end
|
15
|
+
|
16
|
+
# Includes the stylesheets from the list passed as arguments.
|
17
|
+
def css_includes *ss
|
18
|
+
ss.each { |s|
|
19
|
+
link :rel => 'stylesheet', :media => 'all', :href => s
|
20
|
+
}
|
21
|
+
end
|
15
22
|
end
|
16
23
|
end
|
data/lib/hoshi/view/rss2.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Hoshi
|
2
|
+
class View
|
3
|
+
# This method is a fallback for pre-1.8.7 Ruby; if a syntax error is
|
4
|
+
# encountered when hoshi/view.rb tries to load hoshi/view-tag.rb, this
|
5
|
+
# file is loaded. I have really been trying to avoid eval()ing strings
|
6
|
+
# (for religious reasons), but have to make this concession.
|
7
|
+
def self.tag(name, close_type = nil)
|
8
|
+
class_eval <<-EOHACK
|
9
|
+
def #{name}(*opts, &b)
|
10
|
+
if b
|
11
|
+
tag #{name.inspect}, #{close_type.inspect}, *opts, &b
|
12
|
+
else
|
13
|
+
tag #{name.inspect}, #{close_type.inspect}, *opts, &b
|
14
|
+
end
|
15
|
+
end
|
16
|
+
EOHACK
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Hoshi
|
2
|
+
class View
|
3
|
+
# This creates an instance method for this view which appends a tag.
|
4
|
+
# Most of these are handled for you. The arguments to this method
|
5
|
+
# match those to Tag.new. See also View#permissive!.
|
6
|
+
# tag('h1')
|
7
|
+
# def show_an_h1
|
8
|
+
# h1 "I have been shown"
|
9
|
+
# end
|
10
|
+
def self.tag(name, close_type = nil)
|
11
|
+
define_method(name) { |*opts,&b|
|
12
|
+
if b
|
13
|
+
tag name, close_type, *opts, &b
|
14
|
+
else
|
15
|
+
tag name, close_type, *opts
|
16
|
+
end
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/hoshi/view.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'metaid'
|
2
2
|
require 'cgi'
|
3
3
|
|
4
|
+
begin
|
5
|
+
require 'hoshi/view-tag'
|
6
|
+
rescue SyntaxError
|
7
|
+
require 'hoshi/view-tag-fallback'
|
8
|
+
end
|
9
|
+
|
4
10
|
module Hoshi
|
5
11
|
# The View class is the super-class for views you create with Hoshi. More
|
6
12
|
# likely, though, you'll be using one of View's many sub-classes as the
|
@@ -15,23 +21,6 @@ module Hoshi
|
|
15
21
|
class View
|
16
22
|
class ValidationError < StandardError; end
|
17
23
|
|
18
|
-
# This creates an instance method for this view which appends a tag.
|
19
|
-
# Most of these are handled for you. The arguments to this method
|
20
|
-
# match those to Tag.new. See also View#permissive!.
|
21
|
-
# tag('h1')
|
22
|
-
# def show_an_h1
|
23
|
-
# h1 "I have been shown"
|
24
|
-
# end
|
25
|
-
def self.tag(name, close_type = nil)
|
26
|
-
define_method(name) { |*opts,&b|
|
27
|
-
if b
|
28
|
-
tag name, close_type, *opts, &b
|
29
|
-
else
|
30
|
-
tag name, close_type, *opts
|
31
|
-
end
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
24
|
# A short-hand for creating multiple tags via View.tag. For tags that
|
36
25
|
# do not require closing, see View.open_tags.
|
37
26
|
def self.tags *names
|
@@ -52,7 +41,8 @@ module Hoshi
|
|
52
41
|
doctype = doctype.to_s.downcase.gsub('_', '')
|
53
42
|
const_get(constants.find { |c|
|
54
43
|
cl = const_get c
|
55
|
-
cl.ancestors.include?(self) &&
|
44
|
+
(cl.ancestors.include?(self) &&
|
45
|
+
c.to_s.downcase == doctype) rescue false
|
56
46
|
}) rescue nil
|
57
47
|
end
|
58
48
|
|
data/lib/hoshi.rb
CHANGED
metadata
CHANGED
@@ -1,63 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
autorequire:
|
9
|
-
bindir: bin
|
10
|
-
cert_chain: []
|
11
|
-
|
12
|
-
date: 2008-11-11 00:00:00 -08:00
|
13
|
-
default_executable:
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: facets
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: metaid
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: hpricot
|
37
|
-
type: :runtime
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: "0"
|
44
|
-
version:
|
45
|
-
description:
|
2
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
3
|
+
requirements:
|
4
|
+
- - '>='
|
5
|
+
- !ruby/object:Gem::Version
|
6
|
+
version: "0"
|
7
|
+
version:
|
46
8
|
email: pete.elmore@gmail.com
|
47
|
-
|
48
|
-
- html2hoshi
|
49
|
-
extensions: []
|
9
|
+
cert_chain: []
|
50
10
|
|
11
|
+
summary: Nice, object-oriented, first-class views.
|
12
|
+
post_install_message:
|
51
13
|
extra_rdoc_files:
|
52
14
|
- doc/README
|
53
15
|
- doc/TODO
|
54
16
|
- doc/LICENSE
|
17
|
+
homepage: http://debu.gs/hoshi
|
18
|
+
signing_key:
|
19
|
+
name: hoshi
|
20
|
+
rdoc_options: []
|
21
|
+
|
22
|
+
autorequire:
|
23
|
+
rubyforge_project: hoshi-view
|
24
|
+
executables:
|
25
|
+
- html2hoshi
|
26
|
+
description:
|
27
|
+
specification_version: 2
|
28
|
+
default_executable:
|
55
29
|
files:
|
56
30
|
- lib/html2hoshi.rb
|
57
31
|
- lib/hoshi.rb
|
58
32
|
- lib/hoshi
|
59
33
|
- lib/hoshi/monkey_patches.rb
|
60
34
|
- lib/hoshi/view
|
35
|
+
- lib/hoshi/view-tag.rb
|
36
|
+
- lib/hoshi/tag.rb
|
37
|
+
- lib/hoshi/view-tag-fallback.rb
|
38
|
+
- lib/hoshi/view.rb
|
61
39
|
- lib/hoshi/view/html.rb
|
62
40
|
- lib/hoshi/view/xhtml1_strict.rb
|
63
41
|
- lib/hoshi/view/xhtml1_frameset.rb
|
@@ -70,45 +48,59 @@ files:
|
|
70
48
|
- lib/hoshi/view/xhtml2.rb
|
71
49
|
- lib/hoshi/view/xhtml1_transitional.rb
|
72
50
|
- lib/hoshi/view/rss2.rb
|
73
|
-
- lib/hoshi/tag.rb
|
74
|
-
- lib/hoshi/view.rb
|
75
51
|
- doc/README
|
76
52
|
- doc/examples
|
53
|
+
- doc/TODO
|
54
|
+
- doc/LICENSE
|
77
55
|
- doc/examples/layouts.rb
|
78
56
|
- doc/examples/trivial.rb
|
79
57
|
- doc/examples/blocks.rb
|
80
58
|
- doc/examples/env.cgi
|
81
59
|
- doc/examples/feed.rb
|
82
60
|
- doc/examples/rss2.rb
|
83
|
-
- doc/TODO
|
84
|
-
- doc/LICENSE
|
85
61
|
- bin/html2hoshi
|
86
62
|
- Rakefile
|
87
|
-
has_rdoc: true
|
88
|
-
homepage: http://debu.gs/hoshi
|
89
|
-
post_install_message:
|
90
|
-
rdoc_options: []
|
91
|
-
|
92
|
-
require_paths:
|
93
|
-
- lib
|
94
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: "0"
|
99
|
-
version:
|
100
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
64
|
requirements:
|
102
|
-
- -
|
65
|
+
- - '>='
|
103
66
|
- !ruby/object:Gem::Version
|
104
67
|
version: "0"
|
105
68
|
version:
|
106
|
-
|
69
|
+
extensions: []
|
107
70
|
|
108
|
-
rubyforge_project: hoshi-view
|
109
71
|
rubygems_version: 1.3.1
|
110
|
-
|
111
|
-
|
112
|
-
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
authors:
|
75
|
+
- Pete Elmore
|
76
|
+
date: 2009-02-10 08:00:00 +00:00
|
77
|
+
platform: ruby
|
113
78
|
test_files: []
|
114
79
|
|
80
|
+
version: !ruby/object:Gem::Version
|
81
|
+
version: 0.1.4
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
dependencies:
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
type: :runtime
|
93
|
+
version_requirement:
|
94
|
+
name: metaid
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
type: :runtime
|
103
|
+
version_requirement:
|
104
|
+
name: hpricot
|
105
|
+
bindir: bin
|
106
|
+
has_rdoc: true
|