sixarm_ruby_rexml_element_new_with_options 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +1 -0
- data/.gemtest +0 -0
- data/README.md +71 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/lib/sixarm_ruby_rexml_element_new_with_options.rb +84 -0
- data/test/sixarm_ruby_rexml_element_new_with_options_test.rb +95 -0
- metadata +78 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
P��&��r4|MRgѴ�|�EP@��g�c�6��Z��5�Y�#���Bi�o�̣�
|
data/.gemtest
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# SixArm.com » Ruby » <br> REXML::Element.new_with_options methods to build elements
|
2
|
+
|
3
|
+
* Docs: <http://sixarm.com/sixarm_ruby_rexml_element_new_with_options/doc>
|
4
|
+
* Repo: <http://github.com/sixarm/sixarm_ruby_rexml_element_new_with_options>
|
5
|
+
* Email: Joel Parker Henderson, <joel@sixarm.com>
|
6
|
+
|
7
|
+
|
8
|
+
## Introduction
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
## Quickstart
|
13
|
+
|
14
|
+
Install:
|
15
|
+
|
16
|
+
gem install sixarm_ruby_rexml_element_new_with_options
|
17
|
+
|
18
|
+
Bundler:
|
19
|
+
|
20
|
+
gem "sixarm_ruby_rexml_element_new_with_options", "=1.2.0"
|
21
|
+
|
22
|
+
Require:
|
23
|
+
|
24
|
+
require "sixarm_ruby_rexml_element_new_with_options"
|
25
|
+
|
26
|
+
|
27
|
+
## Install with high security (optional)
|
28
|
+
|
29
|
+
To enable high security for all our gems:
|
30
|
+
|
31
|
+
wget http://sixarm.com/sixarm.pem
|
32
|
+
gem cert --add sixarm.pem
|
33
|
+
gem sources --add http://sixarm.com
|
34
|
+
|
35
|
+
To install with high security:
|
36
|
+
|
37
|
+
gem install sixarm_ruby_rexml_element_new_with_options --test --trust-policy HighSecurity
|
38
|
+
|
39
|
+
|
40
|
+
## Changes
|
41
|
+
|
42
|
+
* 2012-03-18 1.2.0 Lift from SixArm HTX
|
43
|
+
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
You may choose any of these open source licenses:
|
48
|
+
|
49
|
+
* Apache License
|
50
|
+
* BSD License
|
51
|
+
* CreativeCommons License, Non-commercial Share Alike
|
52
|
+
* GNU General Public License Version 2 (GPL 2)
|
53
|
+
* GNU Lesser General Public License (LGPL)
|
54
|
+
* MIT License
|
55
|
+
* Perl Artistic License
|
56
|
+
* Ruby License
|
57
|
+
|
58
|
+
The software is provided "as is", without warranty of any kind,
|
59
|
+
express or implied, including but not limited to the warranties of
|
60
|
+
merchantability, fitness for a particular purpose and noninfringement.
|
61
|
+
|
62
|
+
In no event shall the authors or copyright holders be liable for any
|
63
|
+
claim, damages or other liability, whether in an action of contract,
|
64
|
+
tort or otherwise, arising from, out of or in connection with the
|
65
|
+
software or the use or other dealings in the software.
|
66
|
+
|
67
|
+
This license is for the included software that is created by SixArm;
|
68
|
+
some of the included software may have its own licenses, copyrights,
|
69
|
+
authors, etc. and these do take precedence over the SixArm license.
|
70
|
+
|
71
|
+
Copyright (c) 2005-2012 Joel Parker Henderson
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin rdoc
|
3
|
+
Please see README
|
4
|
+
=end
|
5
|
+
|
6
|
+
require 'rexml/document'
|
7
|
+
|
8
|
+
module REXML
|
9
|
+
|
10
|
+
class Element
|
11
|
+
|
12
|
+
# Create a new Element with options:
|
13
|
+
#
|
14
|
+
# * name
|
15
|
+
# * attributes
|
16
|
+
# * text
|
17
|
+
# * children
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
#
|
21
|
+
# e = Element.new_with_options(:name => "foo", :text => "bar")
|
22
|
+
# #=> element with name "foo" and text "bar"
|
23
|
+
#
|
24
|
+
# @return the new Element
|
25
|
+
|
26
|
+
def self.new_with_options(ops={})
|
27
|
+
e = Element.new(ops[:name])
|
28
|
+
if ops[:attributes] then e.add_attributes(ops[:attributes]) end
|
29
|
+
if ops[:text] then e.add_text(ops[:text]) end
|
30
|
+
if ops[:children] then ops[:children].each {|child| e << child } end
|
31
|
+
return e
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# Create a new Element as a "td" table data cell.
|
36
|
+
#
|
37
|
+
# * name defaults to "td"
|
38
|
+
# * attributes
|
39
|
+
# * text
|
40
|
+
# * children
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
#
|
44
|
+
# e = Element.new_with_options_as_td(:text => "bar")
|
45
|
+
# #=> element with name "td" and text "bar"
|
46
|
+
#
|
47
|
+
# @return the new Element
|
48
|
+
|
49
|
+
def self.new_with_options_as_td(ops={})
|
50
|
+
return new_with_options({:name => 'td'}.merge(ops))
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# Create a new Element with options as a "tr" table row:
|
55
|
+
#
|
56
|
+
# * name defaults to "tr"
|
57
|
+
# * attributes
|
58
|
+
# * text
|
59
|
+
# * children
|
60
|
+
# * cells: maps each cell's string to a new child Element using new_with_options_td
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
#
|
64
|
+
# e = Element.new_with_options_as_tr(:text => "bar")
|
65
|
+
# #=> element with name=="tr" and text=="bar"
|
66
|
+
#
|
67
|
+
# @example of table cells:
|
68
|
+
#
|
69
|
+
# e = Element.new_with_options_as_tr(:cells => ["a", "b", "c"])
|
70
|
+
# #=> element with name=="tr" and children with text "a", "b", "c"
|
71
|
+
#
|
72
|
+
# @return the new Element
|
73
|
+
|
74
|
+
def self.new_with_options_as_tr(ops={})
|
75
|
+
if ops[:cells]
|
76
|
+
ops[:children] ||= []
|
77
|
+
ops[:children] = ops[:cells].map{|cell| Element.new_with_options_as_td(:text => cell)}
|
78
|
+
end
|
79
|
+
return new_with_options({:name => 'tr'}.merge(ops))
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'sixarm_ruby_rexml_element_new_with_options'
|
6
|
+
require 'pathname'
|
7
|
+
|
8
|
+
describe REXML::Element do
|
9
|
+
|
10
|
+
before do
|
11
|
+
NAME ||= "foo"
|
12
|
+
TEXT ||= "bar"
|
13
|
+
CHILDREN ||= [REXML::Element.new, REXML::Element.new, REXML::Element.new]
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".new_with_options" do
|
17
|
+
|
18
|
+
it "with defaults" do
|
19
|
+
e = REXML::Element.new_with_options
|
20
|
+
e.name.must_equal nil
|
21
|
+
e.get_text.to_s.must_equal ""
|
22
|
+
e.elements.to_a.must_equal []
|
23
|
+
end
|
24
|
+
|
25
|
+
it "with name" do
|
26
|
+
e = REXML::Element.new_with_options(:name => NAME)
|
27
|
+
e.name.must_equal NAME
|
28
|
+
end
|
29
|
+
|
30
|
+
it "with text" do
|
31
|
+
e = REXML::Element.new_with_options(:text => TEXT)
|
32
|
+
e.get_text.to_s.must_equal TEXT
|
33
|
+
end
|
34
|
+
|
35
|
+
it "with children" do
|
36
|
+
e = REXML::Element.new_with_options(:children => CHILDREN)
|
37
|
+
e.elements.to_a.must_equal CHILDREN
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ".new_with_options_as_td" do
|
43
|
+
|
44
|
+
it "with defaults" do
|
45
|
+
e = REXML::Element.new_with_options_as_td
|
46
|
+
e.name.must_equal "td"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "with name" do
|
50
|
+
e = REXML::Element.new_with_options(:name => NAME)
|
51
|
+
e.name.must_equal NAME
|
52
|
+
end
|
53
|
+
|
54
|
+
it "with text" do
|
55
|
+
e = REXML::Element.new_with_options_as_td(:text => TEXT)
|
56
|
+
e.get_text.to_s.must_equal TEXT
|
57
|
+
end
|
58
|
+
|
59
|
+
it "with children" do
|
60
|
+
e = REXML::Element.new_with_options_as_td(:children => CHILDREN)
|
61
|
+
e.elements.to_a.must_equal CHILDREN
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
describe ".new_with_options_as_tr" do
|
67
|
+
|
68
|
+
it "with defaults" do
|
69
|
+
e = REXML::Element.new_with_options_as_tr
|
70
|
+
e.name.must_equal "tr"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "with name" do
|
74
|
+
e = REXML::Element.new_with_options_as_tr(:name => NAME)
|
75
|
+
e.name.must_equal NAME
|
76
|
+
end
|
77
|
+
|
78
|
+
it "with text" do
|
79
|
+
e = REXML::Element.new_with_options_as_tr(:text => TEXT)
|
80
|
+
e.get_text.to_s.must_equal TEXT
|
81
|
+
end
|
82
|
+
|
83
|
+
it "with children" do
|
84
|
+
e = REXML::Element.new_with_options_as_tr(:children => CHILDREN)
|
85
|
+
e.elements.to_a.must_equal CHILDREN
|
86
|
+
end
|
87
|
+
|
88
|
+
it "with cells" do
|
89
|
+
cells = ["t0", "t1", "t2"]
|
90
|
+
e = REXML::Element.new_with_options_as_tr(:cells => cells)
|
91
|
+
e.elements.to_a.map{|x| x.get_text.to_s}.must_equal cells
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sixarm_ruby_rexml_element_new_with_options
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SixArm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- !binary |-
|
13
|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JRelBKdHFtU2djNTNlRE43YVN6RFF3cjlUQUxLRmtwR0l3WURFTE1B
|
29
|
+
a0dBMVVFQmhNQ1ZWTXhFekFSQmdOVgpCQWdUQ2tOaGJHbG1iM0p1YVdFeEZq
|
30
|
+
QVVCZ05WQkFjVERWTmhiaUJHY21GdVkybHpZMjh4RHpBTkJnTlZCQW9UCkJs
|
31
|
+
TnBlRUZ5YlRFVE1CRUdBMVVFQXhNS2MybDRZWEp0TG1OdmJZSUpBS1B3RUVU
|
32
|
+
VTViSG9NQXdHQTFVZEV3UUYKTUFNQkFmOHdEUVlKS29aSWh2Y05BUUVGQlFB
|
33
|
+
RGdZRUFvb0VleFAvb1BhbTFUUDcxU3l1aHhNYit1VHJaYlNRZQpqVkIrRXhS
|
34
|
+
d1dhZEd3YU5QVUE1NmQzOXF3YXZ3UCtpdSszSnBlb25OTVZ2YldYRjVuYUNY
|
35
|
+
L2RORkllUkVIekVSClpEUlFZTXFydTlURU1uYTZIRDl6cGNzdEY3dndUaEdv
|
36
|
+
dmxPUSszWTZwbFE0bk16aXBYY1o5VEhxczY1UElMMHEKZWFid3BDYkFvcG89
|
37
|
+
Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
38
|
+
date: 2012-03-20 00:00:00.000000000 Z
|
39
|
+
dependencies: []
|
40
|
+
description:
|
41
|
+
email: sixarm@sixarm.com
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- .gemtest
|
47
|
+
- Rakefile
|
48
|
+
- README.md
|
49
|
+
- VERSION
|
50
|
+
- lib/sixarm_ruby_rexml_element_new_with_options.rb
|
51
|
+
- test/sixarm_ruby_rexml_element_new_with_options_test.rb
|
52
|
+
homepage: http://sixarm.com/
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.19
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: SixArm.com » Ruby » REXML::Element.new_with_options methods
|
76
|
+
test_files:
|
77
|
+
- test/sixarm_ruby_rexml_element_new_with_options_test.rb
|
78
|
+
has_rdoc: true
|
metadata.gz.sig
ADDED
Binary file
|