rb-gust 0.0.2 → 0.0.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWNmZmU3ZTU3NjM3MTVkMGE3NWUyYzBhZTkwMDNhYzk3YjliNTI4NA==
4
+ MWJmZjk5MGMwYjJhYTk4MzA0NGJhODcwNWMxYmI2ODU4ZmQ1YjhmZg==
5
5
  data.tar.gz: !binary |-
6
- MGFjNWNmNWI5NTY1NWJiZDZiYzRhMWZhMWFjZjdkN2NhYTM1ZDg0NA==
6
+ NjgwNjQ3YjM3YjdkY2E3NWE0MjdhOTRlMTJhZmFhOTEyMTRjMTNjYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Y2U1YzVkZTI3ZTA4Yzk0ZDk1NThjNWQzYzJhMzU3NmMyYzYxMzBlYThjNzI2
10
- YzNlMzE5MDRjNTRlODk0MjM1YmM2NzIyZGExMzE1ZTE4Yjk5YTI4NjY4MGYy
11
- ZjY1ZTc1ZGY4YmM4ZGU5MjQxZTVkZjg4Y2M4ZDcyMzM5YzYzMTQ=
9
+ MDUyZTBmNjRlNGIyNjZlNzE3NDFkMjZmOTlhZGExNGZkMGJhMGRkM2E0MmIy
10
+ YjgyYTljNTljYjEyYzFmZTQ0MTFhZjJmODgxODE4M2E3NjZiNmJmZmVkZWMy
11
+ YzIxMGY1ZTUwM2FhZmI5MTQ0ZWI3ZDRkZjYzZTE0YTJkMDQ4NzY=
12
12
  data.tar.gz: !binary |-
13
- YTcwYTYyMGVmMDRmNDVhNGUzNWE0N2JhOTQ3YTI2MjkxYzg0YmExYWY4ZTc5
14
- OGM1NGU1YTdlMzZiNmY3ZWM5MGI3YzVjM2Y4ZTU0OGI0MGQxNDM1MjdjN2Uy
15
- YmJmZjcyMzIxOTQ1ZGFlYjQ5ZGFjZGVkZWNkYTVkMmNlNmFiMWQ=
13
+ MWU3YTdiYmM3ZGQ0YzE2NDFhNzNmZWE2OWI3NWM2NDYxMDIxZDNlYWFlMjUy
14
+ Y2FlMDBkMDg4NzM3ODMxNTQxY2RjY2E1ODRiYjJiNzE5ZjhkN2ExNDZlMDk3
15
+ ZWFlZTdmMTkxYzg2ODE2ZDM1NGE0OTVjODdiZTY2ZjhiZTdjMzI=
@@ -4,9 +4,8 @@ Gust Forecast
4
4
  The Gust Forecast is a list of feature ideas that would be nice to have. Ideally, this list is prioritized. (Maybe this list should be moved to Pivotal Tracker)
5
5
 
6
6
  ### Allow for more than one Spreadsheet
7
- Currently the script overwrites all but the last spreadsheet
8
7
 
9
- ### Refactor the Script class to be OO
8
+ Currently the script overwrites all but the last spreadsheet
10
9
 
11
10
  ### Object groups accessible by title name
12
11
 
@@ -42,3 +41,4 @@ end
42
41
 
43
42
  ### Multiple Tables Vertically stacked in One Spreadsheet
44
43
 
44
+ ### Remove Active Support Dependency (if it's easy)
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rb-gust (0.0.1)
5
- active_support
6
- spreadsheet
4
+ rb-gust (0.0.2)
5
+ active_support (>= 2.0)
6
+ spreadsheet (>= 0.7)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -37,4 +37,4 @@ PLATFORMS
37
37
  DEPENDENCIES
38
38
  pry
39
39
  rb-gust!
40
- rspec
40
+ rspec (>= 2.0)
data/README.md CHANGED
@@ -24,13 +24,17 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- Format a Spreadsheet (see the example spreadsheet [here](spec/workbooks/basic_objects.xls)):
27
+ [An example spreadsheet](spec/workbooks/basic_objects.xls):
28
+
29
+ ![A Gust Formatted Spreadsheet](doc/basic_objects.png "A Gust Formatted Spreadsheet")
30
+
31
+ ### Gust requires that you format your spreadsheet correctly:
28
32
 
29
33
  + first row with content as the object titles.
30
34
  + second row has column headers
31
35
  + third row begins the object data values
32
36
 
33
- To load the objects into Ruby, use Gust.load(). An RSpec example:
37
+ To load the objects into Ruby, use `Gust.load()`. An RSpec example:
34
38
 
