html_gen 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +45 -5
- data/README.md +60 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/html_gen.gemspec +15 -10
- data/lib/html_gen.rb +16 -9
- data/lib/{html_gen_element.rb → html_gen/element.rb} +121 -78
- data/lib/{html_gen_parser.rb → html_gen/parser.rb} +41 -40
- data/lib/{html_gen_text_ele.rb → html_gen/text_ele.rb} +9 -9
- data/shippable.yml +9 -0
- data/spec/html_gen_parser_spec.rb +43 -18
- data/spec/html_gen_spec.rb +47 -26
- data/spec/spec_helper.rb +3 -1
- metadata +83 -67
- data/README.rdoc +0 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c67d70ec80e15b84be9ffb5d38c994877a9fe8cb
|
4
|
+
data.tar.gz: cb4312924ea5936e3e85504d8242724267cdd297
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3fc3b7aa1ad97434106efc26ee97df3c0fa83ea693aa839be8301b7f076ec984d7785fd853df413c6eea1b3b38cb0ffe7e0f22ce23a14f63ca54e7f4d1830d2c
|
7
|
+
data.tar.gz: 7da0053e8d31c33098cfdeae5749b0ded911349a7cec7f7b4eb5a216b81ef63845f301da52dadcb902e1697cab5ad434c6712e58579a55d11b40735f2fece8c6
|
data/Gemfile
CHANGED
@@ -3,6 +3,9 @@ source "http://rubygems.org"
|
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
5
|
|
6
|
+
gem "string-cases"
|
7
|
+
gem "codeclimate-test-reporter", group: :test, require: nil
|
8
|
+
|
6
9
|
# Add dependencies to develop your gem here.
|
7
10
|
# Include everything needed to run rake, tests, features, etc.
|
8
11
|
group :development do
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,48 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
addressable (2.3.7)
|
5
|
+
builder (3.2.2)
|
6
|
+
codeclimate-test-reporter (0.4.6)
|
7
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
4
8
|
diff-lcs (1.1.3)
|
5
|
-
|
6
|
-
|
9
|
+
docile (1.1.5)
|
10
|
+
faraday (0.8.9)
|
11
|
+
multipart-post (~> 1.2.0)
|
12
|
+
git (1.2.9.1)
|
13
|
+
github_api (0.10.1)
|
14
|
+
addressable
|
15
|
+
faraday (~> 0.8.1)
|
16
|
+
hashie (>= 1.2)
|
17
|
+
multi_json (~> 1.4)
|
18
|
+
nokogiri (~> 1.5.2)
|
19
|
+
oauth2
|
20
|
+
hashie (3.4.0)
|
21
|
+
highline (1.6.21)
|
22
|
+
jeweler (1.8.8)
|
23
|
+
builder
|
7
24
|
bundler (~> 1.0)
|
8
25
|
git (>= 1.2.5)
|
26
|
+
github_api (= 0.10.1)
|
27
|
+
highline (>= 1.6.15)
|
28
|
+
nokogiri (= 1.5.10)
|
9
29
|
rake
|
10
30
|
rdoc
|
11
|
-
json (1.
|
12
|
-
|
13
|
-
|
31
|
+
json (1.8.2)
|
32
|
+
jwt (1.2.1)
|
33
|
+
multi_json (1.10.1)
|
34
|
+
multi_xml (0.5.5)
|
35
|
+
multipart-post (1.2.0)
|
36
|
+
nokogiri (1.5.10)
|
37
|
+
oauth2 (1.0.0)
|
38
|
+
faraday (>= 0.8, < 0.10)
|
39
|
+
jwt (~> 1.0)
|
40
|
+
multi_json (~> 1.3)
|
41
|
+
multi_xml (~> 0.5)
|
42
|
+
rack (~> 1.2)
|
43
|
+
rack (1.6.0)
|
44
|
+
rake (10.4.2)
|
45
|
+
rdoc (3.12.2)
|
14
46
|
json (~> 1.4)
|
15
47
|
rspec (2.8.0)
|
16
48
|
rspec-core (~> 2.8.0)
|
@@ -20,12 +52,20 @@ GEM
|
|
20
52
|
rspec-expectations (2.8.0)
|
21
53
|
diff-lcs (~> 1.1.2)
|
22
54
|
rspec-mocks (2.8.0)
|
55
|
+
simplecov (0.9.1)
|
56
|
+
docile (~> 1.1.0)
|
57
|
+
multi_json (~> 1.0)
|
58
|
+
simplecov-html (~> 0.8.0)
|
59
|
+
simplecov-html (0.8.0)
|
60
|
+
string-cases (0.0.0)
|
23
61
|
|
24
62
|
PLATFORMS
|
25
63
|
ruby
|
26
64
|
|
27
65
|
DEPENDENCIES
|
28
66
|
bundler (>= 1.0.0)
|
67
|
+
codeclimate-test-reporter
|
29
68
|
jeweler (~> 1.8.4)
|
30
69
|
rdoc (~> 3.12)
|
31
70
|
rspec (~> 2.8.0)
|
71
|
+
string-cases
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
[![Build Status](https://api.shippable.com/projects/540e7b9b3479c5ea8f9ec21c/badge?branchName=master)](https://app.shippable.com/projects/540e7b9b3479c5ea8f9ec21c/builds/latest)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/kaspernj/html_gen/badges/gpa.svg)](https://codeclimate.com/github/kaspernj/html_gen)
|
3
|
+
[![Test Coverage](https://codeclimate.com/github/kaspernj/html_gen/badges/coverage.svg)](https://codeclimate.com/github/kaspernj/html_gen)
|
4
|
+
|
5
|
+
# HtmlGen
|
6
|
+
|
7
|
+
A small and fast framework to parse and generate HTML in Ruby.
|
8
|
+
|
9
|
+
## Install
|
10
|
+
|
11
|
+
Add to your Gemfile and bundle:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "html_gen"
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Generate elements
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
div = HtmlGen::Element.new(:div, classes: ["class1", "class2"], attr: {width: "100px"}, css: {height: "50px"})
|
23
|
+
div.add_str "Hello world"
|
24
|
+
|
25
|
+
p = div.add_ele(:p)
|
26
|
+
p.add_str "Test"
|
27
|
+
|
28
|
+
div.html #=> '<div width="100px" style="height: 50px;" class="class1 class2">Hello world<p>Test</p></div>'
|
29
|
+
```
|
30
|
+
|
31
|
+
### Parse HTML into elements
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
parser = HtmlGen::Parser.new(str: "<html><head><title>Test</title></head><body>This is the body</body></html>")
|
35
|
+
html = parser.eles.first
|
36
|
+
head = html.eles.first
|
37
|
+
|
38
|
+
head.name #=> "head"
|
39
|
+
|
40
|
+
title = head.eles.first
|
41
|
+
title.html #=> "Test"
|
42
|
+
title.attr #=> {}
|
43
|
+
title.css #=> {}
|
44
|
+
```
|
45
|
+
|
46
|
+
## Contributing to html_gen
|
47
|
+
|
48
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
49
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
50
|
+
* Fork the project.
|
51
|
+
* Start a feature/bugfix branch.
|
52
|
+
* Commit and push until you are happy with your contribution.
|
53
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
54
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
55
|
+
|
56
|
+
## Copyright
|
57
|
+
|
58
|
+
Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
|
59
|
+
further details.
|
60
|
+
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/html_gen.gemspec
CHANGED
@@ -2,19 +2,21 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: html_gen 0.0.6 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "html_gen"
|
8
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.6"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Kasper Johansen"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2015-02-13"
|
13
15
|
s.description = "A small framework for generating HTML."
|
14
16
|
s.email = "k@spernj.org"
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE.txt",
|
17
|
-
"README.
|
19
|
+
"README.md"
|
18
20
|
]
|
19
21
|
s.files = [
|
20
22
|
".document",
|
@@ -22,39 +24,42 @@ Gem::Specification.new do |s|
|
|
22
24
|
"Gemfile",
|
23
25
|
"Gemfile.lock",
|
24
26
|
"LICENSE.txt",
|
25
|
-
"README.
|
27
|
+
"README.md",
|
26
28
|
"Rakefile",
|
27
29
|
"VERSION",
|
28
30
|
"html_gen.gemspec",
|
29
31
|
"lib/html_gen.rb",
|
30
|
-
"lib/
|
31
|
-
"lib/
|
32
|
-
"lib/
|
32
|
+
"lib/html_gen/element.rb",
|
33
|
+
"lib/html_gen/parser.rb",
|
34
|
+
"lib/html_gen/text_ele.rb",
|
35
|
+
"shippable.yml",
|
33
36
|
"spec/html_gen_parser_spec.rb",
|
34
37
|
"spec/html_gen_spec.rb",
|
35
38
|
"spec/spec_helper.rb"
|
36
39
|
]
|
37
40
|
s.homepage = "http://github.com/kaspernj/html_gen"
|
38
41
|
s.licenses = ["MIT"]
|
39
|
-
s.
|
40
|
-
s.rubygems_version = "1.8.24"
|
42
|
+
s.rubygems_version = "2.4.0"
|
41
43
|
s.summary = "A small framework for generating HTML."
|
42
44
|
|
43
45
|
if s.respond_to? :specification_version then
|
44
|
-
s.specification_version =
|
46
|
+
s.specification_version = 4
|
45
47
|
|
46
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<string-cases>, [">= 0"])
|
47
50
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
48
51
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
49
52
|
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
50
53
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
51
54
|
else
|
55
|
+
s.add_dependency(%q<string-cases>, [">= 0"])
|
52
56
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
53
57
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
54
58
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
55
59
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
56
60
|
end
|
57
61
|
else
|
62
|
+
s.add_dependency(%q<string-cases>, [">= 0"])
|
58
63
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
59
64
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
60
65
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
data/lib/html_gen.rb
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require "string-cases"
|
2
|
+
|
3
|
+
# This class doesnt hold other methods than for autoloading of subclasses.
|
4
|
+
class HtmlGen
|
5
|
+
# Autoloader for subclasses.
|
4
6
|
def self.const_missing(name)
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
file_path = "#{File.dirname(__FILE__)}/html_gen/#{::StringCases.camel_to_snake(name)}.rb"
|
8
|
+
|
9
|
+
if File.exists?(file_path)
|
10
|
+
require file_path
|
11
|
+
return HtmlGen.const_get(name) if HtmlGen.const_defined?(name)
|
12
|
+
end
|
13
|
+
|
14
|
+
super
|
8
15
|
end
|
9
|
-
|
10
|
-
#Escapes HTML from the given string. This is to avoid any dependencies and should not be used by other libs.
|
16
|
+
|
17
|
+
# Escapes HTML from the given string. This is to avoid any dependencies and should not be used by other libs.
|
11
18
|
def self.escape_html(string)
|
12
19
|
return string.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<")
|
13
20
|
end
|
14
|
-
end
|
21
|
+
end
|
@@ -1,218 +1,222 @@
|
|
1
1
|
#This class can be used to generate HTML.
|
2
2
|
#===Examples
|
3
|
-
# ele =
|
3
|
+
# ele = HtmlGen::Element.new(:a) #=> #<HtmlGen::Element:0x00000000e5f650 @attr={}, @name=:a, @classes=[], @str_html="", @str="", @css={}, @eles=[], @nl="\n", @inden="\t">
|
4
4
|
# ele.classes << "custom_link"
|
5
5
|
# ele.css["font-weight"] = "bold"
|
6
6
|
# ele.attr[:href] = "http://www.youtube.com"
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# b = ele.add_ele(:b)
|
9
9
|
# b.str = "Title of link"
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# ele.html #=> "<a href=\"http://www.youtube.com\" style=\"font-weight: bold;\" class=\"custom_link\">\n\t<b>\n\t\tTitle of link\n\t</b>\n</a>\n"
|
12
|
-
class
|
12
|
+
class HtmlGen::Element
|
13
13
|
FORBIDDEN_SHORT = ["script"]
|
14
|
-
|
14
|
+
|
15
15
|
#Attributes hash which will be used to generate attributes-elements.
|
16
16
|
#===Example
|
17
17
|
# element.attr[:href] = "http://www.youtube.com"
|
18
18
|
attr_reader :attr
|
19
|
-
|
19
|
+
|
20
20
|
#CSS-hash which will be used to generate the 'style'-attribute.
|
21
21
|
#===Example
|
22
22
|
# element.css["font-weight"] = "bold"
|
23
23
|
attr_reader :css
|
24
|
-
|
24
|
+
|
25
|
+
#Data hash which will nest keys.
|
26
|
+
attr_reader :data
|
27
|
+
|
25
28
|
#Classes-array which will be used to generate the 'class'-attribute.
|
26
29
|
#===Example
|
27
30
|
# element.classes += ["class1", "class2"]
|
28
31
|
# element.html #=> ... class="class1 class2"...
|
29
32
|
attr_reader :classes
|
30
|
-
|
33
|
+
|
31
34
|
#This string is used to generate the value of an element. It will be HTML-escaped.
|
32
35
|
#===Example
|
33
|
-
# element =
|
36
|
+
# element = HtmlGen::Element.new("b")
|
34
37
|
# element.str = "Te<i>s</i>t"
|
35
|
-
# element.html(:
|
38
|
+
# element.html(pretty: false) #=> "<b>Te<i>s</i>t</b>"
|
36
39
|
attr_accessor :str
|
37
|
-
|
40
|
+
|
38
41
|
#This string is used to generate the value of an element. It will not be HTML-escaped.
|
39
42
|
#===Example
|
40
|
-
# element =
|
43
|
+
# element = HtmlGen::Element.new("b")
|
41
44
|
# element.str_html = "Te<i>s</i>t"
|
42
45
|
# element.html #=> "<b>Te<i>s</i>t</b>"
|
43
46
|
attr_accessor :str_html
|
44
|
-
|
47
|
+
|
45
48
|
#An array holding all the sub-elements of this element.
|
46
49
|
attr_accessor :eles
|
47
|
-
|
50
|
+
|
48
51
|
#The name of the element. "a" for <a> and such.
|
49
52
|
attr_accessor :name
|
50
|
-
|
53
|
+
|
51
54
|
#You can give various arguments as shortcuts to calling the methods. You can also decide what should be used for newline and indentation.
|
52
|
-
#
|
53
|
-
# :
|
54
|
-
# :
|
55
|
-
# :
|
56
|
-
# :
|
57
|
-
# :
|
58
|
-
# :
|
59
|
-
# :
|
60
|
-
# :
|
55
|
+
# HtmlGen::Element.new(:b, {
|
56
|
+
# css: {"font-weight" => "bold"},
|
57
|
+
# attr: {"href" => "http://www.youtube.com"},
|
58
|
+
# classes: ["class1", "class2"],
|
59
|
+
# str: "A title",
|
60
|
+
# str_html: "Some custom URL as title",
|
61
|
+
# nl: "\n",
|
62
|
+
# inden: "\t",
|
63
|
+
# eles: [HtmlGen::Element.new("i", str: "Hello world!")
|
61
64
|
# })
|
62
65
|
def initialize(name, args = {})
|
63
|
-
raise "'name' should be a string or a symbol but was a '#{name.class.name}'."if !name.is_a?(String)
|
66
|
+
raise "'name' should be a string or a symbol but was a '#{name.class.name}'."if !name.is_a?(String) && !name.is_a?(Symbol)
|
64
67
|
@name = name
|
65
|
-
|
66
|
-
{:
|
68
|
+
|
69
|
+
{attr: {}, data: {}, classes: [], str_html: "", str: "", css: {}, eles: [], nl: "\n", inden: "\t"}.each do |arg, default_val|
|
67
70
|
if args[arg]
|
68
71
|
instance_variable_set("@#{arg}", args[arg])
|
69
72
|
else
|
70
73
|
instance_variable_set("@#{arg}", default_val)
|
71
74
|
end
|
72
|
-
|
75
|
+
|
73
76
|
args.delete(arg)
|
74
77
|
end
|
75
|
-
|
78
|
+
|
76
79
|
raise "Unknown arguments: '#{args.keys.join(",")}'." if !args.empty?
|
77
80
|
end
|
78
|
-
|
81
|
+
|
79
82
|
#Adds a sub-element to the element.
|
80
83
|
#===Examples
|
81
|
-
# element =
|
84
|
+
# element = HtmlGen::Element.new("a")
|
82
85
|
# another_ele = element.add_ele("b")
|
83
86
|
# another_ele.str = "Hello world!"
|
84
87
|
# element.html #=> "<a>\n\t<b>\n\t\tHello world!\n\t</b>\n</a>\n"
|
85
88
|
def add_ele(name, args = {})
|
86
|
-
ele =
|
89
|
+
ele = HtmlGen::Element.new(name, args.merge(nl: @nl, inden: @inden))
|
87
90
|
@eles << ele
|
88
91
|
return ele
|
89
92
|
end
|
90
|
-
|
93
|
+
|
91
94
|
alias add add_ele
|
92
|
-
|
95
|
+
|
93
96
|
#Add a text-element to the element.
|
94
97
|
def add_str(str)
|
95
|
-
ele =
|
98
|
+
ele = HtmlGen::TextEle.new(str: str, inden: @inden, nl: @nl)
|
96
99
|
@eles << ele
|
97
100
|
return ele
|
98
101
|
end
|
99
|
-
|
102
|
+
|
100
103
|
# Returns the HTML for the element.
|
101
104
|
# To avoid indentation and newlines you can use the 'pretty'-argument:
|
102
|
-
# element.html(:
|
105
|
+
# element.html(pretty: false)
|
103
106
|
def html(args = {})
|
104
107
|
if args[:level]
|
105
108
|
level = args[:level]
|
106
109
|
else
|
107
110
|
level = 0
|
108
111
|
end
|
109
|
-
|
112
|
+
|
110
113
|
if args.key?(:pretty)
|
111
114
|
pretty = args[:pretty]
|
112
115
|
else
|
113
116
|
pretty = true
|
114
117
|
end
|
115
|
-
|
118
|
+
|
116
119
|
#Used for keeping 'pretty'-value and correct indentation according to parent elements.
|
117
|
-
pass_args = {:
|
118
|
-
|
120
|
+
pass_args = {level: (level + 1), pretty: pretty, inden: @inden}
|
121
|
+
|
119
122
|
#Clone the attributes-hash since we are going to add stuff to it, and it shouldnt be reflected (if 'html' is called multiple times, it will bug unless we clone).
|
120
123
|
attr = @attr.clone
|
121
|
-
|
124
|
+
|
122
125
|
#Start generating the string with HTML (possible go give a custom 'str'-variable where the content should be pushed to).
|
123
126
|
if args[:str]
|
124
127
|
str = args[:str]
|
125
128
|
else
|
126
129
|
str = ""
|
127
130
|
end
|
128
|
-
|
129
|
-
str << @inden * level if pretty
|
131
|
+
|
132
|
+
str << @inden * level if pretty && level > 0
|
130
133
|
str << "<#{@name}"
|
131
|
-
|
134
|
+
|
132
135
|
#Add content from the 'css'-hash to the 'style'-attribute in the right format.
|
133
|
-
|
136
|
+
unless @css.empty?
|
134
137
|
style = ""
|
135
138
|
@css.each do |key, val|
|
136
|
-
style << "; "
|
139
|
+
style << "; " unless style.empty?
|
137
140
|
style << "#{key}: #{val};"
|
138
141
|
end
|
139
|
-
|
140
|
-
if attr[:style]
|
141
|
-
attr[:style] << "; "
|
142
|
-
attr[:style] << style
|
142
|
+
|
143
|
+
if attr[:style] && !attr[:style].empty?
|
144
|
+
attr[:style] << "; #{style}"
|
143
145
|
else
|
144
146
|
attr[:style] = style
|
145
147
|
end
|
146
148
|
end
|
147
|
-
|
149
|
+
|
148
150
|
#Add content from the 'classes'-array to the 'class'-attribute in the right format.
|
149
|
-
|
151
|
+
unless @classes.empty?
|
150
152
|
class_str = @classes.join(" ")
|
151
|
-
|
152
|
-
if @attr[:class]
|
153
|
+
|
154
|
+
if @attr[:class] && !@attr[:class].empty?
|
153
155
|
attr[:class] << " #{class_str}"
|
154
156
|
else
|
155
157
|
attr[:class] = class_str
|
156
158
|
end
|
157
159
|
end
|
158
|
-
|
160
|
+
|
159
161
|
#Write out the attributes to the string.
|
160
162
|
attr.each do |key, val|
|
161
|
-
str << " #{key}=\"#{
|
163
|
+
str << " #{key}=\"#{HtmlGen.escape_html(val)}\""
|
162
164
|
end
|
163
|
-
|
165
|
+
|
166
|
+
str << " #{data_attributes(@data, "data")}" if @data.any?
|
167
|
+
|
164
168
|
forbidden_short = FORBIDDEN_SHORT.include?(@name.to_s)
|
165
169
|
skip_pretty = false
|
166
|
-
|
167
|
-
if @eles.empty?
|
170
|
+
|
171
|
+
if @eles.empty? && @str.empty? && @str_html.empty? && !forbidden_short
|
168
172
|
#If no sub-string, sub-HTML or sub-elements are given, we should end the HTML with " />".
|
169
173
|
str << " />"
|
170
174
|
str << @nl if pretty
|
171
175
|
else
|
172
176
|
#Write end-of-element and then all sub-elements.
|
173
177
|
str << ">"
|
174
|
-
|
175
|
-
if @eles.empty?
|
178
|
+
|
179
|
+
if @eles.empty? && @str.empty? && @str_html.empty? && forbidden_short
|
176
180
|
skip_pretty = true
|
177
181
|
end
|
178
|
-
|
179
|
-
str << @nl if pretty
|
180
|
-
|
181
|
-
|
182
|
+
|
183
|
+
str << @nl if pretty && !skip_pretty
|
184
|
+
|
185
|
+
unless @str.empty?
|
182
186
|
str << @inden * (level + 1) if pretty
|
183
|
-
str <<
|
187
|
+
str << HtmlGen.escape_html(@str)
|
184
188
|
str << @nl if pretty
|
185
189
|
end
|
186
|
-
|
187
|
-
|
190
|
+
|
191
|
+
unless @str_html.empty?
|
188
192
|
str << @inden * (level + 1) if pretty
|
189
193
|
str << @str_html
|
190
194
|
str << @nl if pretty
|
191
195
|
end
|
192
|
-
|
196
|
+
|
193
197
|
@eles.each do |subele|
|
194
198
|
str << subele.html(pass_args)
|
195
199
|
end
|
196
|
-
|
197
|
-
str << @inden * level if pretty
|
200
|
+
|
201
|
+
str << @inden * level if pretty && level > 0 && !skip_pretty
|
198
202
|
str << "</#{@name}>"
|
199
203
|
str << @nl if pretty
|
200
204
|
end
|
201
|
-
|
205
|
+
|
202
206
|
#Returns the string.
|
203
207
|
return str
|
204
208
|
end
|
205
|
-
|
209
|
+
|
206
210
|
#Returns the names of all sub-elements in an array.
|
207
211
|
def eles_names
|
208
212
|
names = []
|
209
213
|
@eles.each do |ele|
|
210
214
|
names << ele.name
|
211
215
|
end
|
212
|
-
|
216
|
+
|
213
217
|
return names
|
214
218
|
end
|
215
|
-
|
219
|
+
|
216
220
|
#Converts the content of the 'style'-attribute to css-hash-content.
|
217
221
|
def convert_style_to_css
|
218
222
|
if !@attr[:style].to_s.strip.empty?
|
@@ -222,7 +226,7 @@ class Html_gen::Element
|
|
222
226
|
else
|
223
227
|
raise "No style set in element."
|
224
228
|
end
|
225
|
-
|
229
|
+
|
226
230
|
loop do
|
227
231
|
if match = style.match(/\A\s*(\S+?):\s*(.+?)\s*(;|\Z)/)
|
228
232
|
style.gsub!(match[0], "")
|
@@ -237,4 +241,43 @@ class Html_gen::Element
|
|
237
241
|
end
|
238
242
|
end
|
239
243
|
end
|
240
|
-
|
244
|
+
|
245
|
+
def convert_data_attributes_to_data
|
246
|
+
@attr.delete_if do |key, value|
|
247
|
+
match = key.to_s.match(/\Adata-(.+)\Z/)
|
248
|
+
|
249
|
+
if match
|
250
|
+
data_keys = match[1].split("-")
|
251
|
+
last_key = data_keys.pop
|
252
|
+
|
253
|
+
current_data_element = @data
|
254
|
+
data_keys.each do |key_part|
|
255
|
+
current_data_element = current_data_element[key_part] ||= {}
|
256
|
+
end
|
257
|
+
|
258
|
+
current_data_element[last_key] = value
|
259
|
+
|
260
|
+
true
|
261
|
+
else
|
262
|
+
false
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
private
|
268
|
+
|
269
|
+
def data_attributes(data_hash, prev_key)
|
270
|
+
html = ""
|
271
|
+
data_hash.each do |key, value|
|
272
|
+
if value.is_a?(Hash)
|
273
|
+
html << " " unless html.empty?
|
274
|
+
html << "#{data_attributes(value, "#{prev_key}-#{key}")}"
|
275
|
+
else
|
276
|
+
html << " " unless html.empty?
|
277
|
+
html << "#{prev_key}-#{key}=\"#{HtmlGen.escape_html(value)}\""
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
return html
|
282
|
+
end
|
283
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
1
|
#A simple, lightweight and pure-Ruby class for parsing HTML-strings into elements.
|
2
2
|
#===Examples
|
3
|
-
# doc =
|
3
|
+
# doc = HtmlGen::Parser.new(str: a_html_variable)
|
4
4
|
# html_ele = doc.eles.first
|
5
5
|
# html_ele.name #=> "html"
|
6
|
-
class
|
6
|
+
class HtmlGen::Parser
|
7
7
|
#An array that holds all the parsed root-elements.
|
8
8
|
attr_reader :eles
|
9
|
-
|
9
|
+
|
10
10
|
#The constructor. See class documentation for usage of this.
|
11
11
|
def initialize(args)
|
12
12
|
if args[:io]
|
13
13
|
@io = args[:io]
|
14
14
|
elsif args[:str]
|
15
|
-
@io = StringIO.new(args[:str])
|
15
|
+
@io = ::StringIO.new(args[:str])
|
16
16
|
else
|
17
17
|
raise "Dont know how to handle given arguments."
|
18
18
|
end
|
19
|
-
|
20
|
-
raise "No ':io' was given."
|
19
|
+
|
20
|
+
raise "No ':io' was given." unless @io
|
21
21
|
@eof = false
|
22
22
|
@buffer = ""
|
23
23
|
@eles = []
|
24
24
|
@eles_t = []
|
25
25
|
@debug = args[:debug]
|
26
|
-
|
27
|
-
while !@eof
|
26
|
+
|
27
|
+
while !@eof || !@buffer.empty?
|
28
28
|
parse_tag
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
34
|
#Ensures at least 16kb of data is loaded into the buffer.
|
35
35
|
def ensure_buffer
|
36
|
-
while @buffer.length < 16384
|
36
|
+
while @buffer.length < 16384 && !@eof
|
37
37
|
str = @io.gets(16384)
|
38
38
|
if !str
|
39
39
|
@eof = true
|
@@ -42,31 +42,31 @@ class Html_gen::Parser
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
#Searches for a given regex. If found the contents is removed from the buffer.
|
47
47
|
def search(regex)
|
48
48
|
ensure_buffer
|
49
|
-
|
49
|
+
|
50
50
|
if match = @buffer.match(regex)
|
51
51
|
@buffer.gsub!(regex, "")
|
52
52
|
ensure_buffer
|
53
53
|
return match
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
return false
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
#Asumes a tag is the next to be parsed and adds it to document-data.
|
60
60
|
def parse_tag(args = {})
|
61
61
|
if match = search(/\A\s*<\s*(\/|)\s*(\S+?)(\s+|\/\s*>|>)/)
|
62
62
|
tag_name = match[2].to_s.strip.downcase
|
63
63
|
start_sign = match[1].to_s.strip.downcase
|
64
64
|
end_sign = match[3].to_s.strip.downcase
|
65
|
-
|
66
|
-
raise "Dont know how to handle start-sign: '#{start_sign}' for tag: '#{tag_name}'."
|
67
|
-
|
68
|
-
ele =
|
69
|
-
|
65
|
+
|
66
|
+
raise "Dont know how to handle start-sign: '#{start_sign}' for tag: '#{tag_name}'." unless start_sign.empty?
|
67
|
+
|
68
|
+
ele = HtmlGen::Element.new(tag_name)
|
69
|
+
|
70
70
|
if @eles_t.empty?
|
71
71
|
puts "Adding element '#{tag_name}' to root elements." if @debug
|
72
72
|
@eles << ele
|
@@ -74,10 +74,10 @@ class Html_gen::Parser
|
|
74
74
|
puts "Adding element '#{tag_name}' to last t-element: '#{@eles_t.last.name}'." if @debug
|
75
75
|
@eles_t.last.eles << ele
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
@eles_t << ele
|
79
79
|
puts "New element-match: #{match.to_a}" if @debug
|
80
|
-
|
80
|
+
|
81
81
|
if end_sign.match(/^\/\s*>$/)
|
82
82
|
puts "End of element '#{tag_name}' for '#{@eles_t.last.name}'." if @debug
|
83
83
|
ele = @eles_t.pop
|
@@ -85,7 +85,8 @@ class Html_gen::Parser
|
|
85
85
|
return ele
|
86
86
|
elsif end_sign.to_s.strip.empty?
|
87
87
|
parse_attr_of_tag(ele, tag_name)
|
88
|
-
ele.convert_style_to_css if ele.attr.key?("style")
|
88
|
+
ele.convert_style_to_css if ele.attr.key?("style") || ele.attr.key?(:style)
|
89
|
+
ele.convert_data_attributes_to_data
|
89
90
|
return ele
|
90
91
|
else
|
91
92
|
parse_content_of_tag(ele, tag_name)
|
@@ -99,14 +100,14 @@ class Html_gen::Parser
|
|
99
100
|
end
|
100
101
|
end
|
101
102
|
end
|
102
|
-
|
103
|
+
|
103
104
|
#Parses all attributes of the current tag.
|
104
105
|
def parse_attr_of_tag(ele, tag_name)
|
105
106
|
loop do
|
106
107
|
if match = search(/\A\s*(\S+)=(\"|'|)/)
|
107
108
|
attr_name = match[1]
|
108
109
|
raise "Attribute already exists on element: '#{attr_name}'." if ele.attr.key?(attr_name)
|
109
|
-
|
110
|
+
|
110
111
|
if match[2].to_s.empty?
|
111
112
|
quote_char = /\s+/
|
112
113
|
quote_val = :whitespace
|
@@ -114,9 +115,9 @@ class Html_gen::Parser
|
|
114
115
|
quote_char = /#{Regexp.escape(match[2])}/
|
115
116
|
quote_val = :normal
|
116
117
|
end
|
117
|
-
|
118
|
+
|
118
119
|
attr_val = parse_attr_until_quote(quote_char, quote_val)
|
119
|
-
|
120
|
+
|
120
121
|
puts "Parsed attribute '#{attr_name}' with value '#{attr_val}'." if @debug
|
121
122
|
ele.attr[attr_name] = attr_val
|
122
123
|
elsif search(/\A\s*>/)
|
@@ -127,16 +128,16 @@ class Html_gen::Parser
|
|
127
128
|
end
|
128
129
|
end
|
129
130
|
end
|
130
|
-
|
131
|
+
|
131
132
|
#Parses an attribute-value until a given quote-char is reached.
|
132
133
|
def parse_attr_until_quote(quote_char, quote_val)
|
133
134
|
val = ""
|
134
|
-
|
135
|
+
|
135
136
|
loop do
|
136
137
|
ensure_buffer
|
137
138
|
char = @buffer.slice!(0)
|
138
139
|
break if !char
|
139
|
-
|
140
|
+
|
140
141
|
if char == "\\"
|
141
142
|
val << char
|
142
143
|
val << @buffer.slice!(0)
|
@@ -149,15 +150,15 @@ class Html_gen::Parser
|
|
149
150
|
val << char
|
150
151
|
end
|
151
152
|
end
|
152
|
-
|
153
|
+
|
153
154
|
return val
|
154
155
|
end
|
155
|
-
|
156
|
+
|
156
157
|
#Assumes some content of a tag is next to be parsed and parses it.
|
157
158
|
def parse_content_of_tag(ele, tag_name)
|
158
159
|
raise "Empty tag-name given: '#{tag_name}'." if tag_name.to_s.strip.empty?
|
159
160
|
raise "No 'ele' was given." if !ele
|
160
|
-
|
161
|
+
|
161
162
|
loop do
|
162
163
|
if search(/\A\s*\Z/)
|
163
164
|
raise "Could not find end of tag: '#{tag_name}'."
|
@@ -165,23 +166,23 @@ class Html_gen::Parser
|
|
165
166
|
puts "Found end: '#{match.to_a}' for '#{@eles_t.last.name}'." if @debug
|
166
167
|
ele = @eles_t.pop
|
167
168
|
raise "Expected ele-name to be: '#{tag_name}' but it wasnt: '#{ele.name}'." if ele.name.to_s != tag_name
|
168
|
-
|
169
|
+
|
169
170
|
break
|
170
|
-
elsif new_ele = parse_tag(:
|
171
|
+
elsif new_ele = parse_tag(false: true)
|
171
172
|
puts "Found new element '#{new_ele.name}' and adding it to '#{ele.name}'." if @debug
|
172
173
|
#ele.eles << new_ele
|
173
174
|
elsif match = search(/\A(.+?)(<|\Z)/)
|
174
175
|
puts "Text-content-match: '#{match.to_a}'." if @debug
|
175
|
-
|
176
|
+
|
176
177
|
#Put end back into buffer.
|
177
178
|
@buffer = match[2] + @buffer
|
178
179
|
puts "Buffer after text-match: #{@buffer}" if @debug
|
179
|
-
|
180
|
+
|
180
181
|
#Add text element to list as finished.
|
181
|
-
ele.eles <<
|
182
|
+
ele.eles << HtmlGen::TextEle.new(str: match[1])
|
182
183
|
else
|
183
184
|
raise "Dont know what to do with buffer: '#{@buffer}'."
|
184
185
|
end
|
185
186
|
end
|
186
187
|
end
|
187
|
-
end
|
188
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
class
|
1
|
+
class HtmlGen::TextEle
|
2
2
|
attr_reader :args
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(args)
|
5
5
|
@str = args[:str]
|
6
6
|
@inden = args[:inden]
|
7
7
|
@nl = args[:nl]
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
#Returns the text that this element holds.
|
11
11
|
def str
|
12
12
|
return @str
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
#Returns the text HTML-escaped.
|
16
16
|
def html(args)
|
17
17
|
if args[:level]
|
@@ -19,18 +19,18 @@ class Html_gen::Text_ele
|
|
19
19
|
else
|
20
20
|
level = 0
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
if !args.key?(:pretty) or args[:pretty]
|
24
24
|
pretty = true
|
25
25
|
else
|
26
26
|
pretty = false
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
str = ""
|
30
30
|
str << @inden * level if pretty
|
31
|
-
str <<
|
31
|
+
str << HtmlGen.escape_html(@str)
|
32
32
|
str << @nl if pretty
|
33
|
-
|
33
|
+
|
34
34
|
return str
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
data/shippable.yml
ADDED
@@ -1,25 +1,50 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Parser" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
let(:parser) { HtmlGen::Parser.new(str: "<html><head><title>Test</title></head><body>This is the body</body></html>") }
|
5
|
+
let(:doc) { HtmlGen::Parser.new(str: "<td colspan=\"2\" data-test=\"test-value\" data-nested-test=\"test-nested-keys\" style=\"font-weight: bold;\" width='100px' height=50px>test</td>") }
|
6
|
+
let(:td) { doc.eles.first }
|
7
|
+
|
8
|
+
it "detects a single root element" do
|
9
|
+
parser.eles.length.should eq 1
|
10
|
+
end
|
11
|
+
|
12
|
+
it "detects the head and body element under the html element" do
|
8
13
|
html = parser.eles.first
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
html.eles.length.should eq 2
|
15
|
+
end
|
16
|
+
|
17
|
+
it "reads the head-title element content correct" do
|
18
|
+
head = parser.eles.first.eles.first
|
12
19
|
title = head.eles.first
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
title.name.should eq "title"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "reads the td elements name" do
|
24
|
+
td.name.should eq "td"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "detects html attributes" do
|
28
|
+
td.attr["colspan"].should eq "2"
|
29
|
+
td.attr["width"].should eq "100px"
|
30
|
+
td.attr["height"].should eq "50px"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "detects data attributes" do
|
34
|
+
td.data["test"].should eq "test-value"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "detects nested data key attributes" do
|
38
|
+
td.data["nested"]["test"].should eq "test-nested-keys"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "removes the original attributes" do
|
42
|
+
td.attr["data-test"].should eq nil
|
43
|
+
td.attr["data-nested-test"].should eq nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "detects CSS attributes" do
|
47
|
+
td.css["font-weight"].should eq "bold"
|
48
|
+
td.attr["style"].to_s.empty?.should eq true
|
24
49
|
end
|
25
50
|
end
|
data/spec/html_gen_spec.rb
CHANGED
@@ -1,34 +1,55 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe "HtmlGen" do
|
4
|
-
it "
|
5
|
-
html =
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
html
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
it "generates elements with classes" do
|
5
|
+
html = HtmlGen::Element.new(:td, classes: [:test]).html(pretty: false)
|
6
|
+
html.should eq "<td class=\"test\" />"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "generates elements with attributes" do
|
10
|
+
html = HtmlGen::Element.new(:td, attr: {colspan: 2}).html(pretty: false)
|
11
|
+
html.should eq "<td colspan=\"2\" />"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "generates elements with css attributes" do
|
15
|
+
html = HtmlGen::Element.new(:td, css: {width: "80px"}).html(pretty: false)
|
16
|
+
html.should eq "<td style=\"width: 80px;\" />"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "generates elements with sub elementes" do
|
20
|
+
a = HtmlGen::Element.new(:a)
|
15
21
|
b = a.add_ele(:b)
|
16
22
|
b.str = "Test"
|
17
|
-
|
18
|
-
html = a.html(:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
html
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
|
24
|
+
html = a.html(pretty: false)
|
25
|
+
html.should eq "<a><b>Test</b></a>"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "generates elements with string content and escapes it" do
|
29
|
+
html = HtmlGen::Element.new(:b, str: "<b>Test</b>").html(pretty: false)
|
30
|
+
html.should eq "<b><b>Test</b></b>"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "generates elements with html content and doesn't escape it" do
|
34
|
+
html = HtmlGen::Element.new(:b, str_html: "<b>Test</b>").html(pretty: false)
|
35
|
+
html.should eq "<b><b>Test</b></b>"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "supports mixed elements and string content" do
|
39
|
+
div_ele = HtmlGen::Element.new(:div)
|
28
40
|
div_ele.add_ele(:br)
|
29
41
|
div_ele.add_str("This is a test")
|
30
|
-
|
31
|
-
html = div_ele.html(:
|
32
|
-
|
42
|
+
|
43
|
+
html = div_ele.html(pretty: false)
|
44
|
+
html.should eq "<div><br />This is a test</div>"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "supports data attributes" do
|
48
|
+
div_ele = HtmlGen::Element.new(:div, str: "Test", data: {test: "value"})
|
49
|
+
end
|
50
|
+
|
51
|
+
it "supports nested data attributes" do
|
52
|
+
div_ele = HtmlGen::Element.new(:div, str: "Test", data: {deep: {nested: {test: "value"}}})
|
53
|
+
div_ele.html(pretty: false).should eq "<div data-deep-nested-test=\"value\">Test</div>"
|
33
54
|
end
|
34
55
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
1
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
6
|
require 'rspec'
|
@@ -8,5 +11,4 @@ require 'html_gen'
|
|
8
11
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
12
|
|
10
13
|
RSpec.configure do |config|
|
11
|
-
|
12
14
|
end
|
metadata
CHANGED
@@ -1,116 +1,132 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_gen
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Kasper Johansen
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: string-cases
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
16
28
|
name: rspec
|
17
|
-
requirement:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
22
33
|
version: 2.8.0
|
23
34
|
type: :development
|
24
35
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
27
42
|
name: rdoc
|
28
|
-
requirement:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
version: "3.12"
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
38
56
|
name: bundler
|
39
|
-
requirement:
|
40
|
-
|
41
|
-
requirements:
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
42
59
|
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
60
|
+
- !ruby/object:Gem::Version
|
44
61
|
version: 1.0.0
|
45
62
|
type: :development
|
46
63
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
49
70
|
name: jeweler
|
50
|
-
requirement:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
- !ruby/object:Gem::Version
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
55
75
|
version: 1.8.4
|
56
76
|
type: :development
|
57
77
|
prerelease: false
|
58
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.4
|
59
83
|
description: A small framework for generating HTML.
|
60
84
|
email: k@spernj.org
|
61
85
|
executables: []
|
62
|
-
|
63
86
|
extensions: []
|
64
|
-
|
65
|
-
extra_rdoc_files:
|
87
|
+
extra_rdoc_files:
|
66
88
|
- LICENSE.txt
|
67
|
-
- README.
|
68
|
-
files:
|
69
|
-
- .document
|
70
|
-
- .rspec
|
89
|
+
- README.md
|
90
|
+
files:
|
91
|
+
- ".document"
|
92
|
+
- ".rspec"
|
71
93
|
- Gemfile
|
72
94
|
- Gemfile.lock
|
73
95
|
- LICENSE.txt
|
74
|
-
- README.
|
96
|
+
- README.md
|
75
97
|
- Rakefile
|
76
98
|
- VERSION
|
77
99
|
- html_gen.gemspec
|
78
100
|
- lib/html_gen.rb
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- lib/
|
101
|
+
- lib/html_gen/element.rb
|
102
|
+
- lib/html_gen/parser.rb
|
103
|
+
- lib/html_gen/text_ele.rb
|
104
|
+
- shippable.yml
|
82
105
|
- spec/html_gen_parser_spec.rb
|
83
106
|
- spec/html_gen_spec.rb
|
84
107
|
- spec/spec_helper.rb
|
85
108
|
homepage: http://github.com/kaspernj/html_gen
|
86
|
-
licenses:
|
109
|
+
licenses:
|
87
110
|
- MIT
|
111
|
+
metadata: {}
|
88
112
|
post_install_message:
|
89
113
|
rdoc_options: []
|
90
|
-
|
91
|
-
require_paths:
|
114
|
+
require_paths:
|
92
115
|
- lib
|
93
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
-
|
95
|
-
requirements:
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
96
118
|
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
version: "0"
|
102
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
|
-
requirements:
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
105
123
|
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version:
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
108
126
|
requirements: []
|
109
|
-
|
110
127
|
rubyforge_project:
|
111
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.4.0
|
112
129
|
signing_key:
|
113
|
-
specification_version:
|
130
|
+
specification_version: 4
|
114
131
|
summary: A small framework for generating HTML.
|
115
132
|
test_files: []
|
116
|
-
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= html_gen
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to html_gen
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|