chute 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjQ0MGVhMDdlODYyOTM3MjJmY2ZmZTdhMmE4ZDZkNDMyNjYxY2Q5OQ==
5
+ data.tar.gz: !binary |-
6
+ MzIzOTc0OGI0ZDEyOWY3YTI3N2IwZGY0YmFmM2FmNDI4MmM3ODAzYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjE4N2NiNzA0YWEwNTcxZDAwZTU5NDM3M2MwOTkzMmJhYmJiMWQ4MmZhOGQw
10
+ MmY5MWYxNmY1NjE2ZjA3NDgxYzZiZDYxNTdlOWVjYTJmZGRkMTc4YjNiYzFm
11
+ N2E5MzI5MzRlMmVjMGQ0MjY5M2YwYzdkMDUwMTUyNGNhMmQzMGI=
12
+ data.tar.gz: !binary |-
13
+ ODAyOGU0ZjhmNDUxNTBhYTQzODk2YjhkNmQ2NjlhZTk4NmQ0ZDk1YTE0Mzc0
14
+ ZWQ5MmU5YzNlMTFiN2ExM2YyYWNjYmI1ODM2MDY2ZTZlY2JhY2VmNjI1NWU5
15
+ MWFiNmQzYjYwMDdhZjQ3ZmFjMzUyZDE4MTdmYWU4YTQ2Mzg4MDg=
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 2.1.0 knight-kill (2013-08-11)
2
+
3
+ ### Features
4
+
5
+ - **move asset**: add support for moving asset from one album to another
6
+ - **copy asset**: add support for copying asset to another album
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
  gem 'httparty'
3
3
  gem 'hashie'
4
+ gem 'rest-client'
4
5
 
5
6
  # Add dependencies to develop your gem here.
6
7
  # Include everything needed to run rake, tests, features, etc.
@@ -8,11 +9,11 @@ group :development do
8
9
  gem "rspec", "~> 2.8.0"
9
10
  gem "rdoc", "~> 3.12"
10
11
  gem "bundler"
11
- gem "jeweler", "~> 1.8.4"
12
+ gem "jeweler", "~> 1.8.6"
12
13
  gem "simplecov"
13
14
  end
14
15
 
15
16
  group :test do
16
17
  gem 'webmock'
17
- gem 'vcr'
18
+ gem 'vcr' , "~> 2.5.0"
18
19
  end
data/Gemfile.lock CHANGED
@@ -1,25 +1,57 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.3.2)
5
- crack (0.3.1)
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ crack (0.4.1)
7
+ safe_yaml (~> 0.9.0)
6
8
  diff-lcs (1.1.3)
9
+ faraday (0.8.8)
10
+ multipart-post (~> 1.2.0)
7
11
  git (1.2.5)
8
- hashie (1.2.0)
9
- httparty (0.9.0)
12
+ github_api (0.10.1)
13
+ addressable
14
+ faraday (~> 0.8.1)
15
+ hashie (>= 1.2)
16
+ multi_json (~> 1.4)
17
+ nokogiri (~> 1.5.2)
18
+ oauth2
19
+ hashie (2.0.5)
20
+ highline (1.6.19)
21
+ httparty (0.11.0)
10
22
  multi_json (~> 1.0)
11
- multi_xml
12
- jeweler (1.8.4)
23
+ multi_xml (>= 0.5.2)
24
+ httpauth (0.2.0)
25
+ jeweler (1.8.6)
26
+ builder
13
27
  bundler (~> 1.0)
14
28
  git (>= 1.2.5)
29
+ github_api (= 0.10.1)
30
+ highline (>= 1.6.15)
31
+ nokogiri (= 1.5.10)
15
32
  rake
16
33
  rdoc
17
- json (1.7.6)
18
- multi_json (1.5.0)
19
- multi_xml (0.5.1)
20
- rake (10.0.3)
21
- rdoc (3.12)
34
+ json (1.8.0)
35
+ jwt (0.1.8)
36
+ multi_json (>= 1.5)
37
+ mime-types (1.23)
38
+ multi_json (1.7.9)
39
+ multi_xml (0.5.5)
40
+ multipart-post (1.2.0)
41
+ nokogiri (1.5.10)
42
+ oauth2 (0.9.2)
43
+ faraday (~> 0.8)
44
+ httpauth (~> 0.2)
45
+ jwt (~> 0.1.4)
46
+ multi_json (~> 1.0)
47
+ multi_xml (~> 0.5)
48
+ rack (~> 1.2)
49
+ rack (1.5.2)
50
+ rake (10.1.0)
51
+ rdoc (3.12.2)
22
52
  json (~> 1.4)
53
+ rest-client (1.6.7)
54
+ mime-types (>= 1.16)
23
55
  rspec (2.8.0)
24
56
  rspec-core (~> 2.8.0)
