inky 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73dfc9c82a669d92077f6ed7c56e6be5c47cb09e
4
- data.tar.gz: ea0a899b7ddfe49302628c9480b5e5bd81cf73c4
3
+ metadata.gz: 70289d90e16fd42b4a88f9dc6e1a4cdd5494f333
4
+ data.tar.gz: f16632e1b26fee2fd066031eb5fe44fbf5691c98
5
5
  SHA512:
6
- metadata.gz: fe7c749ebca1d1b70dd077d23a111fc6df6a522b4082b5fe5e93b899faf9469ac5d039ed8559e85f7ea444d003b456c1cc84b94bc568df7b9e26f661ebc7cd27
7
- data.tar.gz: c88bc15d94fe7dfcf5d9412e2257a7f3eaa06e84c3fb372aeaf8c30b4788ee59426d9488f75db341ceda054539de2d6563874c78ffacbf26d3bd015da0372df5
6
+ metadata.gz: 48864d10735fa519f42dba06cad36d286afee149d3bbc4fbcc12e6d982b1a1ab1d175a9532c6ba55b560f1b4cb3724ae8a0a391926b0d198af2c11e610d77db3
7
+ data.tar.gz: cce4f4f1b165c349e60e3667df9870ce7485261752671fa7752eea7593db6ee88d29b3fc16fc718bf4ece92c015651f6f5ed9c1e7be49d323417cdc71bac6837
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .DS_Store
16
+ .env
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Nathan Griffith
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Inky
1
+ # Inky ![Inky](https://www.filepicker.io/api/file/iJnQeMi9RlGjpAQB10gu/convert?h=35)
2
2
 
