cloudsheet 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -8,4 +8,6 @@ group :development do
8
8
  gem "bundler"
9
9
  gem "jeweler"
10
10
  gem "simplecov"
11
+ gem "vcr"
12
+ gem "webmock"
11
13
  end
@@ -0,0 +1,59 @@
1
+ # Cloudsheet
2
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/kurtisnelson/cloudsheet) [![Build Status](https://secure.travis-ci.org/kurtisnelson/cloudsheet.png?branch=master)](http://travis-ci.org/kurtisnelson/cloudsheet)
3
+
4
+ Load Google Drive Spreadsheets sanely. It is [published](https://rubygems.org/gems/cloudsheet) on RubyGems. Full documentation is at [rubydoc.info](http://rubydoc.info/gems/cloudsheet/)
5
+
6
+ ## Usage
7
+ Setup the Cloudsheet. sheet is an optional worksheet ID.
8
+
9
+ ```ruby
10
+ cloudsheet = Cloudsheet::Drive.new(user: "me@example.com", password: "secret", sheet_key: "SPREADSHEETID")`
11
+ ```
12
+
13
+ Or use a oauth access token
14
+
15
+ ```ruby
16
+ cloudsheet = Cloudsheet::Drive.new(access_token: "1234a", sheet_key: "SPREADSHEETID")
17
+ ```
18
+
19
+
20
+ Setup an optional mapping of column #s to names and lambdas. The default operation is to no-op.
21
+
22
+ ```ruby
23
+ m = Cloudsheet::Map.new
24
+ m[0] = Cloudsheet::Mapping.new(:name)
25
+ m[1] = Cloudsheet::Mapping.new(:score).type(Float)
26
+ m[2] = Cloudsheet::Mapping.new(:cash).type("money")
27
+ m[3] = Cloudsheet::Mapping.new(:start_date).map(->(d) {DateTime.strptime(d, "%m/%d/%Y")})
28
+ ```
29
+
30
+ The map will try to do the right thing and if nil is passed in, it will skip the lambda and output nil.
31
+
32
+ Select a worksheet if not the first one and pass in an optional map
33
+
34
+ ```ruby
35
+ cloudsheet.sheet(0).map(m)
36
+ cloudsheet.each do |row|
37
+ row["name"] # Column 0
38
+ row["start_date"] # DateTime object created from column 1
39
+ row[2] # Un-mapped columns
40
+ end
41
+
42
+ puts "That was easy!"
43
+ ```
44
+
45
+ ## Contributing to Cloudsheet
46
+
47
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
48
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
49
+ * Fork the project.
50
+ * Start a feature/bugfix branch.
51
+ * Commit and push until you are happy with your contribution.
52
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
53
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
54
+
55
+ ## Copyright
56
+
57
+ Copyright (c) 2012 Kurt Nelson. See LICENSE.txt for
58
+ further details.
59
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -5,23 +5,24 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cloudsheet"
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kurt Nelson"]
12
- s.date = "2012-10-19"
12
+ s.date = "2012-11-15"
13
13
  s.description = "Pull google drive spreadsheets with your column names and datatypes"
14
14
  s.email = "kurtisnelson@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
+ ".travis.yml",
22
23
  "Gemfile",
23
24
  "LICENSE.txt",
24
- "README.rdoc",
25
+ "README.md",
25
26
  "Rakefile",
26
27
  "VERSION",
27
28
  "cloudsheet.gemspec",
@@ -53,6 +54,8 @@ Gem::Specification.new do |s|
53
54
  s.add_development_dependency(%q<bundler>, [">= 0"])
54
55
  s.add_development_dependency(%q<jeweler>, [">= 0"])
55
56
  s.add_development_dependency(%q<simplecov>, [">= 0"])
57
+ s.add_development_dependency(%q<vcr>, [">= 0"])
58
+ s.add_development_dependency(%q<webmock>, [">= 0"])
56
59
  else
57
60
  s.add_dependency(%q<google_drive>, [">= 0"])
58
61
  s.add_dependency(%q<pry>, [">= 0"])
@@ -61,6 +64,8 @@ Gem::Specification.new do |s|
61
64
  s.add_dependency(%q<bundler>, [">= 0"])
62
65
  s.add_dependency(%q<jeweler>, [">= 0"])
63
66
  s.add_dependency(%q<simplecov>, [">= 0"])
67
+ s.add_dependency(%q<vcr>, [">= 0"])
68
+ s.add_dependency(%q<webmock>, [">= 0"])
64
69
  end
65
70
  else
66
71
  s.add_dependency(%q<google_drive>, [">= 0"])
@@ -70,6 +75,8 @@ Gem::Specification.new do |s|
70
75
  s.add_dependency(%q<bundler>, [">= 0"])
71
76
  s.add_dependency(%q<jeweler>, [">= 0"])
72
77
  s.add_dependency(%q<simplecov>, [">= 0"])
78
+ s.add_dependency(%q<vcr>, [">= 0"])
79
+ s.add_dependency(%q<webmock>, [">= 0"])
73
80
  end
74
81
  end
75
82
 
@@ -5,6 +5,8 @@ module Cloudsheet
5
5
  def initialize(hash)
6
6
  if hash[:user] and hash[:password]
7
7
  drive = GoogleDrive.login(hash[:user], hash[:password])
8
+ elsif hash[:access_token]
9
+ drive = GoogleDrive.login_with_oauth(hash[:access_token])
8
10
  else
9
11
  raise "Missing Google Credentials"
10
12
  end
@@ -3,56 +3,64 @@ require "google_drive"
3
3
 
4
4
  describe Cloudsheet::Drive do
5
5
  before :all do
6
+ VCR.insert_cassette(:drive)
6
7
  @google_spreadsheet = GoogleDrive.login(ENV['G_USERNAME'], ENV['G_PASSWORD']).spreadsheet_by_key(ENV['G_SPREADSHEET'])
7
8
  end
8
-
9
- context "properly initialized" do
10
- subject{Cloudsheet::Drive.new(user: ENV['G_USERNAME'], password: ENV['G_PASSWORD'], sheet_key: ENV['G_SPREADSHEET'])}
11
-
12
- it "initializes" do
13
- subject.raw_sheet.worksheet_feed_url.should eq(@google_spreadsheet.worksheets[0].worksheet_feed_url)
14
- end
15
9
 
16
- it "selects a worksheet" do
17
- subject.sheet(0).raw_sheet.worksheet_feed_url.should eq(@google_spreadsheet.worksheets[0].worksheet_feed_url)
10
+ after :all do
11
+ VCR.eject_cassette
18
12
  end
19
13
 
20
- describe "rows" do
21
- it "eliminates the header" do
22
- subject.rows.count.should eq(34)
14
+ context "properly initialized" do
15
+ subject{setup_drive}
16
+ it "initializes" do
17
+ subject.raw_sheet.worksheet_feed_url.should eq(@google_spreadsheet.worksheets[0].worksheet_feed_url)
18
+ end
19
+
20
+ it "selects a worksheet" do
21
+ subject.sheet(0).raw_sheet.worksheet_feed_url.should eq(@google_spreadsheet.worksheets[0].worksheet_feed_url)
23
22
  end
24
23
 
25
- it "is enumerated without a map" do
26
- i = 2
27
- ws = @google_spreadsheet.worksheets[0]
28
- subject.each do |r|
29
- r[0].should eq(ws[i, 1])
30
- i += 1
24
+ describe "rows" do
25
+ it "eliminates the header" do
26
+ subject.rows.count.should eq(34)
31
27
  end
32
- end
33
28
 
34
- it "enumerates with a map" do
35
- m = Cloudsheet::Map.new
36
- m[0] = Cloudsheet::Mapping.new(:name)
37
- m[1] = Cloudsheet::Mapping.new(:start_date).map(->(d) {DateTime.strptime(d, "%m/%d/%Y")})
38
- m[3] = Cloudsheet::Mapping.new(3)
39
- subject.map(m)
40
-
41
- ws = @google_spreadsheet.worksheets[0]
42
- i = 2
43
- subject.each do |r|
44
- r[:name].should eq(ws[i, 1])
45
- r[:start_date].should eq(DateTime.strptime(ws[i, 2], "%m/%d/%Y"))
46
- r[2].should eq(ws[i, 3])
47
- r[3].should eq(ws[i, 4])
48
- i += 1
29
+ it "is enumerated without a map" do
30
+ i = 2
31
+ ws = @google_spreadsheet.worksheets[0]
32
+ subject.each do |r|
33
+ r[0].should eq(ws[i, 1])
34
+ i += 1
35
+ end
36
+ end
37
+
38
+ it "enumerates with a map" do
39
+ m = Cloudsheet::Map.new
40
+ m[0] = Cloudsheet::Mapping.new(:name)
41
+ m[1] = Cloudsheet::Mapping.new(:start_date).map(->(d) {DateTime.strptime(d, "%m/%d/%Y")})
42
+ m[3] = Cloudsheet::Mapping.new(3)
43
+ subject.map(m)
44
+
45
+ ws = @google_spreadsheet.worksheets[0]
46
+ i = 2
47
+ subject.each do |r|
48
+ r[:name].should eq(ws[i, 1])
49
+ r[:start_date].should eq(DateTime.strptime(ws[i, 2], "%m/%d/%Y"))
50
+ r[2].should eq(ws[i, 3])
51
+ r[3].should eq(ws[i, 4])
52
+ i += 1
53
+ end
49
54
  end
50
55
  end
51
56
  end
52
- end
53
57
  context "missing parameters" do
54
58
  it "fails without sheet_key" do
55
59
  ->{Cloudsheet::Drive.new(user: ENV['G_USERNAME'], password: ENV['G_PASSWORD'])}.should raise_error
56
60
  end
57
61
  end
62
+
63
+ def setup_drive
64
+ Cloudsheet::Drive.new(user: ENV['G_USERNAME'], password: ENV['G_PASSWORD'], sheet_key: ENV['G_SPREADSHEET'])
65
+ end
58
66
  end
@@ -4,12 +4,18 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  require 'rspec'
6
6
  require 'pry'
7
+ require 'vcr'
7
8
  require 'cloudsheet'
8
9
 
9
10
  # Requires supporting files with custom matchers and macros, etc,
10
11
  # in ./support/ and its subdirectories.
11
12
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
12
13
 
14
+ VCR.configure do |c|
15
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
16
+ c.hook_into :webmock # or :fakeweb
17
+ end
18
+
13
19
  RSpec.configure do |config|
14
20
 
15
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-19 00:00:00.000000000 Z
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google_drive
@@ -123,19 +123,52 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: vcr
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: webmock
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
126
158
  description: Pull google drive spreadsheets with your column names and datatypes
127
159
  email: kurtisnelson@gmail.com
128
160
  executables: []
129
161
  extensions: []
130
162
  extra_rdoc_files:
131
163
  - LICENSE.txt
132
- - README.rdoc
164
+ - README.md
133
165
  files:
134
166
  - .document
135
167
  - .rspec
168
+ - .travis.yml
136
169
  - Gemfile
137
170
  - LICENSE.txt
138
- - README.rdoc
171
+ - README.md
139
172
  - Rakefile
140
173
  - VERSION
141
174
  - cloudsheet.gemspec
@@ -164,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
197
  version: '0'
165
198
  segments:
166
199
  - 0
167
- hash: 2552302486075153280
200
+ hash: -2248492540917076519
168
201
  required_rubygems_version: !ruby/object:Gem::Requirement
169
202
  none: false
170
203
  requirements:
@@ -1,42 +0,0 @@
1
- = Cloudsheet
2
- Load Google Drive Spreadsheets sanely.
3
-
4
- Setup the Cloudsheet. sheet is an optional worksheet ID.
5
- cloudsheet = Cloudsheet::Drive.new(user: "me@example.com", password: "secret", sheet_key: "SPREADSHEETID")
6
-
7
- Setup an optional mapping of column #s to names and lambdas. The default operation is to no-op.
8
-
9
- m = Cloudsheet::Map.new
10
- m[0] = Cloudsheet::Mapping.new(:name)
11
- m[1] = Cloudsheet::Mapping.new(:score).type(Float)
12
- m[2] = Cloudsheet::Mapping.new(:cash).type("money")
13
- m[3] = Cloudsheet::Mapping.new(:start_date).map(->(d) {DateTime.strptime(d, "%m/%d/%Y")})
14
-
15
- The map will try to do the right thing and if nil is passed in, it will skip the lambda and output nil.
16
-
17
- Select a worksheet if not the first one and pass in an optional map
18
-
19
- cloudsheet.sheet(0).map(m)
20
- cloudsheet.each do |row|
21
- row["name"] # Column 0
22
- row["start_date"] # DateTime object created from column 1
23
- row[2] # Un-mapped columns
24
- end
25
-
26
- puts "That was easy!"
27
-
28
- == Contributing to Cloudsheet
29
-
30
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
31
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
32
- * Fork the project.
33
- * Start a feature/bugfix branch.
34
- * Commit and push until you are happy with your contribution.
35
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
36
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
37
-
38
- == Copyright
39
-
40
- Copyright (c) 2012 Kurt Nelson. See LICENSE.txt for
41
- further details.
42
-