thamble 1.0.1 → 1.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: 674b700a5f07e27ada5e85adab98df86eb5d2dd4
4
- data.tar.gz: 88a0b5d550fe90015acdec05e694602c0cbf4ca3
3
+ metadata.gz: 7a2fd83722900bb09ea99100682d44f292daa222
4
+ data.tar.gz: b553cf68c0e2e739e214679686de413fe94a341e
5
5
  SHA512:
6
- metadata.gz: c10aeff24db26692c481930b1f0aa06870b5a5a1997a9f1271bcc7f51d3b2e83d97ae85029bdf3ea85ac5fec64cb7d548db421e1a2a52c283d23a44c7b4c90c2
7
- data.tar.gz: 78233ad0d0952eae9bf0cdefc68d0694bdfd1e0f7ada6e9d81d761b36a19ec547b52b26933d2586e151fbcc8e40c4a6f44abac86aa1d92c6d58d622f29eba88c
6
+ metadata.gz: 65df2f5381247e83eacdc4232fca2bca9c49f2b8f1008370099e93e7016403a7a10b24879ab08bc0cd385fd1f566090d44360db8e30b2ef95cb5dd259570b87c
7
+ data.tar.gz: e74e10005826799250ffafdb3039abaa7fc350267727a1ccececc6b439d20d9d349a5615d009b47be2862c8c7a0663515836f8fb89636b1a7d3ab80f051b191a
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.2 (2016-01-28)
2
+
3
+ * Add support for running with --enable-frozen-string-literal on ruby 2.3 (jeremyevans)
4
+
1
5
  === 1.0.1 (2015-01-27)
2
6
 
3
7
  * Fix homepage in gemspec (jeremyevans) (#1)
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013,2014 Jeremy Evans
1
+ Copyright (c) 2013-2016 Jeremy Evans
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to
data/Rakefile CHANGED
@@ -10,36 +10,13 @@ end
10
10
 
11
11
  ### Specs
12
12
 
13
- begin
14
- begin
15
- # RSpec 1
16
- require "spec/rake/spectask"
17
- spec_class = Spec::Rake::SpecTask
18
- spec_files_meth = :spec_files=
19
- rescue LoadError
20
- # RSpec 2
21
- require "rspec/core/rake_task"
22
- spec_class = RSpec::Core::RakeTask
23
- spec_files_meth = :pattern=
24
- end
25
-
26
- spec = lambda do |name, files, d|
27
- lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib')
28
- ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir)
29
- desc d
30
- spec_class.new(name) do |t|
31
- t.send(spec_files_meth, files)
32
- end
33
- end
34
-
35
- task :default => [:spec]
36
- spec.call("spec", Dir["spec/*_spec.rb"], "Run specs")
37
- rescue LoadError
38
- task :default do
39
- puts "Must install rspec to run the default task (which runs specs)"
40
- end
13
+ desc "Run specs"
14
+ task :spec do
15
+ sh "#{FileUtils::RUBY} -rubygems -I lib spec/thamble_spec.rb"
41
16
  end
42
17
 
18
+ task :default => :spec
19
+
43
20
  ### RDoc
44
21
 
45
22
  RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'Thamble: Create HTML Tables from Enumerables']
data/lib/thamble/rails.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require 'thamble'
2
4
  require 'active_support/core_ext/string/output_safety'
3
5
  ActiveSupport::SafeBuffer.send(:include, Thamble::Raw)
data/lib/thamble.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require 'rack/utils'
2
4
 
3
5
  # Thamble exposes a single method named table to make it easy to generate
@@ -61,7 +63,7 @@ module Thamble
61
63
  td_attr = @opts[:td]
62
64
 
63
65
  t = tag('table', empty, @opts[:table])
64
- s = t.open
66
+ s = t.open.dup
65
67
  s << nl
66
68
 
67
69
  if caption = @opts[:caption]
data/spec/thamble_spec.rb CHANGED
@@ -1,16 +1,6 @@
1
1
  require 'rubygems'
2
2
  require File.join(File.dirname(File.expand_path(__FILE__)), '../lib/thamble')
3
-
4
- if defined?(RSpec)
5
- require 'rspec/version'
6
- if RSpec::Version::STRING >= '2.11.0'
7
- RSpec.configure do |config|
8
- config.expect_with :rspec do |c|
9
- c.syntax = :should
10
- end
11
- end
12
- end
13
- end
3
+ require 'minitest/autorun'
14
4
 
15
5
  describe "Thamble.table" do
16
6
  def table(*a, &block)
@@ -18,70 +8,70 @@ describe "Thamble.table" do
18
8
  end
19
9
 
20
10
  it 'should return string with HTML table for enumerable' do