3
3
  A ruby client for [filepicker.io](http://filepicker.io). Built on top of the Filepicker
4
4
  [REST API](https://developers.filepicker.io/docs/web/rest/).
@@ -20,7 +20,7 @@ file = Inky::File.new('hFHUCB3iTxyMzseuWOgG')
20
20
  file.uid
21
21
  file.md5
22
22
  file.mimetype
23
- file.uploaded
23
+ file.uploaded_at
24
24
  file.container
25
25
  file.writeable
26
26
  file.filename
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ['nathan@ngriffith.com']
10
10
  spec.summary = "A ruby client for filepicker.io's REST API"
11
11
  spec.description = "A ruby client for filepicker.io's REST API"
12
- spec.homepage = ''
13
- spec.license = ''
12
+ spec.homepage = 'http://github.com/smudge/inky'
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
@@ -19,6 +19,10 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency 'bundler', '~> 1.7'
21
21
  spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'dotenv', '>= 1.0.0'
23
+ spec.add_development_dependency 'rspec', '>= 3.2.0'
24
+ spec.add_development_dependency 'webmock', '>= 1.20.0'
25
+ spec.add_development_dependency 'vcr', '>= 2.9.0'
22
26
 
23
27
  spec.add_dependency 'addressable', '>= 2.2.0'
24
28
  spec.add_dependency 'rest-client', '>= 1.7.0'
@@ -17,12 +17,20 @@ module Inky
17
17
  request_metadata
18
18
  end
19
19
 
20
- def self.from_file(file)
21
- self.local_file = value
20
+ def self.from_file(local_file)
21
+ file = new
22
+ file.local_file = local_file
23
+ file
22
24
  end
23
25
 
24
26
  def self.from_url(url)
25
- self.remote_url = value
27
+ file = new
28
+ file.remote_url = url
29
+ file
30
+ end
31
+
32
+ def uploaded_at
33
+ Time.at(uploaded / 1000.0)
26
34
  end
27
35
 
28
36
  def url
@@ -31,6 +39,7 @@ module Inky
31
39
 
32
40
  def save!(opts = {})
33
41
  opts = { location: 's3', key: Inky.api_key }.merge(opts)
42
+ opts.merge filename: ::File.basename(local_file) if local_file
34
43
  handle_post_response RestClient.post(post_url(opts), post_opts)
35
44
  self
36
45
  end
@@ -73,8 +82,3 @@ module Inky
73
82
  end
74
83
  end
75
84
  end
76
-
77
-
78
- # Inky.authorize!('AEqf74BETRAuJWYy1U4hqz'); f = Inky::File.new('2zSX2El5QOatv87CNXxt')
79
- # Inky.authorize!('AEqf74BETRAuJWYy1U4hqz'); f = Inky::File.from_url('https://www.filepicker.io/api/file/2zSX2El5QOatv87CNXxt')
80
- # Inky.authorize!('AEqf74BETRAuJWYy1U4hqz'); f = Inky::File.from_file(File.open('my_file.txt'))
@@ -1,3 +1,3 @@
1
1
  module Inky
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.filepicker.io/api/file/hFHUCB3iTxyMzseuWOgG/metadata?container=true&filename=true&height=true&key=true&location=true&md5=true&mimetype=true&path=true&size=true&uploaded=true&width=true&writeable=true
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Thu, 12 Feb 2015 18:43:26 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '242'
29
+ Access-Control-Allow-Origin:
30
+ - "*"
31
+ Access-Control-Allow-Methods:
32
+ - GET
33
+ Access-Control-Max-Age:
34
+ - '21600'
35
+ Access-Control-Allow-Headers:
36
+ - CONTENT-TYPE
37
+ Set-Cookie:
38
+ - session=-; Domain=filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT; Path=/
39
+ - session=-; Domain=www.filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT;
40
+ Path=/
41
+ Content-Encoding:
42
+ - gzip
43
+ Vary:
44
+ - Accept-Encoding
45
+ P3p:
46
+ - CP="OTI DSP COR ADM DEV TAIo PSA PSD IVAi IVDi CONi HIS OUR IND CNT COM INT
47
+ NAV"
48
+ body:
49
+ encoding: ASCII-8BIT
50
+ string: !binary |-
51
+ H4sIAE703FQC/5VPT0+DMBT/KgtnM9uVbuDVeJDLNBgNXkhLX+FlpWVQRDR+
52
+ d9vFeDTx3X7/8z6THnvw6wDJzSbBXrRwPdg2udok82CcUKCCQFlOGEvZgYTb
53
+ kiA2znqBFsYYW9081m6xtZybE/gYXkb0IKSJtVqYCQKn0YAV/WWJnyvnhuen
54
+ Cd9viwLP5Ut5t/0Z7gDbzgdXSuLUgsp3v8i4Rnh0NpaULNpPsEbwutrjW8r2
55
+ j0ccHypZ3I+sqv+aGcSl9v/BXvGY04wqqXOZZRwY5SrPgLK9DiRRQvNdtE74
56
+ Ed+lB76j5Osb00IkcW0BAAA=
57
+ http_version:
58
+ recorded_at: Thu, 12 Feb 2015 18:43:26 GMT
59
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,176 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.filepicker.io/api/store/s3?key=<FP_API_KEY>
6
+ body:
7
+ encoding: ASCII-8BIT
8
+ string: !binary |-
9
+ LS00NzMyNTENCkNvbnRlbnQtRGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFt
10
+ ZT0iZmlsZVVwbG9hZCI7IGZpbGVuYW1lPSJpbmt5LnBuZyINCkNvbnRlbnQt
11
+ VHlwZTogaW1hZ2UvcG5nDQoNColQTkcNChoKAAAADUlIRFIAAAEsAAABLAgG
12
+ AAAAeX2OdQAACzlJREFUeF7t3FGOFUcMBdBMxC4ySMw+YPWwD5Ag6yAbIMhW
13
+ V7dtfPj2dLnOba7eV//1l38ECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIE
14
+ CBAgQIAAAQIECBAgQIAAAQIECBAgQKCTwMvr62unfewSFPjx/fPP4KixXwi8
15
+ vv/0AmaewN/zVrYxAQJbBRTW1uTdm8BAAYU1MDQrE9gqoLC2Ju/eBAYKKKyB
16
+ oVmZwFYBhbU1efcmMFBAYQ0MzcoEtgoorK3JuzeBgQIKa2BoViawVUBhbU3e
17
+ vQkMFFBYA0OzMoGtAgpra/LuTWCggMIaGJqVCWwVUFhbk3dvAgMFFNbA0KxM
18
+ YKuAwtqavHsTGCigsAaGZmUCWwUU1tbk3ZvAQAGFNTA0KxPYKuCb7v+TvG+m
19
+ b/0v0ePevjn/6xz8wurxftqCAIGAgMIKIBkhQKCHgMLqkYMtCBAICCisAJIR
20
+ AgR6CCisHjnYggCBgIDCCiAZIUCgh4DC6pGDLQgQCAgorACSEQIEeggorB45
21
+ 2IIAgYCAwgogGSFAoIeAwuqRgy0IEAgIKKwAkhECBHoIKKweOdiCAIGAgMIK
22
+ IBkhQKCHgMLqkYMtCBAICCisAJIRAgR6CCisHjnYggCBgIDCCiAZIUCgh4DC
23
+ 6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AYV1
73
+ WtTzCBC4TUBh3UbrwQQInBZQWKdFPY8AgdsEFNZttB5MgMBpAYV1WtTzCBC4
74
+ TUBh3UbrwQQInBZQWKdFPY8AgdsEFNZttB5MgMBpAYV1WtTzCBAgQIAAAQIE
75
+ CBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIE
76
+ lgj8BzV7R8tXRpyaAAAAAElFTkSuQmCCDQotLTQ3MzI1MS0tDQo=
77
+ headers:
78
+ Accept:
79
+ - "*/*; q=0.5, application/xml"
80
+ Accept-Encoding:
81
+ - gzip, deflate
82
+ Content-Length:
83
+ - '3053'
84
+ Content-Type:
85
+ - multipart/form-data; boundary=473251
86
+ User-Agent:
87
+ - Ruby
88
+ response:
89
+ status:
90
+ code: 200
91
+ message: OK
92
+ headers:
93
+ Server:
94
+ - nginx
95
+ Date:
96
+ - Fri, 13 Feb 2015 17:07:45 GMT
97
+ Content-Type:
98
+ - application/json
99
+ Content-Length:
100
+ - '125'
101
+ Access-Control-Allow-Origin:
102
+ - "*"
103
+ Access-Control-Allow-Methods:
104
+ - POST
105
+ Access-Control-Max-Age:
106
+ - '21600'
107
+ Access-Control-Allow-Headers:
108
+ - CONTENT-TYPE
109
+ Set-Cookie:
110
+ - session=-; Domain=www.filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT;
111
+ Path=/
112
+ P3p:
113
+ - CP="OTI DSP COR ADM DEV TAIo PSA PSD IVAi IVDi CONi HIS OUR IND CNT COM INT
114
+ NAV"
115
+ body:
116
+ encoding: UTF-8
117
+ string: '{"url": "https://www.filepicker.io/api/file/g3QUl9gRNWtHnW8Aa9Md",
118
+ "size": 2930, "type": "image/png", "filename": "inky.png"}'
119
+ http_version:
120
+ recorded_at: Fri, 13 Feb 2015 17:07:47 GMT
121
+ - request:
122
+ method: get
123
+ uri: https://www.filepicker.io/api/file/g3QUl9gRNWtHnW8Aa9Md/metadata?container=true&filename=true&height=true&key=true&location=true&md5=true&mimetype=true&path=true&size=true&uploaded=true&width=true&writeable=true
124
+ body:
125
+ encoding: US-ASCII
126
+ string: ''
127
+ headers:
128
+ Accept:
129
+ - "*/*; q=0.5, application/xml"
130
+ Accept-Encoding:
131
+ - gzip, deflate
132
+ User-Agent:
133
+ - Ruby
134
+ response:
135
+ status:
136
+ code: 200
137
+ message: OK
138
+ headers:
139
+ Server:
140
+ - nginx
141
+ Date:
142
+ - Fri, 13 Feb 2015 17:07:46 GMT
143
+ Content-Type:
144
+ - application/json
145
+ Content-Length:
146
+ - '186'
147
+ Access-Control-Allow-Origin:
148
+ - "*"
149
+ Access-Control-Allow-Methods:
150
+ - GET
151
+ Access-Control-Max-Age:
152
+ - '21600'
153
+ Access-Control-Allow-Headers:
154
+ - CONTENT-TYPE
155
+ Set-Cookie:
156
+ - session=-; Domain=filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT; Path=/
157
+ - session=-; Domain=www.filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT;
158
+ Path=/
159
+ Content-Encoding:
160
+ - gzip
161
+ Vary:
162
+ - Accept-Encoding
163
+ P3p:
164
+ - CP="OTI DSP COR ADM DEV TAIo PSA PSD IVAi IVDi CONi HIS OUR IND CNT COM INT
165
+ NAV"
166
+ body:
167
+ encoding: ASCII-8BIT
168
+ string: !binary |-
169
+ H4sIAGIv3lQC/0WO2w6CMBBEf8X02SBtuRT/Zi1b2NALwRKDxn+3VSJvOzO7
170
+ Z/bFHDmM24zsemLkYMDL7Ad2PrF1tgF67FPAKyFV1YpGtrIu0pBiHXwE8rik
171
+ 3K/WJuuxUES42cyKy4rJMmTRg/vR/bQVO3xEGsaYXFmW+ZL6OP6VDRoiBX+Q
172
+ J9wOMcN3d1eurzO8gVbXSgujBfAKtFE1CN50ShjemY7n0js98yOik+X7AwNs
173
+ Xfz5AAAA
174
+ http_version:
175
+ recorded_at: Fri, 13 Feb 2015 17:07:48 GMT
176
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,108 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.filepicker.io/api/store/s3?key=<FP_API_KEY>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: url=https%3A%2F%2Fwww.filepicker.io%2Fapi%2Ffile%2FEt0USwFnSaGtRVlR6mXY%2Binky.png
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '82'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Fri, 13 Feb 2015 17:07:49 GMT
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '125'
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Allow-Methods:
36
+ - POST
37
+ Access-Control-Max-Age:
38
+ - '21600'
39
+ Access-Control-Allow-Headers:
40
+ - CONTENT-TYPE
41
+ Set-Cookie:
42
+ - session=-; Domain=www.filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT;
43
+ Path=/
44
+ P3p:
45
+ - CP="OTI DSP COR ADM DEV TAIo PSA PSD IVAi IVDi CONi HIS OUR IND CNT COM INT
46
+ NAV"
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"url": "https://www.filepicker.io/api/file/KNmGxyOdSHyzzFEcUGRS",
50
+ "size": 2930, "type": "image/png", "filename": "inky.png"}'
51
+ http_version:
52
+ recorded_at: Fri, 13 Feb 2015 17:07:51 GMT
53
+ - request:
54
+ method: get
55
+ uri: https://www.filepicker.io/api/file/KNmGxyOdSHyzzFEcUGRS/metadata?container=true&filename=true&height=true&key=true&location=true&md5=true&mimetype=true&path=true&size=true&uploaded=true&width=true&writeable=true
56
+ body:
57
+ encoding: US-ASCII
58
+ string: ''
59
+ headers:
60
+ Accept:
61
+ - "*/*; q=0.5, application/xml"
62
+ Accept-Encoding:
63
+ - gzip, deflate
64
+ User-Agent:
65
+ - Ruby
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Server:
72
+ - nginx
73
+ Date:
74
+ - Fri, 13 Feb 2015 17:07:49 GMT
75
+ Content-Type:
76
+ - application/json
77
+ Content-Length:
78
+ - '186'
79
+ Access-Control-Allow-Origin:
80
+ - "*"
81
+ Access-Control-Allow-Methods:
82
+ - GET
83
+ Access-Control-Max-Age:
84
+ - '21600'
85
+ Access-Control-Allow-Headers:
86
+ - CONTENT-TYPE
87
+ Set-Cookie:
88
+ - session=-; Domain=filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT; Path=/
89
+ - session=-; Domain=www.filepicker.io; expires=Thu, 01-Jan-1970 00:00:00 GMT;
90
+ Path=/
91
+ Content-Encoding:
92
+ - gzip
93
+ Vary:
94
+ - Accept-Encoding
95
+ P3p:
96
+ - CP="OTI DSP COR ADM DEV TAIo PSA PSD IVAi IVDi CONi HIS OUR IND CNT COM INT
97
+ NAV"
98
+ body:
99
+ encoding: ASCII-8BIT
100
+ string: !binary |-
101
+ H4sIAGUv3lQC/0WO2Q6CMBBFf8X02SAtS4t/M5YpTOhCsMSg8d9tlcjjXebM
102
+ fTFHDuM2I7ueGDkY8DL7gZ1PbJ1tgB77FPBaVKqWopWS80LxVqRcBx+BPC6p
103
+ 4Fdrk/VYKCLcbIbFZcVkGbLowf3wftqKnT4iDWNMblWW+ZL6OP6VDRoiBX+Q
104
+ J9wOMcO3uyvXNxnegtSN0sJoAbwGbVQDgredEoZ3puP56Z2eeYjoqvL9AcHW
105
+ cM76AAAA
106
+ http_version:
107
+ recorded_at: Fri, 13 Feb 2015 17:07:51 GMT
108
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,59 @@
1
+ require 'support/spec_helper'
2
+
3
+ describe Inky::File do
4
+ context 'when reading existing file' do
5
+ use_vcr_cassette
6
+
7
+ let(:uid) { 'hFHUCB3iTxyMzseuWOgG' }
8
+ let(:file) { Inky::File.new(uid) }
9
+
10
+ describe '#url' do
11
+ subject { file.url }
12
+ it { is_expected.to eq("#{API_BASE_URL}/file/#{uid}") }
13
+ end
14
+ describe '#size' do
15
+ subject { file.size }
16
+ it { is_expected.to eq(175_210) }
17
+ end
18
+ describe '#mimetype' do
19
+ subject { file.mimetype }
20
+ it { is_expected.to eq('image/png') }
21
+ end
22
+ describe '#uploaded' do
23
+ subject { file.uploaded }
24
+ it { is_expected.to eq(1_390_334_370_000.0) }
25
+ end
26
+ describe '#container' do
27
+ subject { file.container }
28
+ it { is_expected.to eq('your_own_bucket') }
29
+ end
30
+ describe '#writeable' do
31
+ subject { file.writeable }
32
+ it { is_expected.to eq(false) }
33
+ end
34
+ describe '#filename' do
35
+ subject { file.filename }
36
+ it { is_expected.to eq('5qYoopVTsixCJJiqSWSE.png') }
37
+ end
38
+ describe '#location' do
39
+ subject { file.location }
40
+ it { is_expected.to eq('S3') }
41
+ end
42
+ describe '#key' do
43
+ subject { file.key }
44
+ it { is_expected.to eq('ZynOv436QOirPYbJIr3Y_5qYoopVTsixCJJiqSWSE.png') }
45
+ end
46
+ describe '#path' do
47
+ subject { file.path }
48
+ it { is_expected.to eq('ZynOv436QOirPYbJIr3Y_5qYoopVTsixCJJiqSWSE.png') }
49
+ end
50
+ describe '#width' do
51
+ subject { file.width }
52
+ it { is_expected.to eq(400) }
53
+ end
54
+ describe '#height' do
55
+ subject { file.height }
56
+ it { is_expected.to eq(400) }
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,81 @@
1
+ require 'support/spec_helper'
2
+ require 'active_support/core_ext/string/conversions'
3
+
4
+ shared_examples 'uploaded inky.png' do
5
+ let(:recorded_time) { VCR.current_cassette.originally_recorded_at || Time.now }
6
+
7
+ describe '#uid' do
8
+ subject { file.uid }
9
+ it { is_expected.to be_truthy }
10
+ end
11
+ describe '#size' do
12
+ subject { file.size }
13
+ it { is_expected.to eq(2_930) }
14
+ end
15
+ describe '#mimetype' do
16
+ subject { file.mimetype }
17
+ it { is_expected.to eq('image/png') }
18
+ end
19
+ describe '#uploaded_at' do
20
+ subject { file.uploaded_at.to_date }
21
+ it { is_expected.to eq(recorded_time.to_date) }
22
+ end
23
+ describe '#container' do
24
+ subject { file.container }
25
+ it { is_expected.to eq(nil) }
26
+ end
27
+ describe '#writeable' do
28
+ subject { file.writeable }
29
+ it { is_expected.to eq(true) }
30
+ end
31
+ describe '#filename' do
32
+ subject { file.filename }
33
+ it { is_expected.to eq('inky.png') }
34
+ end
35
+ describe '#location' do
36
+ subject { file.location }
37
+ it { is_expected.to eq(nil) }
38
+ end
39
+ describe '#key' do
40
+ subject { file.key }
41
+ it { is_expected.to eq(nil) }
42
+ end
43
+ describe '#path' do
44
+ subject { file.path }
45
+ it { is_expected.to eq(nil) }
46
+ end
47
+ describe '#width' do
48
+ subject { file.width }
49
+ it { is_expected.to eq(300) }
50
+ end
51
+ describe '#height' do
52
+ subject { file.height }
53
+ it { is_expected.to eq(300) }
54
+ end
55
+ end
56
+
57
+ describe Inky::File do
58
+ before { Inky.authorize! ENV['FILEPICKER_API_KEY'] }
59
+
60
+ context 'when writing a file' do
61
+ context 'from local file' do
62
+ use_vcr_cassette
63
+
64
+ let(:local_file) { ::File.new('spec/fixtures/files/inky.png') }
65
+ let(:file) { Inky::File.from_file(local_file) }
66
+ before { file.save! }
67
+
68
+ it_behaves_like 'uploaded inky.png'
69
+ end
70
+
71
+ context 'from remote url' do
72
+ use_vcr_cassette
73
+
74
+ let(:remote) { 'https://www.filepicker.io/api/file/Et0USwFnSaGtRVlR6mXY+inky.png' }
75
+ let(:file) { Inky::File.from_url(remote) }
76
+ before { file.save! }
77
+
78
+ it_behaves_like 'uploaded inky.png'
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'dotenv'
5
+ Dotenv.load
6
+
7
+ require 'inky'
8
+ require 'vcr'
9
+
10
+ API_BASE_URL = 'https://www.filepicker.io/api'
11
+
12
+ VCR.configure do |config|
13
+ config.cassette_library_dir = 'spec/fixtures/cassettes'
14
+ config.hook_into :webmock
15
+ config.filter_sensitive_data('<FP_API_KEY>') { ENV['FILEPICKER_API_KEY'] }
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.extend VCR::RSpec::Macros
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inky
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
  - Smudge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,62 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.20.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.20.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.9.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.9.0
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: addressable
43
99
  requirement: !ruby/object:Gem::Requirement
