pivot_table 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2684137254bb56ddbe7d1f32a2d505494170d38c
4
- data.tar.gz: 1d3d224b88c1df7c8980196e463ff6788f42cddd
3
+ metadata.gz: 358c82d5e3a1a349a27b0a35e34c2a2b764fc9f5
4
+ data.tar.gz: 725ff8d73693f14eee2c0d868942f8e6c58f6e1a
5
5
  SHA512:
6
- metadata.gz: e57ccdddfff53cff46227a1cce75f9640376cd08feff730a773e44f1316937609a0c9e2a5a217d804a7ca18db291901e7c6a3c736c469e4ed6acb70a618118d1
7
- data.tar.gz: 315f28559f9ccf3d9f1addfcb5fa5e4ba58125c950a42c5c0b9cdeca575d62cae7a6341fa56790c1151ba64ddaa6a34adcf67de077e743400a9663f018867df0
6
+ metadata.gz: 8c09f55135466324aec7bcd16006dc30a7f6e2b3421bb0d994be06d22ad382b0c91f55f8dda9ff94b37d5c37096cd524562b061ca4603973cec004393c481848
7
+ data.tar.gz: 7a976c7c17833be45c8a3a34bfbbc9ff4d8a240d11582b2c57fa4b8406c364b9c13a33f7295251529738fb8e4e89eedb5f4e004fc3a0ab43f31e61512b259e34
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
- --colour
2
- --format progress
1
+ --color
2
+ --format progress
3
+ --require pivot_table_helper
4
+ --require spec_helper
@@ -0,0 +1 @@
1
+ pivot_table
@@ -0,0 +1 @@
1
+ 2.1.2
@@ -1,3 +1,4 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.0
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem 'rake'
5
5
 
6
6
  group :development, :test do
7
7
  gem 'rspec'
8
+ gem 'rspec-its'
8
9
  gem 'growl'
9
- gem 'guard-rspec'
10
+ gem 'guard-rspec', require: false
10
11
  end
data/Guardfile CHANGED
@@ -1,8 +1,14 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard :rspec do
1
+ # Note: The cmd option is now required due to the increasing number of ways
2
+ # rspec may be run, below are examples of the most common uses.
3
+ # * bundler: 'bundle exec rspec'
4
+ # * bundler binstubs: 'bin/rspec'
5
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
6
+ # installed the spring binstubs per the docs)
7
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
8
+ # * 'just' rspec: 'rspec'
9
+ guard :rspec, cmd: 'bundle exec rspec' do
5
10
  watch(%r{^spec/.+_spec\.rb$})
11
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
6
12
  watch(%r{^lib/pivot_table.rb$}) { "spec" }
7
13
  watch(%r{^lib/pivot_table/(.+)\.rb$}) { "spec" }