25
57
  rspec-expectations (~> 2.8.0)
@@ -28,14 +60,15 @@ GEM
28
60
  rspec-expectations (2.8.0)
29
61
  diff-lcs (~> 1.1.2)
30
62
  rspec-mocks (2.8.0)
63
+ safe_yaml (0.9.5)
31
64
  simplecov (0.7.1)
32
65
  multi_json (~> 1.0)
33
66
  simplecov-html (~> 0.7.1)
34
67
  simplecov-html (0.7.1)
35
- vcr (2.2.5)
36
- webmock (1.8.11)
68
+ vcr (2.5.0)
69
+ webmock (1.13.0)
37
70
  addressable (>= 2.2.7)
38
- crack (>= 0.1.7)
71
+ crack (>= 0.3.2)
39
72
 
40
73
  PLATFORMS
41
74
  ruby
@@ -44,9 +77,10 @@ DEPENDENCIES
44
77
  bundler
45
78
  hashie
46
79
  httparty
47
- jeweler (~> 1.8.4)
80
+ jeweler (~> 1.8.6)
48
81
  rdoc (~> 3.12)
82
+ rest-client
49
83
  rspec (~> 2.8.0)
50
84
  simplecov
51
- vcr
85
+ vcr (~> 2.5.0)
52
86
  webmock
@@ -1,4 +1,6 @@
1
- Copyright (c) 2012 Darko Grozdanovski
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2012-2013 Chute Corporation <hello@getchute.com>, http://getchute.com
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,29 +1,28 @@
1
- CHUTE WRAPPER GEM
2
- ==
1
+ # Chute API V2 wrapper gem
3
2
 