21
- table([[1, 2]]).should == '<table><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
11
+ table([[1, 2]]).must_equal '<table><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
22
12
  end
23
13
 
24
14
  it 'should support :headers option for the headers' do
25
- table([[1, 2]], :headers=>%w'a b').should == '<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
15
+ table([[1, 2]], :headers=>%w'a b').must_equal '<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
26
16
  end
27
17
 
28
18
  it 'should support :headers option as a string with comma separators' do
29
- table([[1, 2]], :headers=>'a,b').should == '<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
19
+ table([[1, 2]], :headers=>'a,b').must_equal '<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
30
20
  end
31
21
 
32
22
  it 'should support :widths option for setting width for each column' do
33
- table([[1, 2]], :widths=>[3,4]).should == '<table><colgroup><col width="3" /><col width="4" /></colgroup><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
23
+ table([[1, 2]], :widths=>[3,4]).must_equal '<table><colgroup><col width="3" /><col width="4" /></colgroup><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
34
24
  end
35
25
 
36
26
  it 'should yield each object in enumerable to block to return data row to use' do
37
- table([[1, 2]]){|l, t| l.map{|i| i*2}}.should == '<table><tbody><tr><td>2</td><td>4</td></tr></tbody></table>'
27
+ table([[1, 2]]){|l, t| l.map{|i| i*2}}.must_equal '<table><tbody><tr><td>2</td><td>4</td></tr></tbody></table>'
38
28
  end
39
29
 
40
30
  it 'should be able to create tags using the table.tag method' do
41
- table([[1, 2]]){|l, t| l.map{|i| t.tag(:b, i*2)}}.should == '<table><tbody><tr><td><b>2</b></td><td><b>4</b></td></tr></tbody></table>'
42
- table([[1, 2]]){|l, t| l.map{|i| t.tag(:b, i*2, i=>i)}}.should == '<table><tbody><tr><td><b 1="1">2</b></td><td><b 2="2">4</b></td></tr></tbody></table>'
31
+ table([[1, 2]]){|l, t| l.map{|i| t.tag(:b, i*2)}}.must_equal '<table><tbody><tr><td><b>2</b></td><td><b>4</b></td></tr></tbody></table>'
32
+ table([[1, 2]]){|l, t| l.map{|i| t.tag(:b, i*2, i=>i)}}.must_equal '<table><tbody><tr><td><b 1="1">2</b></td><td><b 2="2">4</b></td></tr></tbody></table>'
43
33
  end
44
34
 
45
35
  it 'should be able to create links using the table.a method' do
46
- table([[1, 2]]){|l, t| l.map{|i| t.a(i*2, 'foo')}}.should == '<table><tbody><tr><td><a href="foo">2</a></td><td><a href="foo">4</a></td></tr></tbody></table>'
47
- table([[1, 2]]){|l, t| l.map{|i| t.a(i*2, 'foo', i=>i)}}.should == '<table><tbody><tr><td><a 1="1" href="foo">2</a></td><td><a 2="2" href="foo">4</a></td></tr></tbody></table>'
36
+ table([[1, 2]]){|l, t| l.map{|i| t.a(i*2, 'foo')}}.must_equal '<table><tbody><tr><td><a href="foo">2</a></td><td><a href="foo">4</a></td></tr></tbody></table>'
37
+ table([[1, 2]]){|l, t| l.map{|i| t.a(i*2, 'foo', i=>i)}}.must_equal '<table><tbody><tr><td><a 1="1" href="foo">2</a></td><td><a 2="2" href="foo">4</a></td></tr></tbody></table>'
48
38
  end
49
39
 
50
40
  it 'should support :table option for the table attribtues' do
51
- table([[1, 2]], :table=>{:class=>'foo'}).should == '<table class="foo"><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
41
+ table([[1, 2]], :table=>{:class=>'foo'}).must_equal '<table class="foo"><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
52
42
  end
53
43
 
54
44
  it 'should support :tr option for the tr attributes' do
55
- table([[1, 2]], :tr=>{:class=>'foo'}).should == '<table><tbody><tr class="foo"><td>1</td><td>2</td></tr></tbody></table>'
56
- table([[1, 2]], :headers=>%w'a b', :tr=>{:class=>'foo'}).should == '<table><thead><tr class="foo"><th>a</th><th>b</th></tr></thead><tbody><tr class="foo"><td>1</td><td>2</td></tr></tbody></table>'
45
+ table([[1, 2]], :tr=>{:class=>'foo'}).must_equal '<table><tbody><tr class="foo"><td>1</td><td>2</td></tr></tbody></table>'
46
+ table([[1, 2]], :headers=>%w'a b', :tr=>{:class=>'foo'}).must_equal '<table><thead><tr class="foo"><th>a</th><th>b</th></tr></thead><tbody><tr class="foo"><td>1</td><td>2</td></tr></tbody></table>'
57
47
  end