8
14
  watch('spec/spec_helper.rb') { "spec" }
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Pivot Table [![Build Status](https://secure.travis-ci.org/edjames/pivot_table.png)](http://travis-ci.org/edjames/pivot_table) [![Code Climate](https://codeclimate.com/github/edjames/pivot_table.png)](https://codeclimate.com/github/edjames/pivot_table) [![Dependency Status](https://gemnasium.com/edjames/pivot_table.png)](https://gemnasium.com/edjames/pivot_table)
1
+ # Pivot Table [![Build Status](https://secure.travis-ci.org/edjames/pivot_table.png)](http://travis-ci.org/edjames/pivot_table) [![Code Climate](https://codeclimate.com/github/edjames/pivot_table.png)](https://codeclimate.com/github/edjames/pivot_table) [![Dependency Status](https://gemnasium.com/edjames/pivot_table.png)](https://gemnasium.com/edjames/pivot_table) [![Gem Version](https://badge.fury.io/rb/pivot_table.png)](http://badge.fury.io/rb/pivot_table)
2
2
 
3
3
  A handy tool for transforming a dataset into a spreadsheet-style pivot table.
4
4
 
@@ -23,20 +23,20 @@ At the very least, you will need to provide three things to create a pivot table
23
23
 
24
24
  Let's say you have a collection of Order objects that looks like this:
25
25
 
26
- obj_1 = Order.new(:city => 'London', :quarter => 'Q1')
27
- obj_2 = Order.new(:city => 'London', :quarter => 'Q2')
28
- obj_3 = Order.new(:city => 'London', :quarter => 'Q3')
29
- obj_4 = Order.new(:city => 'London', :quarter => 'Q4')
30
- obj_5 = Order.new(:city => 'New York', :quarter => 'Q1')
31
- obj_6 = Order.new(:city => 'New York', :quarter => 'Q2')
32
- obj_7 = Order.new(:city => 'New York', :quarter => 'Q3')
33
- obj_8 = Order.new(:city => 'New York', :quarter => 'Q4')
26
+ obj_1 = Order.new(city: 'London', quarter: 'Q1')
27
+ obj_2 = Order.new(city: 'London', quarter: 'Q2')
28
+ obj_3 = Order.new(city: 'London', quarter: 'Q3')
29
+ obj_4 = Order.new(city: 'London', quarter: 'Q4')
30
+ obj_5 = Order.new(city: 'New York', quarter: 'Q1')
31
+ obj_6 = Order.new(city: 'New York', quarter: 'Q2')
32
+ obj_7 = Order.new(city: 'New York', quarter: 'Q3')
33
+ obj_8 = Order.new(city: 'New York', quarter: 'Q4')
34
34
 
35
35
  data = [ obj_1, obj_2, obj_3, obj_4, obj_5, obj_6, obj_7, obj_8 ]
36
36
 
37
37
  Instantiate a new PivotTable::Grid object like this...
38
38
 
39
- grid = PivotTable::Grid.new do |g|
39
+ g = PivotTable::Grid.new do |g|
40
40
  g.source_data = data
41
41
  g.column_name = :quarter
42
42
  g.row_name = :city
@@ -65,26 +65,32 @@ Then you have the following aspects of the pivot table grid available to you...
65
65
  g.row_headers => ['London', 'New York']
66
66
  g.rows.length => 2
67
67
 
68
- g.rows[0].header => 'London'
69
- g.rows[0].data => [obj_1, obj_2, obj_3, obj_4]
68
+ g.rows[0].header => 'London'
69
+ g.rows[0].data => [obj_1, obj_2, obj_3, obj_4]
70
+ g.rows[0].column_data('Q2') => obj_2
70
71
 
71
- g.rows[1].header => 'New York'
72
- g.rows[1].data => [obj_5, obj_6, obj_7, obj_8]
72
+ g.rows[1].header => 'New York'
73
+ g.rows[1].data => [obj_5, obj_6, obj_7, obj_8]
74
+ g.rows[1].column_data('Q2') => obj_6
73
75
 
74
76
  g.column_headers => ['Q1', 'Q2', 'Q3', 'Q4']
75
77
  g.columns.length => 4
76
78
 
77
- g.columns[0].header => 'Q1'
78
- g.columns[0].data => [obj_1, obj_5]
79
+ g.columns[0].header => 'Q1'
80
+ g.columns[0].data => [obj_1, obj_5]
81
+ g.columns[0].row_data('London') => obj_1
79
82
 
80
- g.columns[1].header => 'Q2'
81
- g.columns[1].data => [obj_2, obj_6]
83
+ g.columns[1].header => 'Q2'
84
+ g.columns[1].data => [obj_2, obj_6]
85
+ g.columns[1].row_data('London') => obj_2
82
86
 
83
- g.columns[2].header => 'Q3'
84
- g.columns[2].data => [obj_3, obj_7]
87
+ g.columns[2].header => 'Q3'
88
+ g.columns[2].data => [obj_3, obj_7]
89
+ g.columns[2].row_data('London') => obj_3
85
90
 
86
- g.columns[3].header => 'Q4'
87
- g.columns[3].data => [obj_4, obj_8]
91
+ g.columns[3].header => 'Q4'
92
+ g.columns[3].data => [obj_4, obj_8]
93
+ g.columns[3].row_data('London') => obj_4
88
94
 
89
95
  The API should give you a lot of flexibility with regards to rendering this information in your views.
90
96
  E.g. The rows and columns collections make it very easy to produce horizontal, vertical and overall total values.
@@ -106,7 +112,7 @@ If you want to get the totals for rows, columns, or the entire grid, you can pas
106
112
 
107
113
  You can also provide additional configuration options when instantiating your Grid. Options are provided as a hash e.g.
108
114
 
109
- grid = PivotTable::Grid.new(:sort => true) do |g|
115
+ g = PivotTable::Grid.new(:sort => true) do |g|
110
116
  g.source_data = data
111
117
  g.column_name = :quarter
112
118
  g.row_name = :city
@@ -117,7 +123,7 @@ Here are the available configuration options:
117
123
 
118
124
  ###### 1. Sort
119
125
 
120
- **Usage:** `:sort => false`
126
+ **Usage:** `sort: false`
121
127
 
122
128
  **Default:** `true`
123
129
 
@@ -127,8 +133,7 @@ This option will automatically sort your data alphabetically based on your colum
127
133
  ### Ruby Support
128
134
 
129
135
  * 1.9.3
130
- * 2.0.0
131
- * 2.1.0
136
+ * 2.x
132
137
 
133
138
  ### Contributing to PivotTable
134
139
 
@@ -7,5 +7,5 @@ require 'pivot_table/column'
7
7
  require 'pivot_table/row'
8
8
 
9
9
  module PivotTable
10
- VERSION = '0.2.0'
10
+ VERSION = '0.3.0'
11
11
  end
@@ -1,7 +1,7 @@
1
1
  module PivotTable
2
2
  module CellCollection
3
3
 
4
- ACCESSORS = [:header, :data, :value_name]
4
+ ACCESSORS = [:header, :data, :value_name, :orthogonal_headers]
5
5
 
6
6
  ACCESSORS.each do |a|
7
7
  self.send(:attr_accessor, a)
@@ -17,5 +17,13 @@ module PivotTable
17
17
  data.inject(0) { |t, x| t + (x ? x.send(value_name) : 0) }
18
18
  end
19
19
 
20
+ private
21
+
22
+ def find_data by_header_name
23
+ data[
24
+ orthogonal_headers.find_index{|header| by_header_name.to_s == header.to_s}
25
+ ] rescue nil
26
+ end
27
+
20
28
  end
21
29
  end
@@ -1,5 +1,9 @@
1
1
  module PivotTable
2
2
  class Column
3
3
  include CellCollection
4
+
5
+ def row_data row_header
6
+ find_data row_header
7
+ end
4
8
  end
5
9
  end
@@ -26,7 +26,8 @@ module PivotTable
26
26
  @rows << Row.new(
27
27
  :header => row_headers[index],
28
28
  :data => data,
29
- :value_name => value_name
29
+ :value_name => value_name,
30
+ :orthogonal_headers => column_headers
30
31
  )
31
32
  end
32
33
  end
@@ -35,9 +36,10 @@ module PivotTable
35
36
  @columns = []
36
37
  @data_grid.transpose.each_with_index do |data, index|
37
38
  @columns << Column.new(
38
- :header => column_headers[index],
39
- :data => data,
40
- :value_name => value_name
39
+ :header => column_headers[index],
40
+ :data => data,
41
+ :value_name => value_name,
42
+ :orthogonal_headers => row_headers
41
43
  )
42
44
  end
43
45
  end
@@ -1,5 +1,9 @@
1
1
  module PivotTable
2
2
  class Row
3
3
  include CellCollection
4
+
5
+ def column_data column_header
6
+ find_data column_header
7
+ end
4
8
  end
5
9
  end
@@ -15,13 +15,13 @@ Gem::Specification.new do |s|
15
15
  s.required_ruby_version = '>= 1.9'
16
16
 
17
17
  s.rubyforge_project = "pivot_table"
18
- s.rubygems_version = ">= 1.6.1"
18
+ s.rubygems_version = "~> 2.2"
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_development_dependency "rspec", "~> 2.14"
24
+ s.add_development_dependency "rspec", "~> 3.1"
25
25
  s.add_development_dependency "growl", "~> 1.0"
26
- s.add_development_dependency "guard-rspec", "~> 4.2"
26
+ s.add_development_dependency "guard-rspec", "~> 4.3"
27
27
  end
@@ -7,11 +7,11 @@ module PivotTable
7
7
 
8
8
  let(:opts) { { :sort => true, :other_setting => 'on' } }
9
9
 
10
- its(:sort) { should be_true }
11
- its(:other_setting) { should == 'on' }
10
+ its(:sort) { is_expected.to eq true }
11
+ its(:other_setting) { is_expected.to eq 'on' }
12
12
 
13
13
  context 'when setting does not exist' do
14
- its(:i_do_not_exist) { should be_nil }
14
+ its(:i_do_not_exist) { is_expected.to be_nil }
15
15
  end
16
16
 
17
17
  end
@@ -4,12 +4,12 @@ module PivotTable
4
4
  describe Grid do
5
5
 
6
6
  context 'accessors' do
7
- it { should respond_to :source_data }
8
- it { should respond_to :row_name }
9
- it { should respond_to :column_name }
10
- it { should respond_to :columns }
11
- it { should respond_to :rows }
12
- it { should respond_to :grand_total }
7
+ it { is_expected.to respond_to :source_data }
8
+ it { is_expected.to respond_to :row_name }
9
+ it { is_expected.to respond_to :column_name }
10
+ it { is_expected.to respond_to :columns }
11
+ it { is_expected.to respond_to :rows }
12
+ it { is_expected.to respond_to :grand_total }
13
13
  end
14
14
 
15
15
  let(:d1) { build_data_object(1, 'r1', 'c1') }
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rubygems'
4
+ require 'rspec'
5
+ require 'rspec/its'
6
+ require 'pivot_table'
7
+ require 'ostruct'
8
+
9
+ # Requires supporting files with custom matchers and macros, etc,
10
+ # in ./support/ and its subdirectories.
11
+ Dir["./spec/support/**/*.rb"].each {|f| require f}
12
+
13
+ RSpec.configure do |config|
14
+ config.include Helpers
15
+ end
@@ -1,16 +1,89 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rubygems'
4
- require 'rspec'
5
- require 'pivot_table'
6
- require 'ostruct'
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
7
31
 
8
- # Requires supporting files with custom matchers and macros, etc,
9
- # in ./support/ and its subdirectories.
10
- Dir["./spec/support/**/*.rb"].each {|f| require f}
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
11
40
 
12
- RSpec.configure do |config|
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
43
+ =begin
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # This setting enables warnings. It's recommended, but in some cases may
59
+ # be too noisy due to issues in dependencies.
60
+ config.warnings = true
61
+
62
+ # Many RSpec users commonly either run the entire suite or an individual
63
+ # file, and it's useful to allow more verbose output when running an
64
+ # individual spec file.
65
+ if config.files_to_run.one?
66
+ # Use the documentation formatter for detailed output,
67
+ # unless a formatter has already been configured
68
+ # (e.g. via a command-line flag).
69
+ config.default_formatter = 'doc'
70
+ end
71
+
72
+ # Print the 10 slowest examples and example groups at the
73
+ # end of the spec run, to help surface which specs are running
74
+ # particularly slow.
75
+ config.profile_examples = 10
13
76
 
14
- config.include Helpers
77
+ # Run specs in random order to surface order dependencies. If you find an
78
+ # order dependency and want to debug it, you can fix the order by providing
79
+ # the seed, which is printed after each run.
80
+ # --seed 1234
81
+ config.order = :random
15
82
 
83
+ # Seed global randomization in this process using the `--seed` CLI option.
84
+ # Setting this allows you to use `--seed` to deterministically reproduce
85
+ # test failures related to randomization by passing the same `--seed` value
86
+ # as the one that triggered the failure.
87
+ Kernel.srand config.seed
88
+ =end
16
89
  end
@@ -1,18 +1,30 @@
1
1
  shared_examples "a cell collection" do
2
- it { should respond_to :header }
3
- it { should respond_to :data }
4
- it { should respond_to :value_name }
5
- it { should respond_to :total }
2
+ it { is_expected.to respond_to :header }
3
+ it { is_expected.to respond_to :data }
4
+ it { is_expected.to respond_to :value_name }
5
+ it { is_expected.to respond_to :total }
6
+ it { is_expected.to respond_to :orthogonal_headers }
6
7
 
7
- context 'initialize with hash' do
8
- subject { klass.new(attrs) }
8
+ subject(:instance) { klass.new(attrs) }
9
+
10
+ let(:data) do
11
+ { a: 1, b: 2 }
12
+ end
9
13
 
10
- let(:attrs) do
11
- { header: 'header', data: 'data', value_name: "value_name" }
12
- end
14
+ let(:attrs) do
15
+ { header: 'header', data: data.values, value_name: "value_name", orthogonal_headers: data.keys }
16
+ end
17
+
18
+ context 'initialize with hash' do
19
+ its(:header) { is_expected.to eq attrs[:header] }
20
+ its(:data) { is_expected.to eq attrs[:data] }
21
+ its(:value_name) { is_expected.to eq attrs[:value_name] }
22
+ its(:orthogonal_headers) { is_expected.to eq attrs[:orthogonal_headers] }
23
+ end
13
24
 
14
- its(:header) { should == attrs[:header] }
15
- its(:data) { should == attrs[:data] }
16
- its(:value_name) { should == attrs[:value_name] }
25
+ it "finds data by orthogonal header name" do
26
+ expect(instance.send :find_data, :a).to equal(data[:a])
27
+ expect(instance.send :find_data, :b).to equal(data[:b])
28
+ expect(instance.send :find_data, :c).to be_nil
17
29
  end
18
30
  end
@@ -1,30 +1,34 @@
1
1
  shared_examples 'a collection of columns' do
2
2
  let(:build_result) { instance.build }
3
- specify { build_result.columns.length.should == 3 }
3
+
4
+ context 'column count' do
5
+ subject { build_result.columns.length }
6
+ it { is_expected.to eq 3 }
7
+ end
4
8
 
5
9
  context 'column headers' do
6
10
  subject { build_result.column_headers }
7
- it { should == column_headers }
11
+ it { is_expected.to eq column_headers }
8
12
  end
9
13
 
10
14
  context '1st column' do
11
15
  subject { build_result.columns[0] }
12
- its(:header) { should == column_headers[0] }
13
- its(:data) { should == column_0 }
14
- its(:total) { should == column_totals[0] }
16
+ its(:header) { is_expected.to eq column_headers[0] }
17
+ its(:data) { is_expected.to eq column_0 }
18
+ its(:total) { is_expected.to eq column_totals[0] }
15
19
  end
16
20
 
17
21
  context '2nd column' do
18
22
  subject { build_result.columns[1] }
19
- its(:header) { should == column_headers[1] }
20
- its(:data) { should == column_1 }
21
- its(:total) { should == column_totals[1] }
23
+ its(:header) { is_expected.to eq column_headers[1] }
24
+ its(:data) { is_expected.to eq column_1 }
25
+ its(:total) { is_expected.to eq column_totals[1] }
22
26
  end
23
27
 
24
28
  context '3rd column' do
25
29
  subject { build_result.columns[2] }
26
- its(:header) { should == column_headers[2] }
27
- its(:data) { should == column_2 }
28
- its(:total) { should == column_totals[2] }
30
+ its(:header) { is_expected.to eq column_headers[2] }
31
+ its(:data) { is_expected.to eq column_2 }
32
+ its(:total) { is_expected.to eq column_totals[2] }
29
33
  end
30
34
  end
@@ -1,23 +1,27 @@
1
1
  shared_examples 'a collection of rows' do
2
2
  let(:build_result) { instance.build }
3
- specify { build_result.rows.length.should == 2 }
3
+
4
+ context 'row count' do
5
+ subject { build_result.rows.length }
6
+ it { is_expected.to eq 2 }
7
+ end
4
8
 
5
9
  context 'row headers' do
6
10
  subject { build_result.row_headers }
7
- it { should == row_headers }
11
+ it { is_expected.to eq row_headers }
8
12
  end
9
13
 
10
14
  context '1st row' do
11
15
  subject { build_result.rows[0] }
12
- its(:header) { should == row_headers[0] }
13
- its(:data) { should == row_0 }
14
- its(:total) { should == row_totals[0] }
16
+ its(:header) { is_expected.to eq row_headers[0] }
17
+ its(:data) { is_expected.to eq row_0 }
18
+ its(:total) { is_expected.to eq row_totals[0] }
15
19
  end
16
20
 
17
21
  context '2nd row' do
18
22
  subject { build_result.rows[1] }
19
- its(:header) { should == row_headers[1] }
20
- its(:data) { should == row_1 }
21
- its(:total) { should == row_totals[1] }
23
+ its(:header) { is_expected.to eq row_headers[1] }
24
+ its(:data) { is_expected.to eq row_1 }
25
+ its(:total) { is_expected.to eq row_totals[1] }
22
26
  end
23
27
  end
@@ -3,18 +3,18 @@ shared_examples 'a data grid' do
3
3
 
4
4
  context 'preparing the grid' do
5
5
  subject { build_result.prepare_grid }
6
- it { should == [[nil, nil, nil], [nil, nil, nil]] }
6
+ it { is_expected.to eq [[nil, nil, nil], [nil, nil, nil]] }
7
7
  end
8
8
 
9
9
  context 'populating the grid' do
10
10
  subject { build_result.data_grid }
11
- it { should == [row_0, row_1] }
11
+ it { is_expected.to eq [row_0, row_1] }
12
12
  end
13
13
 
14
14
  context 'totals' do
15
15
  subject { build_result }
16
- its(:column_totals) { should == column_totals }
17
- its(:row_totals) { should == row_totals }
18
- its(:grand_total) { should == grand_total }
16
+ its(:column_totals) { is_expected.to eq column_totals }
17
+ its(:row_totals) { is_expected.to eq row_totals }
18
+ its(:grand_total) { is_expected.to eq grand_total }
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,67 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivot_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed James
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-17 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.14'
19
+ version: '3.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.14'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: growl
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.2'
47
+ version: '4.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.2'
54
+ version: '4.3'
55
55
  description: Transform an ActiveRecord-ish data set into a pivot table of objects
56
56
  email: ed.james.email@gmail.com
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - .gitignore
62
- - .rspec
63
- - .rvmrc
64
- - .travis.yml
61
+ - ".gitignore"
62
+ - ".rspec"
63
+ - ".ruby-gemset"
64
+ - ".ruby-version"
65
+ - ".travis.yml"
65
66
  - Gemfile
66
67
  - Guardfile
67
68
  - LICENSE
@@ -78,6 +79,7 @@ files:
78
79
  - spec/pivot_table/configuration_spec.rb
79
80
  - spec/pivot_table/grid_spec.rb
80
81
  - spec/pivot_table/row_spec.rb
82
+ - spec/pivot_table_helper.rb
81
83
  - spec/spec_helper.rb
82
84
  - spec/support/helpers.rb
83
85
  - spec/support/shared_examples_for_a_cell_collection_.rb
@@ -93,25 +95,26 @@ require_paths:
93
95
  - lib
94
96
  required_ruby_version: !ruby/object:Gem::Requirement
95
97
  requirements:
96
- - - '>='
98
+ - - ">="
97
99
  - !ruby/object:Gem::Version
98
100
  version: '1.9'
99
101
  required_rubygems_version: !ruby/object:Gem::Requirement
100
102
  requirements:
101
- - - '>='
103
+ - - ">="
102
104
  - !ruby/object:Gem::Version
103
105
  version: '0'
104
106
  requirements: []
105
107
  rubyforge_project: pivot_table
106
- rubygems_version: 2.1.11
108
+ rubygems_version: 2.2.2
107
109
  signing_key:
108
110
  specification_version: 4
109
- summary: pivot_table-0.2.0
111
+ summary: pivot_table-0.3.0
110
112
  test_files:
111
113
  - spec/pivot_table/column_spec.rb
112
114
  - spec/pivot_table/configuration_spec.rb
113
115
  - spec/pivot_table/grid_spec.rb
114
116
  - spec/pivot_table/row_spec.rb
117
+ - spec/pivot_table_helper.rb
115
118
  - spec/spec_helper.rb
116
119
  - spec/support/helpers.rb
117
120
  - spec/support/shared_examples_for_a_cell_collection_.rb
data/.rvmrc DELETED
@@ -1,2 +0,0 @@
1
- # rvm use ruby-1.9.3-p448@pivot_table --create
2
- rvm use ruby-2.0.0-p247@pivot_table --create