fieldview 0.0.5 → 0.0.6

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: 12d759d08d6454a977dae753a9983a321ba49dd0
4
- data.tar.gz: 9de183d6a3ec0a79ae300e6556085197e5a3dba8
3
+ metadata.gz: 5fd1c79b470a1c46f9b283012ec5e0a661f810a0
4
+ data.tar.gz: f6098db003ab6fb2e4155a92d005e5fe5ee4153b
5
5
  SHA512:
6
- metadata.gz: b06dc6f850c20233bb39cb3258e0f37cf80f33f6d5f93ec58f0025f3019f2a7eebd670dfe73bcc07e5e17ce0aefb2d1225fe67a9ebca562b8cac85513ecb1125
7
- data.tar.gz: 218f4758b114688aabbb854df717e46fded8631127583808197df8cc8962a2ca2bf34c57a1d5536f9e572305cd82d37a8bf5e059df1b936c2d67638574a55e81
6
+ metadata.gz: 70d00c38c0722873b0d832b2912e050ee25ebf9ae9a459e8996236bef57ee75ba0c5c3f5a1484b8094be556d608667314aea61d4491160eff4a13943477d4b16
7
+ data.tar.gz: e7ab22accda9f1ceeae46070f89860d3e842a950932f9bb1ef23a1629139691e4acac8ee672748c785a340400139e15607c1add466820083ecc8396c3888ae68
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fieldview (0.0.5)
4
+ fieldview (0.0.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,8 @@
1
1
  module FieldView
2
2
  class Upload < Requestable
3
+ CONTENT_TYPES = ["image/vnd.climate.thermal.geotiff", "image/vnd.climate.ndvi.geotiff",
4
+ "image/vnd.climate.rgb.geotiff", "image/vnd.climate.raw.geotiff"]
5
+
3
6
  # 5 Megabytes is the current chunk size
4
7
  REQUIRED_CHUNK_SIZE = 5*1024*1024
5
8
  CHUNK_CONTENT_TYPE = "application/octet-stream"
@@ -7,13 +10,19 @@ module FieldView
7
10
  PATH = "uploads"
8
11
  attr_accessor :id, :content_length, :content_type
9
12
 
13
+ def self.valid_content_type?(content_type)
14
+ return CONTENT_TYPES.include?(content_type)
15
+ end
16
+
10
17
  # Creates an upload with the specified items, all required.
11
18
  # will return an a new upload object that has it's ID which can be
12
- # used to upload. The following are known content types:
13
- # image/vnd.climate.thermal.geotiff, image/vnd.climate.ndvi.geotiff,
14
- # image/vnd.climate.chlorophyll.geotiff, image/vnd.climate.cci.geotiff,
15
- # image/vnd.climate.waterstress.geotiff, image/vnd.climate.infrared.geotiff
19
+ # used to upload. See the constant "CONTENT_TYPES" for the list
20
+ # of known types
16
21
  def self.create(auth_token, md5, content_length, content_type)
22
+ if not self.valid_content_type?(content_type) then
23
+ raise ArgumentError.new("content_type must be set to one of the following: #{CONTENT_TYPES.join(', ')}")
24
+ end
25
+
17
26
  response = auth_token.execute_request!(:post, PATH,
18
27
  params: {
19
28
  "md5" => md5,
@@ -1,3 +1,3 @@
1
1
  module FieldView
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
data/test/test_upload.rb CHANGED
@@ -15,7 +15,13 @@ class TestUpload < Minitest::Test
15
15
  to_return(status: 200)
16
16
 
17
17
  assert_raises(FieldView::UnexpectedResponseError) do
18
- FieldView::Upload.create(new_auth_token, "dontcare", 5, "dontcare")
18
+ FieldView::Upload.create(new_auth_token, "dontcare", 5, FieldView::Upload::CONTENT_TYPES.first)
19
+ end
20
+ end
21
+
22
+ def test_create_with_invalid_content_type()
23
+ assert_raises ArgumentError do
24
+ FieldView::Upload.create(new_auth_token, "dontcare", "dontcare", "NOT REAL")
19
25
  end
20
26
  end
21
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fieldview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Susmarski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-10 00:00:00.000000000 Z
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ' FieldView is used to make data-driven decisions to maximize your return
14
14
  on every acre. This Ruby Gem is provided as a convenient way to access their API.'