HTML-AutoTag 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8b3e9d049b5f87041ab173a6525b100d9691176
4
- data.tar.gz: 05ff1a5a8e3e8c7dc66e900810d571164c82f246
3
+ metadata.gz: 9fc31c05d334bd5d82c998c2d2c0888e46f1320e
4
+ data.tar.gz: 27001fd038878125cde27b92c8097b3607a0e64f
5
5
  SHA512:
6
- metadata.gz: ca81f53e28caf46f5860ca0d07dddcb0d4bdada52a41e3e4a11bf759d40a5f55972f9a5bb0e222704d1398c15c99e65c845b79f8ca14f6c93ed1d9344ba41340
7
- data.tar.gz: 3d4de05a33d46cf030cca71a3a760f966d3b1d3ef7e6951f72644ae626db09ea301d68b0eb101dc32e2bdc4ce6640e0701d82d7b1127d7ebf71ec478311d79ca
6
+ metadata.gz: 2e99692edea1c4119f7e2252e8ffee650fff90048bc7a4f9d194eb724406fcb9d6a8bf93bec72322d9bf326d97f865525e590070726831b1280dcaeb85c866e2
7
+ data.tar.gz: 56d17d0d3c9dd5ae2c46561b1c79cb18646fb110cb468bfd0fdaa89fdff283656b4cda9c88d1855d4a1b27d015bd1044e20d29bdfe980c7afc0e98308c8a4c99
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ *.gem
data/.travis.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
+ install: gem install htmlentities
2
3
  rvm:
3
4
  - 2.1.0
4
- - jruby-18mode
5
5
  - jruby-19mode
6
6
  - 1.9.3
7
- - 1.8.7
7
+ # - jruby-18mode
8
+ # - 1.8.7
data/Changes ADDED
@@ -0,0 +1,7 @@
1
+ Revision history for html-autotag-ruby
2
+
3
+ 0.0.2
4
+ - added htmlentities
5
+
6
+ 0.0.1
7
+ - First version, released on an unsuspecting world.
data/HTML-AutoTag.gemspec CHANGED
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_dependency "htmlentities"
23
24
  end
data/lib/HTML/AutoAttr.rb CHANGED
@@ -80,7 +80,7 @@ HTML::AutoAttr - Just another HTML attribute generator.
80
80
  require 'HTML/AutoAttr'
81
81
  attr = HTML::AutoAttr.new( { 'foo' => ['bar','baz','qux'] } )
82
82
 
83
- 4.times puts attr.to_s
83
+ 4.times { puts attr.to_s }
84
84
  </code>
85
85
 
86
86
  == DESCRIPTION
data/lib/HTML/AutoTag.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "HTML/AutoTag/version"
2
2
  require "HTML/AutoAttr"
3
+ require "htmlentities"
3
4
 
4
5
  module HTML
5
6
 
@@ -8,12 +9,12 @@ module HTML
8
9
  attr_accessor 'encodes', 'indent', 'level', 'sorted', 'newline'
9
10
 
10
11
  def initialize( params = {} )
11
- @encodes = params['encodes'] || ''
12
+ @encodes = params['encodes'] ? 1 : 0
12
13
  @indent = params['indent'] || ''
13
14
  @level = params['level'] || 0
14
15
  @sorted = params['sorted'] || 0
15
16
  @newline = params['indent'] ? "\n" : ''
16
-
17
+ @encoder = HTMLEntities.new
17
18
  end
18
19
 
19
20
  def tag( params = {} )
@@ -53,8 +54,8 @@ module HTML
53
54
  @level -= 1
54
55
 
55
56
  else
56
- # do encoding here
57
57
  cdata = params['cdata']
58
+ @encoder.encode( cdata ) if @encodes == 1
58
59
  no_post_indent = 1
59
60
  end
60
61
 
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class AutoTag
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/t/02-tag.rb CHANGED
@@ -5,14 +5,14 @@ class TestTag < Test::Unit::TestCase
5
5
 
6
6
  def test_init
7
7
  auto = HTML::AutoTag.new
8
- assert_equal( '', auto.encodes, "no args encodes correct" )
8
+ assert_equal( 0, auto.encodes, "no args encodes correct" )
9
9
  assert_equal( '', auto.indent, "no args indent correct" )
10
10
  assert_equal( 0, auto.level, "no args level correct" )
11
11
  assert_equal( 0, auto.sorted, "no args sorted correct" )
12
12
  assert_equal( '', auto.newline, "no args newline correct" )
13
13
 
14
- auto = HTML::AutoTag.new( 'encodes' => '<=&>', 'indent' => ' ' )
15
- assert_equal( '<=&>', auto.encodes, "encodes set correct" )
14
+ auto = HTML::AutoTag.new( 'encodes' => 1, 'indent' => ' ' )
15
+ assert_equal( 1, auto.encodes, "encodes set correct" )
16
16
  assert_equal( ' ', auto.indent, "indent set correct" )
17
17
  assert_equal( "\n", auto.newline, "newline set correct" )
18
18
  end
@@ -43,4 +43,8 @@ class TestTag < Test::Unit::TestCase
43
43
  assert_equal( " <ol>\n <li>1</li>\n <li>2</li>\n</ol>\n", auto.tag( 'tag' => 'ol', 'cdata' => [{ 'tag' => 'li', 'cdata' => 1 }, { 'tag' => 'li', 'cdata' => 2 }] ), "ol tag correct" )
44
44
  end
45
45
 
46
+ def test_encodes
47
+ auto = HTML::AutoTag.new( 'encodes' => 1 )
48
+ assert_equal( '<p><0></p>', auto.tag( 'tag' => 'p', 'cdata' => '<0>' ), "paragraph tag correct" )
49
+ end
46
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HTML-AutoTag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jeffa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-29 00:00:00.000000000 Z
11
+ date: 2015-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: htmlentities
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Just another HTML tag generator for ruby.
42
56
  email:
43
57
  - jeffa@cpan.org
@@ -47,6 +61,7 @@ extra_rdoc_files: []
47
61
  files:
48
62
  - ".gitignore"
49
63
  - ".travis.yml"
64
+ - Changes
50
65
  - Gemfile
51
66
  - HTML-AutoTag.gemspec
52
67
  - License.md