EyeEmConnector 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem 'oauth2'
6
+ gem 'multi_json'
7
+ gem 'faraday', "~> 0.8.0"
8
+ gem 'faraday_middleware'
9
+ gem 'rash'
10
+
11
+
12
+ # Add dependencies to develop your gem here.
13
+ # Include everything needed to run rake, tests, features, etc.
14
+ group :development do
15
+ gem "rspec", "~> 2.8.0"
16
+ gem "rdoc", "~> 3.12"
17
+ gem "bundler", "~> 1.0.0"
18
+ gem "jeweler", "~> 1.8.3"
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 André Rieck
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = EyeEmConnector
2
+
3
+ Wrapper for the EyeEm API(https://github.com/eyeem/Public-API/wiki).
4
+
5
+ == Contributing to EyeEmConnector
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 André Rieck. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "EyeEmConnector"
18
+ gem.homepage = "http://github.com/Varek/EyeEmConnector"
19
+ gem.license = "MIT"
20
+ gem.summary = "EyeEm API Wrapper in Ruby"
21
+ gem.description = "EyeEm API Wrapper in Ruby"
22
+ gem.email = "4ndr3r13ck@googlemail.com"
23
+ gem.authors = ["André Rieck"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "EyeEmConnector #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,39 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require File.expand_path('../request', __FILE__)
4
+ Dir[File.expand_path('../models/*.rb', __FILE__)].each{|f| require f}
5
+
6
+ module EyeEmConnector
7
+
8
+ class Client
9
+
10
+ attr_accessor *Configuration::VALID_OPTIONS
11
+
12
+ def initialize(options={})
13
+ options = EyeEmConnector.options.merge(options)
14
+ Configuration::VALID_OPTIONS.each do |key|
15
+ send("#{key}=", options[key])
16
+ end
17
+ end
18
+
19
+ def connection
20
+ params = access_token.nil? ? {:client_id => @client_id} : {}
21
+ Faraday::Connection.new(:url => Configuration::ENDPOINT, :params => params, :ssl => {:verify => false}) do |builder|
22
+ builder.request :oauth2, @access_token unless @access_token.nil?
23
+ builder.request :json
24
+ builder.response :json
25
+ builder.adapter Faraday.default_adapter
26
+ end
27
+ end
28
+
29
+ include Request
30
+ include EyeEmConnector::Client::Albums
31
+ include EyeEmConnector::Client::News
32
+ include EyeEmConnector::Client::Photos
33
+ include EyeEmConnector::Client::Search
34
+ include EyeEmConnector::Client::Topics
35
+ include EyeEmConnector::Client::Users
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,20 @@
1
+ module EyeEmConnector
2
+
3
+ module Configuration
4
+
5
+ ENDPOINT = 'https://www.eyeem.com/api/v2/'
6
+ VALID_OPTIONS = [:client_id, :client_secret, :access_token]
7
+ attr_accessor *VALID_OPTIONS
8
+
9
+ def configure
10
+ yield self
11
+ end
12
+
13
+ def options
14
+ VALID_OPTIONS.inject({}) do |option, key|
15
+ option.merge!(key => send(key))
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,49 @@
1
+ module EyeEmConnector
2
+
3
+ class Client
4
+
5
+ module Albums
6
+ # for the options of different albums endpoints, see https://github.com/eyeem/Public-API/wiki/Albums
7
+ def albums_recommended(options={})
8
+ response = request('albums/recommended',options)
9
+ response.body
10
+ end
11
+
12
+ def albums(options={})
13
+ response = request('albums',options)
14
+ response.body
15
+ end
16
+
17
+ def album(id,options={})
18
+ response = request('albums/'+id.to_s,options)
19
+ response.body
20
+ end
21
+
22
+ def album_photos(id,options={})
23
+ response = request('albums/'+id.to_s+'/photos',options)
24
+ response.body
25
+ end
26
+
27
+ def album_likers(id,options={})
28
+ response = request('albums/'+id.to_s+'/likers',options)
29
+ response.body
30
+ end
31
+
32
+ def album_contributors(id,options={})
33
+ response = request('albums/'+id.to_s+'/contributors',options)
34
+ response.body
35
+ end
36
+
37
+ def album_liker(album_id,liker_id,options={})
38
+ response = request("albums/#{album_id.to_s}/likers/#{liker_id}",options)
39
+ response.status == 200
40
+ end
41
+
42
+ def album_contributor(album_id,contributer_id,options={})
43
+ response = request("albums/#{album_id.to_s}/contributors/#{contributer_id}",options)
44
+ response.status == 200
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,20 @@
1
+ module EyeEmConnector
2
+
3
+ class Client
4
+
5
+ module News
6
+ # for the options of different albums endpoints, see https://github.com/eyeem/Public-API/wiki/Albums
7
+
8
+ def news(options={}) #access token required
9
+ response = request('news',options)
10
+ response.body
11
+ end
12
+
13
+ def single_news(id,options={}) #access token required
14
+ response = request("news/#{id}",options)
15
+ response.body
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,40 @@
1
+ module EyeEmConnector
2
+
3
+ class Client
4
+
5
+ module Photos
6
+ # for the options of different albums endpoints, see https://github.com/eyeem/Public-API/wiki/Albums
7
+
8
+ def photos(options={}) #access token needed, returns photos of authenticated user
9
+ response = request('photos',options)
10
+ response.body
11
+ end
12
+
13
+ def photo(id,options={})
14
+ response = request('photos/'+id.to_s,options)
15
+ response.body
16
+ end
17
+
18
+ def photo_likers(id,options={})
19
+ response = request('photos/'+id.to_s+'/likers',options)
20
+ response.body
21
+ end
22
+
23
+ def photo_liker(photo_id,liker_id,options={})
24
+ response = request("photos/#{photo_id.to_s}/likers/#{liker_id}",options)
25
+ response.status == 200
26
+ end
27
+
28
+ def photo_comments(id,options={})
29
+ response = request('photos/'+id.to_s+'/comments',options)
30
+ response.body
31
+ end
32
+
33
+ def photo_comment(photo_id,contributer_id,options={})
34
+ response = request("photos/#{photo_id.to_s}/comments/#{contributer_id}",options)
35
+ response.body
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ module EyeEmConnector
2
+
3
+ class Client
4
+
5
+ module Search
6
+ # for the options of different albums endpoints, see https://github.com/eyeem/Public-API/wiki/Albums
7
+
8
+ def search(options={})
9
+ response = request('search',options)
10
+ response.body
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module EyeEmConnector
2
+
3
+ class Client
4
+
5
+ module Topics
6
+ # for the options of different albums endpoints, see https://github.com/eyeem/Public-API/wiki/Albums
7
+
8
+ def topics(options={})
9
+ response = request('topics',options)
10
+ response.body
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,75 @@
1
+ module EyeEmConnector
2
+
3
+ class Client
4
+
5
+ module Users
6
+ # for the options of different users endpoints, see https://github.com/eyeem/Public-API/wiki/users
7
+
8
+ def users(options={})
9
+ response = request('users',options)
10
+ response.body
11
+ end
12
+
13
+ def user(id,options={})
14
+ response = request('users/'+id.to_s,options)
15
+ response.body
16
+ end
17
+
18
+ def user_photos(id,options={})
19
+ response = request('users/'+id.to_s+'/photos',options)
20
+ response.body
21
+ end
22
+
23
+ def user_liked_photos(id,options={})
24
+ response = request('users/'+id.to_s+'/likedPhotos',options)
25
+ response.body
26
+ end
27
+
28
+ def user_friends_photos(id,options={})
29
+ response = request('users/'+id.to_s+'/friendsPhotos',options)
30
+ response.body
31
+ end
32
+
33
+ def user_liked_albums(id,options={})
34
+ response = request('users/'+id.to_s+'/likedAlbums',options)
35
+ response.body
36
+ end
37
+
38
+ def user_feed(id,options={}) #access token required
39
+ response = request('users/'+id.to_s+'/feed',options)
40
+ response.body
41
+ end
42
+
43
+ def user_friends(id,options={})
44
+ response = request('users/'+id.to_s+'/friends',options)
45
+ response.body
46
+ end
47
+
48
+ def user_friend(user_id,friend_id,options={})
49
+ response = request("users/#{user_id}/friends/#{friend_id}",options)
50
+ response.status == 200
51
+ end
52
+
53
+ def user_followers(id,options={})
54
+ response = request('users/'+id.to_s+'/followers',options)
55
+ response.body
56
+ end
57
+
58
+ def user_follower(user_id,follower_id,options={})
59
+ response = request("users/#{user_id}/followers/#{follower_id}",options)
60
+ response.status == 200
61
+ end
62
+
63
+ def user_topics(id,options={}) #access token required
64
+ response = request("users/#{id.to_s}/topics",options)
65
+ response.body
66
+ end
67
+
68
+ def user_social_media(id,options={}) #access token required
69
+ response = request("users/#{id.to_s}/socialMedia",options)
70
+ response.body
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,16 @@
1
+ require 'multi_json'
2
+ require 'rash'
3
+ module EyeEmConnector
4
+
5
+ module Request
6
+ def request(endpoint,options={})
7
+ response = connection.get(endpoint) do |rq|
8
+ options.each do |option, value|
9
+ rq.params[option] = value
10
+ end
11
+ end || ''
12
+ response
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path('../EyeEmConnector/configuration', __FILE__)
2
+ require File.expand_path('../EyeEmConnector/client', __FILE__)
3
+
4
+ module EyeEmConnector
5
+ extend Configuration
6
+ def self.client(options={})
7
+ EyeEmConnector::Client.new(options)
8
+ end
9
+
10
+ def self.method_missing(method, *args, &block)
11
+ return super unless client.respond_to?(method)
12
+ client.send(method, *args, &block)
13
+ end
14
+
15
+ def self.respond_to?(method)
16
+ return client.respond_to?(method) || super
17
+ end
18
+
19
+
20
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Eyeemconnector" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'EyeEmConnector'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: EyeEmConnector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - André Rieck
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-17 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: oauth2
16
+ requirement: &70257841083320 !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: *70257841083320
25
+ - !ruby/object:Gem::Dependency
26
+ name: multi_json
27
+ requirement: &70257841082840 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70257841082840
36
+ - !ruby/object:Gem::Dependency
37
+ name: faraday
38
+ requirement: &70257841082300 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.8.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70257841082300
47
+ - !ruby/object:Gem::Dependency
48
+ name: faraday_middleware
49
+ requirement: &70257841081780 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70257841081780
58
+ - !ruby/object:Gem::Dependency
59
+ name: rash
60
+ requirement: &70257841081300 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70257841081300
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: &70257841080820 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 2.8.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70257841080820
80
+ - !ruby/object:Gem::Dependency
81
+ name: rdoc
82
+ requirement: &70257841080300 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '3.12'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70257841080300
91
+ - !ruby/object:Gem::Dependency
92
+ name: bundler
93
+ requirement: &70257841079820 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.0.0
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70257841079820
102
+ - !ruby/object:Gem::Dependency
103
+ name: jeweler
104
+ requirement: &70257841079340 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.8.3
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70257841079340
113
+ description: EyeEm API Wrapper in Ruby
114
+ email: 4ndr3r13ck@googlemail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files:
118
+ - LICENSE.txt
119
+ - README.rdoc
120
+ files:
121
+ - .document
122
+ - .rspec
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.rdoc
126
+ - Rakefile
127
+ - VERSION
128
+ - lib/EyeEmConnector.rb
129
+ - lib/EyeEmConnector/client.rb
130
+ - lib/EyeEmConnector/configuration.rb
131
+ - lib/EyeEmConnector/models/albums.rb
132
+ - lib/EyeEmConnector/models/news.rb
133
+ - lib/EyeEmConnector/models/photos.rb
134
+ - lib/EyeEmConnector/models/search.rb
135
+ - lib/EyeEmConnector/models/topics.rb
136
+ - lib/EyeEmConnector/models/users.rb
137
+ - lib/EyeEmConnector/request.rb
138
+ - spec/EyeEmConnector_spec.rb
139
+ - spec/spec_helper.rb
140
+ homepage: http://github.com/Varek/EyeEmConnector
141
+ licenses:
142
+ - MIT
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ segments:
154
+ - 0
155
+ hash: 1699859503115762509
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 1.8.10
165
+ signing_key:
166
+ specification_version: 3
167
+ summary: EyeEm API Wrapper in Ruby
168
+ test_files: []