html 0.0.1 → 0.1.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: da09a50f8846475cb4145bcd212646c53c61ddbf
4
+ data.tar.gz: 3e70f3a5fc6c246274eeb5ccfbbc5b4ca869f47b
5
+ SHA512:
6
+ metadata.gz: f60f69e38d7d84e5469076e71ed69e93208d16ad49657c873b261f7a788ac3ab526cc9a0a7da2312c2c38ba693bb69be8474b461104994aa4b1c85b4d2fb961c
7
+ data.tar.gz: af47fa9cd20ca6eb3488def0cc0ce1982c72872061cc44af8546c25de41664824cb33050ad52e58bd578c826e8f3b5b77174bc420cfa2f5f868c3b8351c75f69
@@ -0,0 +1,4 @@
1
+ ---
2
+ test:
3
+ override:
4
+ - bundle exec rake ci
@@ -1,16 +1,8 @@
1
1
  language: ruby
2
- bundler_args: --without guard
2
+ bundler_args: --without guard
3
3
  script: "bundle exec rake ci"
4
4
  rvm:
5
- - 1.9.2
6
5
  - 1.9.3
7
- - jruby-19mode
8
- - rbx-19mode
9
- allowed_failures:
10
- matrix:
11
- - 1.8.7
12
- - jruby-18mode
13
- - rbx-18mode
14
- notifications:
15
- email:
16
- - mbj@seonic.net
6
+ - 2.0.0
7
+ - jruby
8
+ - rbx-2
data/Gemfile CHANGED
@@ -2,5 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'devtools', :git => 'https://github.com/datamapper/devtools.git'
5
+ gem 'devtools', :git => 'https://github.com/rom-rb/devtools.git'
6
6
  eval File.read('Gemfile.devtools')
@@ -1,55 +1,60 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  group :development do
4
- gem 'rake', '~> 10.0.3'
5
- gem 'rspec', '~> 2.13.0'
6
- gem 'yard', '~> 0.8.5'
4
+ gem 'rake', '~> 10.1.0'
5
+ gem 'rspec', '~> 2.14.1'
6
+ gem 'yard', '~> 0.8.7'
7
+
8
+ platform :rbx do
9
+ gem 'rubysl-singleton', '~> 2.0.0'
10
+ end
7
11
  end
8
12
 
9
13
  group :yard do
10
- gem 'kramdown', '~> 0.14.2'
14
+ gem 'kramdown', '~> 1.3.0'
11
15
  end
12
16
 
13
17
  group :guard do
14
- gem 'guard', '~> 1.6.2'
15
- gem 'guard-bundler', '~> 1.0.0'
16
- gem 'guard-rspec', '~> 2.4.1'
18
+ gem 'guard', '~> 2.3.0'
19
+ gem 'guard-bundler', '~> 2.0.0'
20
+ gem 'guard-rspec', '~> 4.2.0'
21
+ gem 'guard-rubocop', '~> 1.0.0'
17
22
 
18
23
  # file system change event handling
19
- gem 'rb-fchange', '~> 0.0.6', :require => false
20
- gem 'rb-fsevent', '~> 0.9.3', :require => false
21
- gem 'rb-inotify', '~> 0.9.0', :require => false
22
-
23
- gem 'listen', '~> 0.7.3'
24
+ gem 'listen', '~> 2.4.0'
25
+ gem 'rb-fchange', '~> 0.0.6', require: false
26
+ gem 'rb-fsevent', '~> 0.9.3', require: false
27
+ gem 'rb-inotify', '~> 0.9.0', require: false
24
28
 
25
29
  # notification handling
26
- gem 'libnotify', '~> 0.8.0', :require => false
27
- gem 'rb-notifu', '~> 0.0.4', :require => false
28
- gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
30
+ gem 'libnotify', '~> 0.8.0', require: false
31
+ gem 'rb-notifu', '~> 0.0.4', require: false
32
+ gem 'terminal-notifier-guard', '~> 1.5.3', require: false
29
33
  end
30
34
 
31
35
  group :metrics do
32
- gem 'flay', '~> 2.1.0'
33
- gem 'flog', '~> 3.2.2'
34
- gem 'reek', '~> 1.3.1'
35
- gem 'metric_fu-roodi', '~> 2.2.1'
36
- gem 'yardstick', '~> 0.9.3'
36
+ gem 'coveralls', '~> 0.7.0'
37
+ gem 'flay', '~> 2.4.0'
38
+ gem 'flog', '~> 4.2.0'
39
+ gem 'reek', '~> 1.3.2'
40
+ gem 'rubocop', '~> 0.16.0'
41
+ gem 'simplecov', '~> 0.8.2'
42
+ gem 'yardstick', '~> 0.9.9'
37
43
 
