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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fieldview/upload.rb +13 -4
- data/lib/fieldview/version.rb +1 -1
- data/test/test_upload.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fd1c79b470a1c46f9b283012ec5e0a661f810a0
|
4
|
+
data.tar.gz: f6098db003ab6fb2e4155a92d005e5fe5ee4153b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70d00c38c0722873b0d832b2912e050ee25ebf9ae9a459e8996236bef57ee75ba0c5c3f5a1484b8094be556d608667314aea61d4491160eff4a13943477d4b16
|
7
|
+
data.tar.gz: e7ab22accda9f1ceeae46070f89860d3e842a950932f9bb1ef23a1629139691e4acac8ee672748c785a340400139e15607c1add466820083ecc8396c3888ae68
|
data/Gemfile.lock
CHANGED
data/lib/fieldview/upload.rb
CHANGED
@@ -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.
|
13
|
-
#
|
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,
|
data/lib/fieldview/version.rb
CHANGED
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,
|
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.
|
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-
|
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.'
|