rb-gust 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/FORECAST.md +2 -2
- data/Gemfile.lock +4 -4
- data/README.md +6 -2
- data/doc/basic_objects.png +0 -0
- data/lib/rb-gust.rb +1 -2
- data/lib/rb-gust/spreadsheet.rb +3 -1
- data/lib/rb-gust/{script.rb → spreadsheet/loader.rb} +23 -6
- data/lib/rb-gust/version.rb +1 -1
- data/spec/spreadsheet/loader_spec.rb +19 -0
- data/spec/workbooks/basic_objects.xls +0 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWJmZjk5MGMwYjJhYTk4MzA0NGJhODcwNWMxYmI2ODU4ZmQ1YjhmZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjgwNjQ3YjM3YjdkY2E3NWE0MjdhOTRlMTJhZmFhOTEyMTRjMTNjYw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDUyZTBmNjRlNGIyNjZlNzE3NDFkMjZmOTlhZGExNGZkMGJhMGRkM2E0MmIy
|
10
|
+
YjgyYTljNTljYjEyYzFmZTQ0MTFhZjJmODgxODE4M2E3NjZiNmJmZmVkZWMy
|
11
|
+
YzIxMGY1ZTUwM2FhZmI5MTQ0ZWI3ZDRkZjYzZTE0YTJkMDQ4NzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWU3YTdiYmM3ZGQ0YzE2NDFhNzNmZWE2OWI3NWM2NDYxMDIxZDNlYWFlMjUy
|
14
|
+
Y2FlMDBkMDg4NzM3ODMxNTQxY2RjY2E1ODRiYjJiNzE5ZjhkN2ExNDZlMDk3
|
15
|
+
ZWFlZTdmMTkxYzg2ODE2ZDM1NGE0OTVjODdiZTY2ZjhiZTdjMzI=
|
data/FORECAST.md
CHANGED
@@ -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
|
-
|
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)
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rb-gust (0.0.
|
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
|
-
|
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()
|
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
|
data/lib/rb-gust.rb
CHANGED
@@ -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
|
-
|
15
|
+
Spreadsheet::Loader.load(self.workbook_filepath)
|
17
16
|
end
|
18
17
|
|
19
18
|
end
|
data/lib/rb-gust/spreadsheet.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
module Gust
|
2
|
-
class
|
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
|
-
|
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
|
data/lib/rb-gust/version.rb
CHANGED
@@ -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
|
Binary file
|
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.
|
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-
|
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
|