@@ -89,15 +145,23 @@ extra_rdoc_files: []
89
145
  files:
90
146
  - ".gitignore"
91
147
  - Gemfile
148
+ - LICENSE
92
149
  - README.md
93
150
  - Rakefile
94
151
  - inky.gemspec
95
152
  - lib/inky.rb
96
153
  - lib/inky/file.rb
97
154
  - lib/inky/version.rb
98
- homepage: ''
155
+ - spec/fixtures/cassettes/Inky_File/when_reading_existing_file.yml
156
+ - spec/fixtures/cassettes/Inky_File/when_writing_a_file/from_local_file.yml
157
+ - spec/fixtures/cassettes/Inky_File/when_writing_a_file/from_remote_url.yml
158
+ - spec/fixtures/files/inky.png
159
+ - spec/metadata_spec.rb
160
+ - spec/store_spec.rb
161
+ - spec/support/spec_helper.rb
162
+ homepage: http://github.com/smudge/inky
99
163
  licenses:
100
- - ''
164
+ - MIT
101
165
  metadata: {}
102
166
  post_install_message:
103
167
  rdoc_options: []
@@ -119,5 +183,12 @@ rubygems_version: 2.2.2
119
183
  signing_key:
120
184
  specification_version: 4
121
185
  summary: A ruby client for filepicker.io's REST API
122
- test_files: []
186
+ test_files:
187
+ - spec/fixtures/cassettes/Inky_File/when_reading_existing_file.yml
188
+ - spec/fixtures/cassettes/Inky_File/when_writing_a_file/from_local_file.yml
189
+ - spec/fixtures/cassettes/Inky_File/when_writing_a_file/from_remote_url.yml
190
+ - spec/fixtures/files/inky.png
191
+ - spec/metadata_spec.rb
192
+ - spec/store_spec.rb
193
+ - spec/support/spec_helper.rb
123
194
  has_rdoc: