platformcraft-filespot 0.1.3 → 0.1.4

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: 9bb3562213d02635405c3b26c8cd37e2dc4289b5
4
- data.tar.gz: ae843536033964ca2e757bb029e4d9b92c4cabf6
3
+ metadata.gz: 35dccadd089a759ce2a50795b5732e8799662c7d
4
+ data.tar.gz: 1b0981f71db5ca94c4a4a33e8bc86c3df2b8b394
5
5
  SHA512:
6
- metadata.gz: 906ef21911f89f986f7cb2854463369e1e5ed532bfed47ae598dfc238834252f8e6cb84e223c6558236e6bb6ec3a248622ce311871eac4f88be5b740c51009b6
7
- data.tar.gz: c340ee0cb7fbfab8b0c96993bfd0ac28a43ce317685af5127c92acf6cb4bee422431a9fdbeb3100845a9c752142e76d7e65514f2b9f359004651806afe2b4d2f
6
+ metadata.gz: db1b43004260f73c12c3563fb0e65d8edb95a314676c2968c194e0b08fecc2fad54a954e42abe34a98cae83c1c1d37d0a23e4c2858d26ba1f3ee6b3717ae97e1
7
+ data.tar.gz: a77f09f9c38d0ae29bc09a49a9655431cd09db38e1e2a105103c56cc64e4e9592199641e8b4d323c456af1c72c67d4319cff988313bfb6267106bc587a41cc76
@@ -1,7 +1,11 @@
1
1
  module Filespot
2
2
  module Objects
3
- def get_objects
4
- res = Response.new(Request.get("/objects"))
3
+ def exists?(path)
4
+ !!get_object_by_path(path)
5
+ end
6
+
7
+ def get_objects(folder=nil)
8
+ res = Response.new(Request.get("/objects", folder: folder))
5
9
  return [] unless res.code == 200
6
10
 
7
11
  arr = []
@@ -28,6 +32,21 @@ module Filespot
28
32
  res = Response.new(Request.delete("/objects/#{object_id}"))
29
33
  res
30
34
  end
35
+
36
+ def delete_object_by_path(path)
37
+ object = get_object_by_path path
38
+ return delete_object(object.id) if object
39
+ nil
40
+ end
41
+
42
+ def get_object_by_path(path)
43
+ full_path = path[0] == '/' ? path : "/#{path}"
44
+ folder = File.dirname full_path
45
+ get_objects(folder).each do |object|
46
+ return object if object.path == full_path
47
+ end
48
+ nil
49
+ end
31
50
  end
32
51
 
33
52
  class Object
@@ -43,8 +43,9 @@ module Filespot
43
43
  def self.api_uri(http_method, api_method, params)
44
44
  uri = URI("https://" + Filespot.url)
45
45
  uri.path = "/#{Filespot.version}#{api_method}"
46
- uri.query = URI.encode_www_form(init_params(params))
46
+ uri.query = URI.encode_www_form(default_params)
47
47
  uri.query += "&hash=#{Digest.hmac(http_method, uri.to_s)}"
48
+ uri.query += "&#{URI.encode_www_form(params)}" if params.any?
48
49
  uri
49
50
  end
50
51
  end
@@ -1,3 +1,3 @@
1
1
  module Filespot
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platformcraft-filespot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - droff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2016-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -132,9 +132,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.5.0
135
+ rubygems_version: 2.6.2
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: http://doc.platformcraft.ru/filespot/api/
139
- test_files: []
140
- has_rdoc:
139
+ test_files:
140
+ - spec/fixtures/download_tasks.json
141
+ - spec/fixtures/download_tasks_id.json
142
+ - spec/fixtures/objects.json
143
+ - spec/fixtures/objects_id.json
144
+ - spec/fixtures/objects_post.json
145
+ - spec/lib/client/download_spec.rb
146
+ - spec/lib/client/objects_spec.rb
147
+ - spec/lib/client_spec.rb
148
+ - spec/lib/digest_spec.rb
149
+ - spec/lib/response_spec.rb
150
+ - spec/spec_helper.rb