instagram-continued 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -0
  3. data/.travis.yml +1 -0
  4. data/README.md +1 -1
  5. data/Rakefile +12 -11
  6. data/instagram-continued.gemspec +6 -5
  7. data/lib/faraday/loud_logger.rb +47 -48
  8. data/lib/faraday/oauth2.rb +16 -18
  9. data/lib/faraday/raise_http_exception.rb +9 -9
  10. data/lib/instagram.rb +8 -8
  11. data/lib/instagram/api.rb +4 -4
  12. data/lib/instagram/client.rb +1 -1
  13. data/lib/instagram/client/comments.rb +5 -5
  14. data/lib/instagram/client/embedding.rb +9 -9
  15. data/lib/instagram/client/likes.rb +5 -5
  16. data/lib/instagram/client/locations.rb +4 -4
  17. data/lib/instagram/client/media.rb +3 -3
  18. data/lib/instagram/client/subscriptions.rb +27 -27
  19. data/lib/instagram/client/tags.rb +3 -3
  20. data/lib/instagram/client/users.rb +19 -19
  21. data/lib/instagram/client/utils.rb +5 -5
  22. data/lib/instagram/configuration.rb +7 -6
  23. data/lib/instagram/connection.rb +7 -7
  24. data/lib/instagram/oauth.rb +8 -8
  25. data/lib/instagram/request.rb +23 -26
  26. data/lib/instagram/response.rb +8 -4
  27. data/lib/instagram/version.rb +1 -1
  28. data/spec/faraday/response_spec.rb +23 -25
  29. data/spec/instagram/api_spec.rb +90 -94
  30. data/spec/instagram/client/comments_spec.rb +21 -25
  31. data/spec/instagram/client/embedding_spec.rb +8 -8
  32. data/spec/instagram/client/geography_spec.rb +10 -13
  33. data/spec/instagram/client/likes_spec.rb +21 -25
  34. data/spec/instagram/client/locations_spec.rb +42 -48
  35. data/spec/instagram/client/media_spec.rb +33 -37
  36. data/spec/instagram/client/subscriptions_spec.rb +34 -46
  37. data/spec/instagram/client/tags_spec.rb +29 -33
  38. data/spec/instagram/client/users_spec.rb +155 -180
  39. data/spec/instagram/client/utils_spec.rb +8 -9
  40. data/spec/instagram/client_spec.rb +9 -9
  41. data/spec/instagram/request_spec.rb +27 -27
  42. data/spec/instagram_spec.rb +20 -24
  43. data/spec/spec_helper.rb +10 -10
  44. metadata +24 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb7dca52b65e36a84dde86803975799a9cd538ca
4
- data.tar.gz: c1c55884f48329f67ef88467ec06c31b0690d317
3
+ metadata.gz: 2cffa2f9ed95f70c0a1cc4d47a530460810384ec
4
+ data.tar.gz: b0f80fe802d90b61b8ead906dc227f3cc23b70da
5
5
  SHA512:
6
- metadata.gz: a1e5a32aad698a95721cfda44a1cfdb840b9e10b4cc5b605e72d976dbf39585d7a13e0cf746b16cf491250bbea0c0eed11fc519b8009c4ed4db7212b42ce403e
7
- data.tar.gz: b8670e10c46527e476ec3be6efa14bc515c039aeadba835c8373f9565ee117b8b620f272fc9e94bff8c9adf15bbb3ad86c4fc936673689513a6f8b15bfd16ca5
6
+ metadata.gz: e384994413ba6a1c0cca8d7d536254e5f582c73003c0692d4a949d32171c19b7c84a50ad75ab9bc7db4c13e6a25836135a2997275e00962fe8dbd3c44178af1e
7
+ data.tar.gz: 97a873844d5d5f2f1c107ecea2399c8c1586b8e0276d3541fb89a302fb9a830a8c00d799d78677a7e0150ab18fd7c3da5573498937232b9da36459912d5084aa
@@ -0,0 +1,11 @@
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
3
+ Style/StringLiteralsInInterpolation:
4
+ EnforcedStyle: double_quotes
5
+ Metrics/LineLength:
6
+ Max: 100
7
+ Style/TrailingCommaInLiteral:
8
+ EnforcedStyleForMultiline: comma
9
+ SupportedStyles:
10
+ - comma
11
+ - no_comma
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.3.1
4
4
  - 2.3.0
5
+ - 2.4.0
5
6
  - 2.2
6
7
  - 2.1
7
8
  - 2.0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Instagram-Continued
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/instagram-continued.svg)](https://badge.fury.io/rb/instagram-continued) [![Build Status](https://travis-ci.org/icco/instagram-ruby-gem.svg?branch=master)](https://travis-ci.org/icco/instagram-ruby-gem)
3
+ [![Gem Version](https://badge.fury.io/rb/instagram-continued.svg)](https://badge.fury.io/rb/instagram-continued) [![Build Status](https://travis-ci.org/icco/instagram-continued.svg?branch=master)](https://travis-ci.org/icco/instagram-continued)
4
4
 
5
5
  [![Dependency Status](https://gemnasium.com/badges/github.com/icco/instagram-continued.svg)](https://gemnasium.com/github.com/icco/instagram-continued)
6
6
 
data/Rakefile CHANGED
@@ -1,26 +1,27 @@
1
- require 'bundler'
1
+ require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rspec/core/rake_task'
4
+ require "rspec/core/rake_task"
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- task :default => :spec
7
+ task default: :spec
8
+ task test: :spec
8
9
 
9
10
  namespace :doc do
10
11
  begin
11
- require 'yard'
12
+ require "yard"
12
13
  rescue LoadError
13
14
  # ignore
14
15
  else
15
16
  YARD::Rake::YardocTask.new do |task|
16
- task.files = ['HISTORY.mkd', 'LICENSE.mkd', 'lib/**/*.rb']
17
+ task.files = ["HISTORY.mkd", "LICENSE.mkd", "lib/**/*.rb"]
17
18
  task.options = [
18
- '--protected',
19
- '--output-dir', 'doc/yard',
20
- '--tag', 'format:Supported formats',
21
- '--tag', 'authenticated:Requires Authentication',
22
- '--tag', 'rate_limited:Rate Limited',
23
- '--markup', 'markdown',
19
+ "--protected",
20
+ "--output-dir", "doc/yard",
21
+ "--tag", "format:Supported formats",
22
+ "--tag", "authenticated:Requires Authentication",
23
+ "--tag", "rate_limited:Rate Limited",
24
+ "--markup", "markdown"
24
25
  ]
25
26
  end
26
27
  end
@@ -6,16 +6,17 @@ Gem::Specification.new do |s|
6
6
  s.add_development_dependency("rspec", "~> 3.4")
7
7
  s.add_development_dependency("webmock", "~> 1.22")
8
8
  s.add_development_dependency("bluecloth", "~> 2.2")
9
+ s.add_development_dependency("rubocop")
9
10
 
10
11
  s.add_runtime_dependency("faraday", "~> 0.11")
11
12
  s.add_runtime_dependency("faraday_middleware")
12
- s.add_runtime_dependency("multi_json", "~> 1.12")
13
- s.add_runtime_dependency("hashie", "~> 3.4")
13
+ s.add_runtime_dependency("multi_json")
14
+ s.add_runtime_dependency("hashie")
14
15
 
15
16
  s.authors = ["Shayne Sweeney", "Nat Welch"]
16
- s.description = %q{A Ruby wrapper for the Instagram REST and Search APIs}
17
+ s.description = "A Ruby wrapper for the Instagram REST and Search APIs"
17
18
  s.email = ["shayne@instagr.am", "nat@natwelch.com"]
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
20
  s.files = `git ls-files`.split("\n")
20
21
  s.homepage = "https://github.com/icco/instagram-continued"
21
22
  s.name = "instagram-continued"
@@ -24,7 +25,7 @@ Gem::Specification.new do |s|
24
25
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6")
25
26
  s.required_ruby_version = Gem::Requirement.new(">= 2.0.0")
26
27
  s.rubyforge_project = s.name
27
- s.summary = %q{Ruby wrapper for the Instagram API}
28
+ s.summary = "Ruby wrapper for the Instagram API"
28
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
30
  s.version = Instagram::VERSION.dup
30
31
  end
@@ -1,61 +1,61 @@
1
- require 'faraday'
1
+ require "faraday"
2
2
 
3
3
  # @private
4
4
  module FaradayMiddleware
5
5
  # @private
6
6
  class LoudLogger < Faraday::Middleware
7
- extend Forwardable
8
- def_delegators :@logger, :debug, :info, :warn, :error, :fatal
7
+ extend Forwardable
8
+ def_delegators :@logger, :debug, :info, :warn, :error, :fatal
9
9
 
10
- def initialize(app, options = {})
11
- @app = app
12
- @logger = options.fetch(:logger) {
13
- require 'logger'
14
- ::Logger.new($stdout)
15
- }
10
+ def initialize(app, options = {})
11
+ @app = app
12
+ @logger = options.fetch(:logger) do
13
+ require "logger"
14
+ ::Logger.new($stdout)
16
15
  end
16
+ end
17
17
 
18
- def call(env)
19
- start_time = Time.now
20
- info { request_info(env) }
21
- debug { request_debug(env) }
22
- @app.call(env).on_complete do
23
- end_time = Time.now
24
- response_time = end_time - start_time
25
- info { response_info(env, response_time) }
26
- debug { response_debug(env) }
27
- end
18
+ def call(env)
19
+ start_time = Time.now
20
+ info { request_info(env) }
21
+ debug { request_debug(env) }
22
+ @app.call(env).on_complete do
23
+ end_time = Time.now
24
+ response_time = end_time - start_time
25
+ info { response_info(env, response_time) }
26
+ debug { response_debug(env) }
28
27
  end
28
+ end
29
29
 
30
- private
30
+ private
31
31
 
32
- def filter(output)
33
- if ENV['INSTAGRAM_GEM_REDACT']
34
- output = output.to_s.gsub(/client_id=[a-zA-Z0-9]*/,'client_id=[CLIENT-ID]')
35
- output = output.to_s.gsub(/access_token=[a-zA-Z0-9]*/,'access_token=[ACCESS-TOKEN]')
36
- else
37
- output
38
- end
32
+ def filter(output)
33
+ if ENV["INSTAGRAM_GEM_REDACT"]
34
+ output = output.to_s.gsub(/client_id=[a-zA-Z0-9]*/, "client_id=[CLIENT-ID]")
35
+ output = output.to_s.gsub(/access_token=[a-zA-Z0-9]*/, "access_token=[ACCESS-TOKEN]")
36
+ else
37
+ output
39
38
  end
39
+ end
40
40
 
41
- def request_info(env)
42
- "Started %s request to: %s" % [ env[:method].to_s.upcase, filter(env[:url]) ]
43
- end
41
+ def request_info(env)
42
+ "Started %s request to: %s" % [env[:method].to_s.upcase, filter(env[:url])]
43
+ end
44
44
 
45
- def response_info(env, response_time)
46
- "Response from %s; Status: %d; Time: %.1fms" % [ filter(env[:url]), env[:status], (response_time * 1_000.0) ]
47
- end
45
+ def response_info(env, response_time)
46
+ "Response from %s; Status: %d; Time: %.1fms" % [filter(env[:url]), env[:status], (response_time * 1_000.0)]
47
+ end
48
48
 
49
- def request_debug(env)
50
- debug_message("Request", env[:request_headers], env[:body])
51
- end
49
+ def request_debug(env)
50
+ debug_message("Request", env[:request_headers], env[:body])
51
+ end
52
52
 
53
- def response_debug(env)
54
- debug_message("Response", env[:response_headers], env[:body])
55
- end
53
+ def response_debug(env)
54
+ debug_message("Response", env[:response_headers], env[:body])
55
+ end
56
56
 
57
- def debug_message(name, headers, body)
58
- <<-MESSAGE.gsub(/^ +([^ ])/m, '\\1')
57
+ def debug_message(name, headers, body)
58
+ <<-MESSAGE.gsub(/^ +([^ ])/m, '\\1')
59
59
  #{name} Headers:
60
60
  ----------------
61
61
  #{format_headers(headers)}
@@ -64,12 +64,11 @@ module FaradayMiddleware
64
64
  -------------
65
65
  #{filter(body)}
66
66
  MESSAGE
67
- end
68
-
69
- def format_headers(headers)
70
- length = headers.map {|k,v| k.to_s.size }.max
71
- headers.map { |name, value| "#{name.to_s.ljust(length)} : #{filter(value)}" }.join("\n")
72
- end
67
+ end
73
68
 
69
+ def format_headers(headers)
70
+ length = headers.map { |k, _v| k.to_s.size }.max
71
+ headers.map { |name, value| "#{name.to_s.ljust(length)} : #{filter(value)}" }.join("\n")
72
+ end
74
73
  end
75
- end
74
+ end
@@ -1,39 +1,37 @@
1
- require 'faraday'
1
+ require "faraday"
2
2
 
3
3
  # @private
4
4
  module FaradayMiddleware
5
5
  # @private
6
6
  class InstagramOAuth2 < Faraday::Middleware
7
7
  def call(env)
8
+ if (env[:method] == :get) || (env[:method] == :delete)
9
+ query = if env[:url].query.nil?
10
+ {}
11
+ else
12
+ Faraday::Utils.parse_query(env[:url].query)
13
+ end
8
14
 
9
- if env[:method] == :get or env[:method] == :delete
10
- if env[:url].query.nil?
11
- query = {}
12
- else
13
- query = Faraday::Utils.parse_query(env[:url].query)
14
- end
15
-
16
- if @access_token and not query["client_secret"]
17
- env[:url].query = Faraday::Utils.build_query(query.merge(:access_token => @access_token))
18
- env[:request_headers] = env[:request_headers].merge('Authorization' => "Token token=\"#{@access_token}\"")
15
+ if @access_token && !(query["client_secret"])
16
+ env[:url].query = Faraday::Utils.build_query(query.merge(access_token: @access_token))
17
+ env[:request_headers] = env[:request_headers].merge("Authorization" => "Token token=\"#{@access_token}\"")
19
18
  elsif @client_id
20
- env[:url].query = Faraday::Utils.build_query(query.merge(:client_id => @client_id))
19
+ env[:url].query = Faraday::Utils.build_query(query.merge(client_id: @client_id))
21
20
  end
22
21
  else
23
- if @access_token and not env[:body] && env[:body][:client_secret]
22
+ if @access_token && !(env[:body] && env[:body][:client_secret])
24
23
  env[:body] = {} if env[:body].nil?
25
- env[:body] = env[:body].merge(:access_token => @access_token)
26
- env[:request_headers] = env[:request_headers].merge('Authorization' => "Token token=\"#{@access_token}\"")
24
+ env[:body] = env[:body].merge(access_token: @access_token)
25
+ env[:request_headers] = env[:request_headers].merge("Authorization" => "Token token=\"#{@access_token}\"")
27
26
  elsif @client_id
28
- env[:body] = env[:body].merge(:client_id => @client_id)
27
+ env[:body] = env[:body].merge(client_id: @client_id)
29
28
  end
30
29
  end
31
30
 
32
-
33
31
  @app.call env
34
32
  end
35
33
 
36
- def initialize(app, client_id, access_token=nil)
34
+ def initialize(app, client_id, access_token = nil)
37
35
  @app = app
38
36
  @client_id = client_id
39
37
  @access_token = access_token
@@ -1,4 +1,4 @@
1
- require 'faraday'
1
+ require "faraday"
2
2
 
3
3
  # @private
4
4
  module FaradayMiddleware
@@ -35,27 +35,27 @@ module FaradayMiddleware
35
35
  private
36
36
 
37
37
  def error_message_400(response)
38
- "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]}#{error_body(response[:body])}"
38
+ "#{response[:method].to_s.upcase} #{response[:url]}: #{response[:status]}#{error_body(response[:body])}"
39
39
  end
40
40
 
41
41
  def error_body(body)
42
42
  # body gets passed as a string, not sure if it is passed as something else from other spots?
43
- if not body.nil? and not body.empty? and body.kind_of?(String)
43
+ if !body.nil? && !body.empty? && body.is_a?(String)
44
44
  # removed multi_json thanks to wesnolte's commit
45
45
  body = ::JSON.parse(body)
46
46
  end
47
47
 
48
48
  if body.nil?
49
49
  nil
50
- elsif body['meta'] and body['meta']['error_message'] and not body['meta']['error_message'].empty?
51
- ": #{body['meta']['error_message']}"
52
- elsif body['error_message'] and not body['error_message'].empty?
53
- ": #{body['error_type']}: #{body['error_message']}"
50
+ elsif body["meta"] && body["meta"]["error_message"] && !body["meta"]["error_message"].empty?
51
+ ": #{body["meta"]["error_message"]}"
52
+ elsif body["error_message"] && !body["error_message"].empty?
53
+ ": #{body["error_type"]}: #{body["error_message"]}"
54
54
  end
55
55
  end
56
56
 
57
- def error_message_500(response, body=nil)
58
- "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{[response[:status].to_s + ':', body].compact.join(' ')}"
57
+ def error_message_500(response, body = nil)
58
+ "#{response[:method].to_s.upcase} #{response[:url]}: #{[response[:status].to_s + ":", body].compact.join(" ")}"
59
59
  end
60
60
  end
61
61
  end
@@ -1,8 +1,8 @@
1
- require File.expand_path('../instagram/error', __FILE__)
2
- require File.expand_path('../instagram/configuration', __FILE__)
3
- require File.expand_path('../instagram/api', __FILE__)
4
- require File.expand_path('../instagram/client', __FILE__)
5
- require File.expand_path('../instagram/response', __FILE__)
1
+ require File.expand_path("../instagram/error", __FILE__)
2
+ require File.expand_path("../instagram/configuration", __FILE__)
3
+ require File.expand_path("../instagram/api", __FILE__)
4
+ require File.expand_path("../instagram/client", __FILE__)
5
+ require File.expand_path("../instagram/response", __FILE__)
6
6
 
7
7
  module Instagram
8
8
  extend Configuration
@@ -10,7 +10,7 @@ module Instagram
10
10
  # Alias for Instagram::Client.new
11
11
  #
12
12
  # @return [Instagram::Client]
13
- def self.client(options={})
13
+ def self.client(options = {})
14
14
  Instagram::Client.new(options)
15
15
  end
16
16
 
@@ -21,7 +21,7 @@ module Instagram
21
21
  end
22
22
 
23
23
  # Delegate to Instagram::Client
24
- def self.respond_to?(method, include_all=false)
25
- return client.respond_to?(method, include_all) || super
24
+ def self.respond_to?(method, include_all = false)
25
+ client.respond_to?(method, include_all) || super
26
26
  end
27
27
  end
@@ -1,6 +1,6 @@
1
- require File.expand_path('../connection', __FILE__)
2
- require File.expand_path('../request', __FILE__)
3
- require File.expand_path('../oauth', __FILE__)
1
+ require File.expand_path("../connection", __FILE__)
2
+ require File.expand_path("../request", __FILE__)
3
+ require File.expand_path("../oauth", __FILE__)
4
4
 
5
5
  module Instagram
6
6
  # @private
@@ -9,7 +9,7 @@ module Instagram
9
9
  attr_accessor *Configuration::VALID_OPTIONS_KEYS
10
10
 
11
11
  # Creates a new API
12
- def initialize(options={})
12
+ def initialize(options = {})
13
13
  options = Instagram.options.merge(options)
14
14
  Configuration::VALID_OPTIONS_KEYS.each do |key|
15
15
  send("#{key}=", options[key])
@@ -4,7 +4,7 @@ module Instagram
4
4
  # @note All methods have been separated into modules and follow the same grouping used in http://instagram.com/developer/
5
5
  # @see http://instagram.com/developer/
6
6
  class Client < API
7
- Dir[File.expand_path('../client/*.rb', __FILE__)].each{|f| require f}
7
+ Dir[File.expand_path("../client/*.rb", __FILE__)].each { |f| require f }
8
8
 
9
9
  include Instagram::Client::Utils
10
10
 
@@ -15,7 +15,7 @@ module Instagram
15
15
  # If getting this data of a protected user, you must be authenticated (and be allowed to see that user).
16
16
  # @rate_limited true
17
17
  # @see http://instagram.com/developer/endpoints/comments/#get_media_comments
18
- def media_comments(id, *args)
18
+ def media_comments(id, *_args)
19
19
  response = get("media/#{id}/comments")
20
20
  response
21
21
  end
@@ -34,8 +34,8 @@ module Instagram
34
34
  # If getting this data of a protected user, you must be authenticated (and be allowed to see that user).
35
35
  # @rate_limited true
36
36
  # @see http://instagram.com/developer/endpoints/comments/#post_media_comments
37
- def create_media_comment(id, text, options={})
38
- response = post("media/#{id}/comments", options.merge(:text => text), signature=true)
37
+ def create_media_comment(id, text, options = {})
38
+ response = post("media/#{id}/comments", options.merge(text: text), signature = true)
39
39
  response
40
40
  end
41
41
 
@@ -53,8 +53,8 @@ module Instagram
53
53
  # In order to remove a comment, you must be the owner of the comment, the media item, or both.
54
54
  # @rate_limited true
55
55
  # @see http://instagram.com/developer/endpoints/comments/#delete_media_comments
56
- def delete_media_comment(media_id, comment_id, options={})
57
- response = delete("media/#{media_id}/comments/#{comment_id}", options, signature=true)
56
+ def delete_media_comment(media_id, comment_id, options = {})
57
+ response = delete("media/#{media_id}/comments/#{comment_id}", options, signature = true)
58
58
  response
59
59
  end
60
60
  end
@@ -1,16 +1,16 @@
1
1
  module Instagram
2
2
  class Client
3
- # Defines methods related to embedding
3
+ # Defines methods related to embedding
4
4
  module Embedding
5
- # Returns information about the media associated with the given short link
5
+ # Returns information about the media associated with the given short link
6
6
  #
7
- # @overload oembed(url=nil, options={})
8
- # @param url [String] An instagram short link
9
- # @param options [Hash] A customizable set of options
10
- # @option options [Integer] :maxheight Maximum height of returned media
11
- # @option options [Integer] :maxwidth Maximum width of returned media
12
- # @option options [Integer] :callback A JSON callback to be invoked
13
- # @return [Hashie::Mash] Information about the media associated with given short link
7
+ # @overload oembed(url=nil, options={})
8
+ # @param url [String] An instagram short link
9
+ # @param options [Hash] A customizable set of options
10
+ # @option options [Integer] :maxheight Maximum height of returned media
11
+ # @option options [Integer] :maxwidth Maximum width of returned media
12
+ # @option options [Integer] :callback A JSON callback to be invoked
13
+ # @return [Hashie::Mash] Information about the media associated with given short link
14
14
  # @example Return information about the media associated with http://instagr.am/p/BUG/
15
15
  # Instagram.oembed(http://instagr.am/p/BUG/)
16
16
  #