58
48
 
59
49
  it 'should support :td option for the td attributes' do
60
- table([[1, 2]], :td=>{:class=>'foo'}).should == '<table><tbody><tr><td class="foo">1</td><td class="foo">2</td></tr></tbody></table>'
50
+ table([[1, 2]], :td=>{:class=>'foo'}).must_equal '<table><tbody><tr><td class="foo">1</td><td class="foo">2</td></tr></tbody></table>'
61
51
  end
62
52
 
63
53
  it 'should support :th option for the th attributes' do
64
- table([[1, 2]], :headers=>%w'a b', :th=>{:class=>'foo'}).should == '<table><thead><tr><th class="foo">a</th><th class="foo">b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
54
+ table([[1, 2]], :headers=>%w'a b', :th=>{:class=>'foo'}).must_equal '<table><thead><tr><th class="foo">a</th><th class="foo">b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
65
55
  end
66
56
 
67
57
  it 'should support a proc for the :tr option' do
68
- table([[1, 2]], :tr=>proc{|row| {:class=>"foo#{row.join}"}}).should == '<table><tbody><tr class="foo12"><td>1</td><td>2</td></tr></tbody></table>'
69
- table([[1, 2]], :headers=>%w'a b', :tr=>proc{|row| {:class=>"foo#{row.join}"}}).should == '<table><thead><tr class="fooab"><th>a</th><th>b</th></tr></thead><tbody><tr class="foo12"><td>1</td><td>2</td></tr></tbody></table>'
58
+ table([[1, 2]], :tr=>proc{|row| {:class=>"foo#{row.join}"}}).must_equal '<table><tbody><tr class="foo12"><td>1</td><td>2</td></tr></tbody></table>'
59
+ table([[1, 2]], :headers=>%w'a b', :tr=>proc{|row| {:class=>"foo#{row.join}"}}).must_equal '<table><thead><tr class="fooab"><th>a</th><th>b</th></tr></thead><tbody><tr class="foo12"><td>1</td><td>2</td></tr></tbody></table>'
70
60
  end
71
61
 
72
62
  it 'should support a proc for the :td option' do
73
- table([[1, 2]], :td=>proc{|v, i, row| {:class=>"foo#{row.join}-#{v}-#{i}"}}).should == '<table><tbody><tr><td class="foo12-1-0">1</td><td class="foo12-2-1">2</td></tr></tbody></table>'
63
+ table([[1, 2]], :td=>proc{|v, i, row| {:class=>"foo#{row.join}-#{v}-#{i}"}}).must_equal '<table><tbody><tr><td class="foo12-1-0">1</td><td class="foo12-2-1">2</td></tr></tbody></table>'
74
64
  end
75
65
 
76
66
  it 'should support a proc for the :th option' do
77
- table([[1, 2]], :headers=>%w'a b', :th=>proc{|v| {:class=>"foo#{v}"}}).should == '<table><thead><tr><th class="fooa">a</th><th class="foob">b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
67
+ table([[1, 2]], :headers=>%w'a b', :th=>proc{|v| {:class=>"foo#{v}"}}).must_equal '<table><thead><tr><th class="fooa">a</th><th class="foob">b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
78
68
  end
79
69
 
80
70
  it 'should support :caption option for the table caption' do
81
- table([[1, 2]], :headers=>%w'a b', :caption=>'Foo').should == '<table><caption>Foo</caption><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
71
+ table([[1, 2]], :headers=>%w'a b', :caption=>'Foo').must_equal '<table><caption>Foo</caption><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
82
72
  end
83
73
 
84
74
  it 'should be callable as a method if including the module' do
85
- Class.new{include Thamble}.new.send(:table, [[1, 2]]).gsub(/\s+\n/m, '').gsub("\n", '').should == '<table><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
75
+ Class.new{include Thamble}.new.send(:table, [[1, 2]]).gsub(/\s+\n/m, '').gsub("\n", '').must_equal '<table><tbody><tr><td>1</td><td>2</td></tr></tbody></table>'
86
76
  end
87
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thamble
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-27 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: |
28
42
  Thamble exposes a single method, table, for easily creating HTML
29
43
  tables from enumerable objects.
@@ -69,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
83
  version: '0'
70
84
  requirements: []
71
85
  rubyforge_project:
72
- rubygems_version: 2.4.5
86
+ rubygems_version: 2.5.1
73
87
  signing_key:
74
88
  specification_version: 4
75
89
  summary: Create HTML Tables from Enumerables