38
- platforms :ruby_18, :ruby_19 do
39
- # this indirectly depends on ffi which does not build on ruby-head
40
- gem 'yard-spellcheck', '~> 0.1.5'
44
+ platforms :mri do
45
+ gem 'mutant', '~> 0.3.4'
41
46
  end
42
47
 
43
- platforms :mri_19, :rbx do
44
- gem 'mutant', '~> 0.2.20'
45
- end
46
-
47
- platforms :mri_19 do
48
- gem 'simplecov', '~> 0.7.1'
48
+ platforms :ruby_19, :ruby_20 do
49
+ gem 'yard-spellcheck', '~> 0.1.5'
49
50
  end
50
51
 
51
- platforms :rbx do
52
- gem 'pelusa', '~> 0.2.2'
52
+ platform :rbx do
53
+ gem 'json', '~> 1.8.1'
54
+ gem 'racc', '~> 1.4'
55
+ gem 'rubysl-logger', '~> 2.0.0'
56
+ gem 'rubysl-open-uri', '~> 2.0.0'
57
+ gem 'rubysl-prettyprint', '~> 2.0.2'
53
58
  end
54
59
  end
55
60
 
@@ -59,6 +64,6 @@ end
59
64
 
60
65
  platform :jruby do
61
66
  group :jruby do
62
- gem 'jruby-openssl', '~> 0.8.2'
67
+ gem 'jruby-openssl', '~> 0.8.5'
63
68
  end
64
69
  end
@@ -0,0 +1,3 @@
1
+ test:
2
+ override:
3
+ - bundle exec rake ci
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 14
3
- total_score: 26
3
+ total_score: 28
@@ -7,7 +7,7 @@ UncommunicativeParameterName:
7
7
  - !ruby/regexp /^.$/
8
8
  - !ruby/regexp /[0-9]$/
9
9
  - !ruby/regexp /[A-Z]/
10
- LargeClass:
10
+ TooManyMethods:
11
11
  max_methods: 10
12
12
  exclude: []
13
13
  enabled: true
@@ -51,11 +51,11 @@ NestedIterators:
51
51
  - Adamantium::ModuleMethods#define_memoize_method # 2 levels
52
52
  enabled: true
53
53
  max_allowed_nesting: 1
54
- LongMethod:
54
+ TooManyStatements:
55
55
  max_statements: 7 # TODO: decrease max_statements to 5 or less
56
56
  exclude: []
57
57
  enabled: true
58
- Duplication:
58
+ DuplicateMethodCall:
59
59
  allow_calls: []
60
60
  exclude: []
61
61
  enabled: true
@@ -75,7 +75,7 @@ UncommunicativeVariableName:
75
75
  - !ruby/regexp /^.$/
76
76
  - !ruby/regexp /[0-9]$/
77
77
  - !ruby/regexp /[A-Z]/
78
- SimulatedPolymorphism:
78
+ RepeatedConditional:
79
79
  exclude: []
80
80
  enabled: true
81
81
  max_ifs: 1
@@ -84,7 +84,7 @@ DataClump:
84
84
  enabled: true
85
85
  max_copies: 1
86
86
  min_clump_size: 3
87
- ControlCouple:
87
+ ControlParameter:
88
88
  exclude: []
89
89
  enabled: true
90
90
  LongYieldList:
@@ -2,9 +2,9 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'html'
5
- gem.version = '0.0.1'
5
+ gem.version = '0.1.1'
6
6
  gem.authors = [ 'Markus Schirp' ]
7
- gem.email = [ 'mbj@seonic.net' ]
7
+ gem.email = [ 'mbj@schirp-dso.com' ]
8
8
  gem.description = 'Because HTML is not a String'
9
9
  gem.summary = gem.description
10
10
  gem.homepage = 'https://github.com/mbj/html'
@@ -12,9 +12,9 @@ Gem::Specification.new do |gem|
12
12
  gem.require_paths = [ 'lib' ]
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.test_files = `git ls-files -- spec`.split("\n")
15
+ gem.license = 'MIT'
15
16
  gem.extra_rdoc_files = %w[TODO]
