pogoplug 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,80 @@
1
+ require_relative 'helper'
2
+ module PogoPlug
3
+ class FileTest < Test::Unit::TestCase
4
+ context "File" do
5
+ setup do
6
+ @name = "My file name"
7
+ @id = "WJ0I39hPZfSIgLYSes5u0w"
8
+ @type = File::Type::FILE
9
+ @mimetype = "test/plain"
10
+ @file = File.new(name: @name, id: @id, type: @type)
11
+ end
12
+
13
+ should "provide a name" do
14
+ assert_equal(@file.name, @name)
15
+ end
16
+
17
+ should "provide an ID" do
18
+ assert_equal(@file.id, @id)
19
+ end
20
+
21
+ should "provide a type" do
22
+ assert_equal(@file.type, @type)
23
+ end
24
+
25
+ should "provide a size" do
26
+ assert_equal(@file.size, 0)
27
+ end
28
+
29
+ should "provide a mimetype" do
30
+ @file.mimetype = @mimetype
31
+ assert_equal(@file.mimetype, @mimetype)
32
+ end
33
+
34
+ should "know if its a directory" do
35
+ assert_false(@file.directory?, "File of type File::Type::FILE should not think it is a directory")
36
+ directory = File.new(name: "My folder", id: "some id value", type: File::Type::DIRECTORY)
37
+ assert_true(directory.directory?, "File of type File::Type::DIRECTORY should know that it is a directory")
38
+ end
39
+
40
+ should "be able to build instances from JSON" do
41
+ json = %q{
42
+ {
43
+ "fileid": "WJ0I39hPZfSIgLYSes5u0w",
44
+ "type": "0",
45
+ "name": "bar.txt",
46
+ "parentid": "0",
47
+ "mimetype": "text/plain",
48
+ "size": "0",
49
+ "ctime": "1376082434000",
50
+ "mtime": "1376082434000",
51
+ "origtime": "1376082434000",
52
+ "xcstamp": "",
53
+ "tnstamp": "",
54
+ "mdstamp": "",
55
+ "streamtype": "full",
56
+ "thumbnail": "",
57
+ "preview": "",
58
+ "stream": "",
59
+ "livestream": "",
60
+ "flvstream": "",
61
+ "properties": {
62
+ "origin": ""
63
+ },
64
+ "metaver": "0",
65
+ "filename": "bar.txt",
66
+ "mediatype": "text"
67
+ }
68
+ }
69
+ file = File.from_json(JSON.parse(json))
70
+ assert_false(file.directory?)
71
+ assert_true(file.file?)
72
+ assert_equal(file.mimetype, "text/plain")
73
+ assert_equal(file.size, 0)
74
+ assert_equal(file.id, "WJ0I39hPZfSIgLYSes5u0w")
75
+ assert_equal(file.name, "bar.txt")
76
+ assert_equal(file.parent_id, "0")
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+
16
+ require 'simplecov'
17
+ SimpleCov.start
18
+
19
+ require 'pogoplug'
20
+
21
+ class Test::Unit::TestCase
22
+ end
@@ -0,0 +1,46 @@
1
+ require_relative 'helper'
2
+
3
+ module PogoPlug
4
+ class ServiceTest < Test::Unit::TestCase
5
+ context "Service" do
6
+
7
+ setup do
8
+ @name = "Pogoplug Cloud"
9
+ @id = "XCLDGAAAHE5B5NKDKMUXJ52F9J"
10
+ @service = PogoPlug::Service.new(name: @name, id: @id)
11
+ end
12
+
13
+ should "provide an ID" do
14
+ assert_equal(@service.id, @id)
15
+ end
16
+
17
+ should "provide a name" do
18
+ assert_equal(@service.name, @name)
19
+ end
20
+
21
+ should "be able to build instances from JSON" do
22
+ json = %q{
23
+ {
24
+ "deviceid": "XCLDGAAAHE5B5NKDKMUXJ52F9J",
25
+ "serviceid": "XCLDGAAAHE5B5NKDKMUXJ52F9J",
26
+ "sclass": "1",
27
+ "type": "xce:plugfs:cloud",
28
+ "name": "Pogoplug Cloud",
29
+ "version": "4.6.0.12",
30
+ "online": "1",
31
+ "msgpending": "0",
32
+ "apiurl": "https://cl0c0.pogoplug.com/svc/api/",
33
+ "space": "5000000000/5000000000",
34
+ "flags": "0",
35
+ "onlan": "0",
36
+ "metaver": "0"
37
+ }
38
+ }
39
+ service = Service.from_json(JSON.parse(json))
40
+ assert_equal("XCLDGAAAHE5B5NKDKMUXJ52F9J", service.id)
41
+ assert_equal("Pogoplug Cloud", service.name)
42
+ assert_equal("https://cl0c0.pogoplug.com/svc/api/", service.api_url)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1 @@
1
+ This is our test file. We write it to PogoPlug cloud.
metadata ADDED
@@ -0,0 +1,256 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pogoplug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Travis Truman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pogoplug
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '3.12'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.12'
94
+ - !ruby/object:Gem::Dependency
95
+ name: shoulda
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard
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: guard-bundler
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'
158
+ - !ruby/object:Gem::Dependency
159
+ name: guard-test
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: ruby_gntp
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ description: ''
191
+ email: trumant@gmail.com
192
+ executables: []
193
+ extensions: []
194
+ extra_rdoc_files:
195
+ - LICENSE.txt
196
+ - README.rdoc
197
+ files:
198
+ - .document
199
+ - .rvmrc
200
+ - .travis.yml
201
+ - Gemfile
202
+ - Gemfile.lock
203
+ - Guardfile
204
+ - LICENSE.txt
205
+ - README.rdoc
206
+ - Rakefile
207
+ - VERSION
208
+ - lib/pogoplug.rb
209
+ - lib/pogoplug/api_version.rb
210
+ - lib/pogoplug/authentication_error.rb
211
+ - lib/pogoplug/client.rb
212
+ - lib/pogoplug/device.rb
213
+ - lib/pogoplug/file.rb
214
+ - lib/pogoplug/file_listing.rb
215
+ - lib/pogoplug/hash_initializer.rb
216
+ - lib/pogoplug/service.rb
217
+ - lib/pogoplug/version.rb
218
+ - listDevices.json
219
+ - listFiles.json
220
+ - pogoplug.gemspec
221
+ - test/pogoplug/client_test.rb
222
+ - test/pogoplug/device_test.rb
223
+ - test/pogoplug/file_listing_test.rb
224
+ - test/pogoplug/file_test.rb
225
+ - test/pogoplug/helper.rb
226
+ - test/pogoplug/service_test.rb
227
+ - test/test_file.txt
228
+ homepage: http://github.com/trumant/pogoplug
229
+ licenses:
230
+ - MIT
231
+ post_install_message:
232
+ rdoc_options: []
233
+ require_paths:
234
+ - lib
235
+ required_ruby_version: !ruby/object:Gem::Requirement
236
+ none: false
237
+ requirements:
238
+ - - ! '>='
239
+ - !ruby/object:Gem::Version
240
+ version: '0'
241
+ segments:
242
+ - 0
243
+ hash: -4524288643432962824
244
+ required_rubygems_version: !ruby/object:Gem::Requirement
245
+ none: false
246
+ requirements:
247
+ - - ! '>='
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ requirements: []
251
+ rubyforge_project:
252
+ rubygems_version: 1.8.23
253
+ signing_key:
254
+ specification_version: 3
255
+ summary: A Ruby wrapper around the PogoPlug API
256
+ test_files: []