4
- Development
5
- --
3
+ > Access [Chute API V2](https://api.getchute.com/v2) from Ruby.
6
4
 
7
- to build and install the gem locally on your system use:
8
5
 
9
- rake install
10
-
11
- you can afterwards include it inside your rails app
6
+ ## How to use
12
7
 
8
+ Install directly
13
9
 
14
- Running tests
15
- --
10
+ ```sh
11
+ gem install chute
12
+ ```
16
13
 
17
- to run the tests write
14
+ or add to your Gemfile
18
15
 
16
+ ```ruby
17
+ gem 'chute'
18
+ ```
19
19
 
20
- bundle exec rspec
21
20
 
21
+ ### Configuration
22
22
 
23
- Configuration of the Gem Inside your config/ folder
24
- --
23
+ Create `config/initializers/chute.rb` and set your credentials (you can get them from [apps.getchute.com](http://apps.getchute.com).
25
24
 
26
- ```
25
+ ```ruby
27
26
  Chute.configure do |config|
28
27
  config.app_id = YOUR_APP_ID
29
28
  config.app_secret = YOUR_APP_SECRET
@@ -32,15 +31,48 @@ end
32
31
  ```
33
32
 
34
33
 
34
+ ### Usage
35
+
35
36
  The parameters in the response are accessed as standard fields inside a class. Assuming `response` is the basic
36
- object containing the complete response you can access the id of the element by
37
+ object containing the complete response you can access the id of an element by
37
38
 
38
- ```
39
+ ```ruby
39
40
  response.data.id # if data is a single object
40
41
  response.data[0].id # if data is an array
41
42
  ```
42
43
 
43
44
 
44
- Responses are being recorded for reuse by using VCR
45
+ ## Development
46
+
47
+ To build and install the gem locally on your system use:
48
+
49
+ rake install
50
+
51
+ you can afterwards include it inside your rails app
52
+
53
+
54
+ ### Tests
55
+
56
+ To be able to run tests you'll first need to create an authorization file with the following contents and save it as `spec/support/authorization.rb`
57
+
58
+ ```ruby
59
+ shared_context "init credentials" do
60
+ before(:all) do
61
+ Chute.app_id = "508fc620018d162a070000d6" # this is an app designated for API testing
62
+ Chute.app_secret = "2ee285c24d8ffa83145aba8834f29ca1644b293a76a49db59a037e7301a26119"
63
+ Chute.access_token = "fe5d08d828c1d4562e5d2a7bbbb76e7dfa1fbc0932467a7a710bec66935df654"
64
+ end
65
+ end
66
+ ```
67
+
68
+ Now you can run tests using rspec
69
+
70
+ bundle exec rspec
71
+
72
+
73
+ Responses are recorded for reuse by VCR. If you need to re-run some of them remove the specific file from `spec/fixtures/`
74
+
75
+
76
+ ## License
45
77
 
46
- if you need to re-run some of them remove the specific one from `fixtures/`
78
+ Copyright (c) 2012-2013 Chute Corporation. Released under the MIT License.
data/chute.gemspec CHANGED
@@ -5,24 +5,24 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "chute"
8
- s.version = "2.0.2"
8
+ s.version = "2.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Darko Grozdanovski", "Chris Burkhart", "Petr Bela"]
12
- s.date = "2013-06-18"
12
+ s.date = "2013-08-12"
13
13
  s.description = "wrapper for the API for getchute.com"
14
14
  s.email = "support@gmail.com"
15
15
  s.extra_rdoc_files = [
16
- "LICENSE.txt",
16
+ "LICENSE.md",
17
17
  "README.md"
18
18
  ]
19
19
  s.files = [
20
+ "CHANGELOG.md",
20
21
  "Gemfile",
21
22
  "Gemfile.lock",
22
- "LICENSE.txt",
23
+ "LICENSE.md",
23
24
  "README.md",
24
25
  "Rakefile",
25
- "VERSION",
26
26
  "chute.gemspec",
27
27
  "lib/chute.rb",
28
28
  "lib/chute/client.rb",
@@ -63,6 +63,7 @@ Gem::Specification.new do |s|
63
63
  "spec/fixtures/chute_cassettes/albums/albums_import_assets.yml",
64
64
  "spec/fixtures/chute_cassettes/albums/albums_import_assets_from_instagram_id.yml",
65
65
  "spec/fixtures/chute_cassettes/albums/albums_list.yml",
66
+ "spec/fixtures/chute_cassettes/albums/albums_move_copy_asset.yml",
66
67
  "spec/fixtures/chute_cassettes/albums/albums_stats.yml",
67
68
  "spec/fixtures/chute_cassettes/albums/albums_update.yml",
68
69
  "spec/fixtures/chute_cassettes/assets/assets_delete.yml",
@@ -71,6 +72,7 @@ Gem::Specification.new do |s|
71
72
  "spec/fixtures/chute_cassettes/assets/assets_import.yml",
72
73
  "spec/fixtures/chute_cassettes/assets/assets_list.yml",
73
74
  "spec/fixtures/chute_cassettes/assets/assets_update.yml",
75
+ "spec/fixtures/chute_cassettes/assets/assets_upload.yml",
74
76
  "spec/fixtures/chute_cassettes/comments/comments_create.yml",
75
77
  "spec/fixtures/chute_cassettes/comments/comments_list.yml",
76
78
  "spec/fixtures/chute_cassettes/flags/flags_methods.yml",
@@ -85,41 +87,46 @@ Gem::Specification.new do |s|
85
87
  "spec/fixtures/chute_cassettes/users/users_get.yml",
86
88
  "spec/fixtures/chute_cassettes/users/users_me.yml",
87
89
  "spec/fixtures/chute_cassettes/votes/votes_methods.yml",
88
- "spec/spec_helper.rb"
90
+ "spec/fixtures/files/test_image.jpg",
91
+ "spec/spec_helper.rb",
92
+ "spec/support/file_helpers.rb"
89
93
  ]
90
94
  s.homepage = "https://github.com/chute/chute-sdk-2"
91
95
  s.licenses = ["MIT"]
92
96
  s.require_paths = ["lib"]
93
- s.rubygems_version = "1.8.25"
97
+ s.rubygems_version = "2.0.3"
94
98
  s.summary = "getchute API wrapper"
95
99
 
96
100
  if s.respond_to? :specification_version then
97
- s.specification_version = 3
101
+ s.specification_version = 4
98
102
 
99
103
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
100
104
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
101
105
  s.add_runtime_dependency(%q<hashie>, [">= 0"])
106
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
102
107
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
103
108
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
104
109
  s.add_development_dependency(%q<bundler>, [">= 0"])
105
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
110
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.6"])
106
111
  s.add_development_dependency(%q<simplecov>, [">= 0"])
107
112
  else
108
113
  s.add_dependency(%q<httparty>, [">= 0"])
109
114
  s.add_dependency(%q<hashie>, [">= 0"])
115
+ s.add_dependency(%q<rest-client>, [">= 0"])
110
116
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
111
117
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
112
118
  s.add_dependency(%q<bundler>, [">= 0"])
113
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
119
+ s.add_dependency(%q<jeweler>, ["~> 1.8.6"])
114
120
  s.add_dependency(%q<simplecov>, [">= 0"])
115
121
  end
116
122
  else
117
123
  s.add_dependency(%q<httparty>, [">= 0"])
118
124
  s.add_dependency(%q<hashie>, [">= 0"])
125
+ s.add_dependency(%q<rest-client>, [">= 0"])
119
126
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
120
127
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
121
128
  s.add_dependency(%q<bundler>, [">= 0"])
122
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
129
+ s.add_dependency(%q<jeweler>, ["~> 1.8.6"])
123
130
  s.add_dependency(%q<simplecov>, [">= 0"])
124
131
  end
125
132
  end
data/lib/chute.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "httparty"
2
+ require "rest_client"
2
3
 
3
4
  Dir[File.dirname(__FILE__) + '/chute/**/*.rb'].each do |file|
4
5
  require file
@@ -1,13 +1,14 @@
1
1
  module Chute
2
2
  module Configuration
3
3
 
4
- VALID_CONNECTION_KEYS = [:api_endpoint, :auth_endpoint].freeze
4
+ VALID_CONNECTION_KEYS = [:api_endpoint, :auth_endpoint, :upload_endpoint].freeze
5
5
  VALID_OPTIONS_KEYS = [:app_id, :app_secret, :access_token].freeze
6
6
  VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
7
7
 
8
8
 
9
9
  DEFAULT_API_ENDPOINT = 'https://api.getchute.com'
10
10
  DEFAULT_AUTH_ENDPOINT = 'https://getchute.com/auth'
11
+ DEFAULT_UPLOAD_ENDPOINT = 'http://upload.getchute.com'
11
12
 
12
13
  DEFAULT_APP_ID = 'app_id'
13
14
  DEFAULT_APP_SECRET = 'app_secret'
@@ -30,6 +31,7 @@ module Chute
30
31
  def reset
31
32
  self.api_endpoint = DEFAULT_API_ENDPOINT
32
33
  self.auth_endpoint = DEFAULT_AUTH_ENDPOINT
34
+ self.upload_endpoint = DEFAULT_UPLOAD_ENDPOINT
33
35
 
34
36
  self.app_id = DEFAULT_APP_ID
35
37
  self.app_secret = DEFAULT_APP_SECRET
@@ -59,6 +59,16 @@ module Chute
59
59
  Chute::Client.post("/v2/albums/#{album_id}/remove_assets",:asset_ids => asset_ids)
60
60
  end
61
61
 
62
+ # Move asset from one album to another, preserving all asset's metadata
63
+ def move_asset(album_id, asset_id, to_album)
64
+ Chute::Client.post("/v2/albums/#{album_id}/assets/#{asset_id}/move/#{to_album}")
65
+ end
66
+
67
+ # Copy asset from one album to another, carrying over all asset's metadata
68
+ def copy_asset(album_id, asset_id, to_album)
69
+ Chute::Client.post("/v2/albums/#{album_id}/assets/#{asset_id}/copy/#{to_album}")
70
+ end
71
+
62
72
  end
63
73
  end
64
74
  end
@@ -27,9 +27,14 @@ module Chute
27
27
  Chute::Client.get("/v2/assets/#{id}/geo")
28
28
  end
29
29
 
30
- # TODO Implement on server: Asset Create
31
- def upload(data)
32
- Chute::Client.post("/v2/assets/upload", :urls => urls)
30
+ def upload(albumId, f)
31
+ response = RestClient::Request.execute(:url => "#{Chute.upload_endpoint}/v2/albums/#{albumId}/assets/upload", :method => :post,
32
+ :payload => {
33
+ :multipart => true,
34
+ :filedata => f
35
+ },:headers => {"Authorization" => "Bearer #{Chute.access_token}"}
36
+ )
37
+ Chute::Connection.parse(JSON.parse(response.body))
33
38
  end
34
39
 
35
40
  def import(urls, shortcuts)
data/lib/chute/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Chute
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 0
5
- PATCH = 2
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -31,6 +31,7 @@ describe Chute::Client do
31
31
  @config = {
32
32
  :api_endpoint => 'api',
33
33
  :auth_endpoint => 'auth',
34
+ :upload_endpoint => "upload",
34
35
  :app_id => 'id',
35
36
  :app_secret => 'secret',
36
37
  :access_token => 'token',
@@ -192,6 +192,31 @@ describe Chute::V2::Albums do
192
192
 
193
193
  end
194
194
 
195
+ describe "POST move and copy asset" do
196
+
197
+ let(:id) { Chute::V2::Albums.create({:name => "Created Album"}).data.id }
198
+ let(:to_album) { Chute::V2::Albums.create({:name => "Created Album"}).data.id }
199
+
200
+ before do
201
+ VCR.insert_cassette 'albums/albums_move_copy_asset', :record => :new_episodes
202
+ end
203
+ after do
204
+ VCR.eject_cassette
205
+ end
206
+
207
+ it "should be able to move asset to another album" do
208
+ response = Chute::V2::Albums.move_asset(id, 8765443, to_album)
209
+ response.should be_true
210
+ end
211
+
212
+
213
+ it "should be able to copy asset to another album" do
214
+ response = Chute::V2::Albums.copy_asset(id, 3452424, to_album)
215
+ response.should be_true
216
+ end
217
+
218
+ end
219
+
195
220
  describe "POST to import Assets" do
196
221
 
197
222
  let(:id) { Chute::V2::Albums.create({:name => "Created Album"}).data.id }