16
17
 
17
- gem.add_runtime_dependency('backports', [ '~> 3.0', '>= 3.0.3' ])
18
- gem.add_runtime_dependency('adamantium', '~> 0.0.7')
19
- gem.add_runtime_dependency('equalizer', '~> 0.0.5')
18
+ gem.add_runtime_dependency('adamantium', '~> 0.1.0')
19
+ gem.add_runtime_dependency('equalizer', '~> 0.0.9')
20
20
  end
@@ -1,5 +1,5 @@
1
1
  #encoding: utf-8
2
- require 'backports'
2
+
3
3
  require 'adamantium'
4
4
  require 'equalizer'
5
5
  require 'ice_nine'
@@ -9,13 +9,13 @@ module HTML
9
9
 
10
10
  CONTENT_TAGS = IceNine.deep_freeze(%w(
11
11
  a abbr address article aside audio b bdi bdo blockquote
12
- body button canvas caption cite code col colgroup data
13
- dd del details dfn div dl dt em embed eventsource fieldset
14
- fieldsource figcaption figure footer form h1 h2 h3 h4 h5 h6
15
- head header hgroup html i iframe ins kbd label legend li link
16
- mark menu nav noscript object ol optgroup option output p pre
17
- q ruby rp rt s samp script section select small span strong
18
- style sub summary sup table tbody textarea tfoot th thead time
12
+ body button canvas caption cite code col colgroup data
13
+ dd del details dfn div dl dt em embed eventsource fieldset
14
+ fieldsource figcaption figure footer form h1 h2 h3 h4 h5 h6
15
+ head header hgroup html i iframe ins kbd label legend li link
16
+ mark menu nav noscript object ol optgroup option output p pre
17
+ q ruby rp rt s samp script section select small span strong
18
+ style sub summary sup table tbody textarea tfoot th thead time
19
19
  title td tr ul var video
20
20
  ))
21
21
 
@@ -33,12 +33,18 @@ module HTML
33
33
  # @api private
34
34
  #
35
35
  def self.join(components)
36
- contents = components.map do |component|
36
+ contents = components.map do |component|
37
37
  Fragment.build(component)
38
38
  end
39
39
  Fragment.new(contents.join)
40
40
  end
41
41
 
42
+ ESCAPE_TABLE = IceNine.deep_freeze(
43
+ '>' => '<',
44
+ '<' => '&gt;',
45
+ '"' => '&quot;',
46
+ '&' => '&amp;'
47
+ )
42
48
 
43
49
  # Escape html
44
50
  #
@@ -50,13 +56,10 @@ module HTML
50
56
  #
51
57
  def self.escape(text)