35
39
  ```ruby
36
40
  objects = Gust.load('/gust_gem_path/spec/worksheets/basic_objects.xls')
Binary file
@@ -2,7 +2,6 @@
2
2
  require 'spreadsheet'
3
3
 
4
4
  require 'rb-gust/version'
5
- require 'rb-gust/script'
6
5
  require 'rb-gust/spreadsheet'
7
6
 
8
7
  module Gust
@@ -13,7 +12,7 @@ module Gust
13
12
 
14
13
  def self.load workbook_filepath
15
14
  @@workbook_filepath = workbook_filepath
16
- Script.new.script
15
+ Spreadsheet::Loader.load(self.workbook_filepath)
17
16
  end
18
17
 
19
18
  end
@@ -1,5 +1,7 @@
1
- require 'rb-gust/spreadsheet/worksheet'
1
+
2
+ require 'rb-gust/spreadsheet/loader'
2
3
  require 'rb-gust/spreadsheet/structure'
4
+ require 'rb-gust/spreadsheet/worksheet'
3
5
 
4
6
  module Gust::Spreadsheet
5
7
  end
@@ -1,10 +1,16 @@
1
- module Gust
2
- class Script
1
+ module Gust::Spreadsheet
2
+ class Loader
3
3
  attr_reader :objects, :object_groups
4
+ attr_reader :workbook_filepath
5
+
6
+ def initialize workbook_filepath
7
+ @workbook_filepath = workbook_filepath
8
+ @_workbook = ::Spreadsheet.open(workbook_filepath)
9
+ @object_groups = {}
10
+ end
4
11
 
5
12
  require 'active_support/inflector'
6
13
  def build_object_groups
7
- @object_groups = {}
8
14
  @titles.each_with_index do |title,i|
9
15
  group_name = ActiveSupport::Inflector.tableize(title).to_sym
10
16
  @object_groups[group_name] = group_objects(@headers[i], @objects[i])
@@ -29,9 +35,7 @@ module Gust
29
35
  end
30
36
 
31
37
  def script
32
- _wb = ::Spreadsheet.open(Gust.workbook_filepath)
33
-
34
- _wb.worksheets.each do |_ws|
38
+ _workbook.worksheets.each do |_ws|
35
39
  @ws = Gust::Spreadsheet::Worksheet.new(_ws)
36
40
  @titles = @ws.titles
37
41
  @headers = @ws.headers
@@ -41,5 +45,18 @@ module Gust
41
45
 
42
46
  @object_groups
43
47
  end
48
+
49
+ def self.load workbook_filepath
50
+ loader = self.new(workbook_filepath)
51
+ loader.script
52
+ end
53
+
54
+ private
55
+
56
+ # Hide any references to ::Spreadsheet objects
57
+ def _workbook
58
+ @_workbook
59
+ end
60
+
44
61
  end
45
62
  end
@@ -1,3 +1,3 @@
1
1
  module Gust
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gust::Spreadsheet::Loader do
4
+ before do
5
+ @path = File.join(File.expand_path('..', File.dirname(__FILE__)), 'workbooks','basic_objects.xls')
6
+ end
7
+
8
+ let(:loader) { Gust::Spreadsheet::Loader }
9
+
10
+ it "loads" do
11
+ loader.load(@path).should_not be_nil
12
+ end
13
+
14
+ it "loads more than one worksheet into objects" do
15
+ objects = loader.load(@path)
16
+ objects.keys.should include(:vehicles, :races)
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-gust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Feaver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-25 00:00:00.000000000 Z
11
+ date: 2013-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spreadsheet
@@ -80,15 +80,17 @@ files:
80
80
  - LICENSE.txt
81
81
  - README.md
82
82
  - Rakefile
83
+ - doc/basic_objects.png
83
84
  - lib/rb-gust.rb
84
- - lib/rb-gust/script.rb
85
85
  - lib/rb-gust/spreadsheet.rb
86
+ - lib/rb-gust/spreadsheet/loader.rb
86
87
  - lib/rb-gust/spreadsheet/structure.rb
87
88
  - lib/rb-gust/spreadsheet/worksheet.rb
88
89
  - lib/rb-gust/version.rb
89
90
  - rb-gust.gemspec
90
91
  - spec/gust_spec.rb
91
92
  - spec/spec_helper.rb
93
+ - spec/spreadsheet/loader_spec.rb
92
94
  - spec/spreadsheet/structure_spec.rb
93
95
  - spec/spreadsheet/worksheet_spec.rb
94
96
  - spec/workbooks/basic_objects.xls
@@ -120,6 +122,7 @@ summary: Load data from a spreadsheets directly into Ruby objects for further ma
120
122
  test_files:
121
123
  - spec/gust_spec.rb
122
124
  - spec/spec_helper.rb
125
+ - spec/spreadsheet/loader_spec.rb
123
126
  - spec/spreadsheet/structure_spec.rb
124
127
  - spec/spreadsheet/worksheet_spec.rb
125
128
  - spec/workbooks/basic_objects.xls