52
58
  text.gsub(
53
- /[><"]/,
54
- '>' => '&lt;',
55
- '<' => '&gt;',
56
- '"' => '&amp;'
59
+ /[><"&]/, ESCAPE_TABLE
57
60
  )
58
61
  end
59
-
62
+
60
63
  CONTENT_TAGS.each do |name|
61
64
  class_eval(<<-RUBY, __FILE__, __LINE__)
62
65
  def self.#{name}(*args)
@@ -86,7 +89,7 @@ module HTML
86
89
  Fragment.new("<#{type}#{attributes(attributes)}/>")
87
90
  end
88
91
 
89
- # Create content tag
92
+ # Create content tag
90
93
  #
91
94
  # @param [#to_str] type
92
95
  # @param [String] content
@@ -96,7 +99,7 @@ module HTML
96
99
  # @api private
97
100
  #
98
101
  def self.content_tag(type, content, attributes={})
99
- Fragment.new("<#{type}#{attributes(attributes)}>#{Fragment.build(content).to_s}</#{type}>")
102
+ Fragment.new("<#{type}#{attributes(attributes)}>#{Fragment.build(content)}</#{type}>")
100
103
  end
101
104
 
102
105
  # Create html attributes
@@ -109,7 +112,7 @@ module HTML
109
112
  #
110
113
  def self.attributes(attributes)
111
114
  attributes.map do |key, value|
112
- %Q{ #{key.to_s}="#{escape(value.to_s)}"}
115
+ %Q{ #{key}="#{escape(value.to_s)}"}
113
116
  end.join
114
117
  end
115
118
  end
@@ -24,7 +24,7 @@ module HTML
24
24
  @content = string
25
25
  end
26
26
 
27
- # Return string
27
+ # Return string
28
28
  #
29
29
  # FIXME: This will be removed once I have my own templating language.
30
30
  #
@@ -32,14 +32,29 @@ module HTML
32
32
  #
33
33
  alias_method :to_s, :content
34
34
 
35
+ # Enumerate contents
36
+ #
37
+ # The idea is to make it compatible with a rack body.
38
+ #
39
+ # @return [self]
40
+ # if block given
41
+ #
42
+ # @api private
43
+ #
44
+ def each
45
+ return to_enum unless block_given?
46
+ yield content
47
+ self
48
+ end
49
+
35
50
  # Create new fragment
36
51
  #
37
52
  # @param [String,Fragment] input
38
- #
53
+ #
39
54
  # @return [Fragment]
40
55
  #
41
56
  # @api private
42
- #
57
+ #
43
58
  def self.build(input)
44
59
  if input.kind_of?(self)
45
60
  input
@@ -49,6 +64,6 @@ module HTML
49
64
  end
50
65
 
51
66
  EMPTY = new('')
52
- end
53
67
 
54
- end
68
+ end # Fragment
69
+ end # HTML
@@ -1,11 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'html'
4
- require 'rspec'
5
-
6
- # require spec support files and shared behavior
7
- Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each { |f| require f }
8
-
9
-
10
- RSpec.configure do |config|
11
- end
4
+ require 'devtools'
5
+ require 'devtools/spec_helper'
@@ -7,7 +7,8 @@ describe HTML, '.attributes' do
7
7
 
8
8
  examples = {
9
9
  { 'foo' => 'bar' } => ' foo="bar"',
10
- { 'foo' => '"' } => ' foo="&amp;"',
10
+ { 'foo' => '"' } => ' foo="&quot;"',
11
+ { 'foo' => '&' } => ' foo="&amp;"',
11
12
  { :class => :baz } => ' class="baz"'
12
13
  }
13
14
 
@@ -16,6 +16,16 @@ describe HTML, '.tag' do
16
16
  end
17
17
  end
18
18
 
19
+ context 'with plaintext content' do
20
+ let(:arguments) { [ name, content] }
21
+
22
+ let(:content) { '<foo>' }
23
+
24
+ it 'should return html fragment wrapping excapted content' do
25
+ should eql(HTML::Fragment.new('<foo>&gt;foo&lt;</foo>'))
26
+ end
27
+ end
28
+
19
29
  context 'with attributes' do
20
30
  let(:arguments) { [ name, content, attributes ] }
21
31
 
@@ -9,7 +9,7 @@ describe HTML, '.escape' do
9
9
  'foo' => 'foo',
10
10
  '<>' => '&gt;&lt;',
11
11
  '<foo>' => '&gt;foo&lt;',
12
- '<foo bar="baz">' => '&gt;foo bar=&amp;baz&amp;&lt;'
12
+ '<foo bar="baz">' => '&gt;foo bar=&quot;baz&quot;&lt;'
13
13
  }
14
14
 
15
15
  examples.each do |input, expectation|
@@ -15,7 +15,7 @@ describe HTML::Fragment, '.build' do
15
15
  end
16
16
 
17
17
  context 'when input is HTML::Fragment' do
18
- let(:input) { HTML::Fragment.new(mock) }
18
+ let(:input) { HTML::Fragment.new(double) }
19
19
 
20
20
  it 'should be input' do
21
21
  should be(input)
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe HTML::Fragment, '#each' do
4
+ let(:yields) { [] }
5
+
6
+ let(:object) { described_class.new(chunk) }
7
+
8
+ let(:chunk) { double('Chunk') }
9
+
10
+ context 'with block' do
11
+ subject { object.each { |chunk| yields << chunk } }
12
+
13
+ it 'should enumerate chunks' do
14
+ expect { subject }.to change { yields }.from([]).to([chunk])
15
+ end
16
+
17
+ it_should_behave_like 'a command method'
18
+ end
19
+
20
+ context 'without block' do
21
+ subject { object.each }
22
+
23
+ it { should be_a(Enumerator) }
24
+
25
+ its(:to_a) { should eql([chunk]) }
26
+ end
27
+ end
metadata CHANGED
@@ -1,92 +1,67 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Markus Schirp
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-01 00:00:00.000000000 Z
11
+ date: 2014-02-16 00:00:00.000000000 Z
13
12
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: backports
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '3.0'
22
- - - ! '>='
23
- - !ruby/object:Gem::Version
24
- version: 3.0.3
25
- type: :runtime
26
- prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '3.0'
33
- - - ! '>='
34
- - !ruby/object:Gem::Version
35
- version: 3.0.3
36
13
  - !ruby/object:Gem::Dependency
37
14
  name: adamantium
38
15
  requirement: !ruby/object:Gem::Requirement
39
- none: false
40
16
  requirements:
41
- - - ~>
17
+ - - "~>"
42
18
  - !ruby/object:Gem::Version
43
- version: 0.0.7
19
+ version: 0.1.0
44
20
  type: :runtime
45
21
  prerelease: false
46
22
  version_requirements: !ruby/object:Gem::Requirement
47
- none: false
48
23
  requirements:
49
- - - ~>
24
+ - - "~>"
50
25
  - !ruby/object:Gem::Version
51
- version: 0.0.7
26
+ version: 0.1.0
52
27
  - !ruby/object:Gem::Dependency
53
28
  name: equalizer
54
29
  requirement: !ruby/object:Gem::Requirement
55
- none: false
56
30
  requirements:
57
- - - ~>
31
+ - - "~>"
58
32
  - !ruby/object:Gem::Version
59
- version: 0.0.5
33
+ version: 0.0.9
60
34
  type: :runtime
61
35
  prerelease: false
62
36
  version_requirements: !ruby/object:Gem::Requirement
63
- none: false
64
37
  requirements:
65
- - - ~>
38
+ - - "~>"
66
39
  - !ruby/object:Gem::Version
67
- version: 0.0.5
40
+ version: 0.0.9
68
41
  description: Because HTML is not a String
69
42
  email:
70
- - mbj@seonic.net
43
+ - mbj@schirp-dso.com
71
44
  executables: []
72
45
  extensions: []
73
46
  extra_rdoc_files:
74
47
  - TODO
75
48
  files:
76
- - .gitignore
77
- - .rspec
78
- - .travis.yml
49
+ - ".circle.yml"
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".travis.yml"
79
53
  - Changelog.md
80
54
  - Gemfile
81
55
  - Gemfile.devtools
82
56
  - README.md
83
57
  - Rakefile
84
58
  - TODO
59
+ - circle.yml
85
60
  - config/flay.yml
86
61
  - config/flog.yml
87
62
  - config/mutant.yml
63
+ - config/reek.yml
88
64
  - config/roodi.yml
89
- - config/site.reek
90
65
  - config/yardstick.yml
91
66
  - html.gemspec
92
67
  - lib/html.rb
@@ -100,30 +75,31 @@ files:
100
75
  - spec/unit/html/class_methods/nocontent_tags_spec.rb
101
76
  - spec/unit/html/class_methods/tag_spec.rb
102
77
  - spec/unit/html/fragment/class_methods/build_spec.rb
78
+ - spec/unit/html/fragment/each_spec.rb
103
79
  - spec/unit/html/fragment/initialize_spec.rb
104
80
  homepage: https://github.com/mbj/html
105
- licenses: []
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
106
84
  post_install_message:
107
85
  rdoc_options: []
108
86
  require_paths:
109
87
  - lib
110
88
  required_ruby_version: !ruby/object:Gem::Requirement
111
- none: false
112
89
  requirements:
113
- - - ! '>='
90
+ - - ">="
114
91
  - !ruby/object:Gem::Version
115
92
  version: '0'
116
93
  required_rubygems_version: !ruby/object:Gem::Requirement
117
- none: false
118
94
  requirements:
119
- - - ! '>='
95
+ - - ">="
120
96
  - !ruby/object:Gem::Version
121
97
  version: '0'
122
98
  requirements: []
123
99
  rubyforge_project:
124
- rubygems_version: 1.8.23
100
+ rubygems_version: 2.2.0
125
101
  signing_key:
126
- specification_version: 3
102
+ specification_version: 4
127
103
  summary: Because HTML is not a String
128
104
  test_files:
129
105
  - spec/spec_helper.rb
@@ -135,5 +111,5 @@ test_files:
135
111
  - spec/unit/html/class_methods/nocontent_tags_spec.rb
136
112
  - spec/unit/html/class_methods/tag_spec.rb
137
113
  - spec/unit/html/fragment/class_methods/build_spec.rb
114
+ - spec/unit/html/fragment/each_spec.rb
138
115
  - spec/unit/html/fragment/initialize_spec.rb
139
- has_rdoc: