giphy_api_ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66ccfe32afbe3eec98cb486fced81e7f93ec20e3
4
+ data.tar.gz: b1d6aa98bd98072d04ef7f571530200e66bbf9df
5
+ SHA512:
6
+ metadata.gz: 13a2d657a957718c76056f8f326dd0ebb255ab21fa4beab0aa0036d76f39cb538adaeb12f889d78e66fa68dc58624f6218ada391b319a069b6d1e32c27390b32
7
+ data.tar.gz: 9140663921d55e3d721d07d82c196c1dba007b8b61182cef854f278485d200c7e16f889c961067f826a46dda02de1e362fc7426f02cbfcbb6af404bf822fef4f
data/.codecov.yml ADDED
@@ -0,0 +1,24 @@
1
+ coverage:
2
+ status:
3
+ project: # measuring the overall project coverage
4
+ default: # context, you can create multiple ones with custom titles
5
+ enabled: no # must be yes|true to enable this status
6
+ target: 100% # specify the target coverage for each commit status
7
+ # option: "auto" (must increase from parent commit or pull request base)
8
+ # option: "X%" a static target percentage to hit
9
+ if_no_uploads: error # will post commit status of "error" if no coverage reports we uploaded
10
+ # options: success, error, failure
11
+ if_not_found: success # if parent is not found report status as success, error, or failure
12
+ if_ci_failed: error # if ci fails report status as success, error, or failure
13
+
14
+ patch: # pull requests only: this commit status will measure the
15
+ # entire pull requests Coverage Diff. Checking if the lines
16
+ # adjusted are covered at least X%.
17
+ default:
18
+ enabled: yes # must be yes|true to enable this status
19
+ target: auto # specify the target "X%" coverage to hit
20
+ if_no_uploads: error # will post commit status of "error" if no coverage reports were uploaded
21
+ # options: success, error, failure
22
+ if_not_found: success
23
+ if_ci_failed: error
24
+ comment: false
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .byebug_history
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.1
5
+ - 2.2.0
6
+ - 2.3.0
7
+ - 2.4.0
8
+ before_install: gem install bundler -v 1.12.5
9
+ script: rake test RUBYOPT="-W0"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in giphy_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Farrukh Abdulkadyrov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # Giphy API
2
+
3
+ [![Build Status](https://travis-ci.org/faragorn/giphy_api_ruby.svg?branch=master)](https://travis-ci.org/faragorn/giphy_api_ruby)
4
+ [![codecov](https://codecov.io/gh/faragorn/giphy_api_ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/faragorn/giphy_api_ruby)
5
+ [![Code Climate](https://codeclimate.com/github/faragorn/giphy_api_ruby/badges/gpa.svg)](https://codeclimate.com/github/faragorn/giphy_api_ruby)
6
+
7
+ Giphy API gem allows Ruby developers to progromatically access Giphy API V1.
8
+
9
+ This gem supports all endpoints that are officially documented by Giphy. Please refer to [Giphy API Documentation](https://developers.giphy.com/docs/) for more details about endpoints and parameters.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+ ```ruby
15
+ gem 'giphy_api_ruby'
16
+ ```
17
+ or to install directly from github:
18
+ ```ruby
19
+ gem 'giphy_api_ruby', github: 'faragorn/giphy_api_ruby'
20
+ ```
21
+
22
+
23
+ And then execute:
24
+
25
+ $ bundle install
26
+
27
+ RubyGems version is coming soon!
28
+
29
+ ## Configuration
30
+
31
+ ```ruby
32
+ GiphyAPI.configure do |config|
33
+ config.api_key = 'YOUR API KEY' # ENV['GIPHY_API_KEY'] by default
34
+ config.json_parser = MultiJson # JSON by default
35
+ config.api_prefix = 'v1' # 'v1' by default
36
+ end
37
+ ```
38
+
39
+ You are highly recommended to use a different JSON parser for perfomance reasons. <br />
40
+ The easiset solution is to use [MultiJSON](https://github.com/intridea/multi_json) gem. <br />
41
+ Your custom JSON parser must implement `load` method.
42
+
43
+ ## Usage
44
+
45
+ ### Requesting Gifs
46
+
47
+ ```ruby
48
+ # Searching Gifs by keyword:
49
+ # http://api.giphy.com/v1/gifs/search?q=aliens&api_key=YOUR_API_KEY
50
+ gifs = GiphyAPI::Gif.search('aliens')
51
+ # http://api.giphy.com/v1/gifs/search?q=aliens&limit=10&offset=20&rating=g&lang=en&api_key=YOUR_API_KEY
52
+ gifs = GiphyAPI::Gif.search('aliens', limit: 10, offset: 20, rating: 'g', lang: 'en')
53
+ #
54
+ # Trending Gifs:
55
+ # http://api.giphy.com/v1/gifs/trending?api_key=YOUR_API_KEY
56
+ gifs = GiphyAPI::Gif.trending()
57
+ # http://api.giphy.com/v1/gifs/trending?limit=20&rating=g&api_key=YOUR_API_KEY
58
+ gifs = GiphyAPI::Gif.trending(limit: 20, rating: 'g')
59
+ #
60
+ # Random Gif:
61
+ # http://api.giphy.com/v1/gifs/random?api_key=YOUR_API_KEY
62
+ gif = GiphyAPI::Gif.random()
63
+ # http://api.giphy.com/v1/gifs/random?tag=burito&rating=g&api_key=YOUR_API_KEY
64
+ gif = GiphyAPI::Gif.random(tag: 'burrito', rating: 'g')
65
+ #
66
+ # Translated Gif:
67
+ # http://api.giphy.com/v1/gifs/translate?s=moo&api_key=YOUR_API_KEY
68
+ gif = GiphyAPI::Gif.translate('moo')
69
+ #
70
+ # Get a Gif by id:
71
+ # http://api.giphy.com/v1/gifs/jWq123?api_key=YOUR_API_KEY
72
+ gif = GiphyAPI::Gif.find('jWq123')
73
+ #
74
+ # Get Gifs by a list of ids:
75
+ # http://api.giphy.com/v1/gifs?ids=jWq123,Pv01&api_key=YOUR_API_KEY
76
+ gifs = GiphyAPI::Gif.find_by_ids('jWq123', 'Pv01')
77
+ ```
78
+
79
+ ### Requesting Stickers
80
+ ```ruby
81
+ # Searching Stickers by keyword:
82
+ # http://api.giphy.com/v1/stickers/search?q=aliens&api_key=YOUR_API_KEY
83
+ stickers = GiphyAPI::Sticker.search('aliens')
84
+ # http://api.giphy.com/v1/stickers/search?q=aliens&limit=10&offset=20&rating=g&lang=en&api_key=YOUR_API_KEY
85
+ stickers = GiphyAPI::Sticker.search('aliens', limit: 10, offset: 20, rating: 'g', lang: 'en')
86
+ #
87
+ # Trending Stickers:
88
+ # http://api.giphy.com/v1/stickers/trending?api_key=YOUR_API_KEY
89
+ stickers = GiphyAPI::Sticker.trending()
90
+ # http://api.giphy.com/v1/stickers/trending?limit=20&rating=g&api_key=YOUR_API_KEY
91
+ stickers = GiphyAPI::Sticker.trending(limit: 20, rating: 'g')
92
+ #
93
+ # Random Sticker:
94
+ # http://api.giphy.com/v1/stickers/random?api_key=YOUR_API_KEY
95
+ sticker = GiphyAPI::Sticker.random()
96
+ # http://api.giphy.com/v1/stickers/random?tag=burito&rating=g&api_key=YOUR_API_KEY
97
+ sticker = GiphyAPI::Sticker.random(tag: 'burrito', rating: 'g')
98
+ #
99
+ # Translated Sticker:
100
+ # http://api.giphy.com/v1/stickers/translate?s=moo&api_key=YOUR_API_KEY
101
+ sticker = GiphyAPI::Sticker.translate('moo')
102
+ ```
103
+
104
+ ### Pagination
105
+
106
+ Following pagination fields will be set to all collections if Giphy API returns a `pagination` object:
107
+
108
+ ```ruby
109
+ gifs.total_count # Total number of items available.
110
+ gifs.offset # Position in pagination.
111
+ gifs.count # Total number of items returned.
112
+ ```
113
+
114
+ These attributes will be set to `nil` if nothing was returned.
115
+
116
+ ## Development and Contributing
117
+
118
+ 1. Create a fork of the original repo.
119
+ 1. After checking out your fork repo, run `bundle setup` to install dependencies.
120
+ 1. Create a new branch and add your changes there.
121
+ 1. Commit your changes and create a pull request.
122
+
123
+ **Note:** run `rake test` to run the tests. You can also run `bundle console` for an interactive prompt that will allow you to experiment. <br />
124
+ Bug reports and pull requests are welcome on GitHub at https://github.com/faragorn/giphy_api_ruby.
125
+
126
+ ## License
127
+
128
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
129
+
130
+ ## TO Do List
131
+
132
+ * More tests for Base class
133
+ * Add rubocop for syntax checking
134
+ * Create a CLI
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "giphy_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'giphy_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "giphy_api_ruby"
8
+ spec.version = GiphyApi::VERSION
9
+ spec.authors = ["Farrukh Abdulkadyrov"]
10
+ spec.email = ["farrukhabdul@gmail.com"]
11
+
12
+ spec.summary = 'Minimalistic Ruby Wrapper for Giphy API'
13
+ spec.homepage = "https://gihtub.com/faragorn/giphy_api_ruby"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = '~> 2.0'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.12"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "minitest", "~> 5.0"
23
+ spec.add_development_dependency "fakeweb", "~> 1.3"
24
+ spec.add_development_dependency "byebug", "~> 9.0"
25
+ spec.add_development_dependency "codecov", "~> 0.1"
26
+ end
@@ -0,0 +1,29 @@
1
+ module GiphyAPI
2
+ class Collection
3
+ include Enumerable
4
+
5
+ PAGINATION_ATTRIBUTES = [:total_count, :offset].freeze
6
+
7
+ attr_accessor :elements, *PAGINATION_ATTRIBUTES
8
+
9
+ def initialize(elements)
10
+ @elements = elements
11
+ end
12
+
13
+ def each &block
14
+ elements.each(&block)
15
+ end
16
+
17
+ def count
18
+ elements.length
19
+ end
20
+
21
+ def collect!
22
+ return elements unless block_given?
23
+ set = []
24
+ each { |e| set << yield(e) }
25
+ @elements = set
26
+ self
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ module GiphyAPI
2
+ class Configuration
3
+ attr_accessor :api_key, :api_prefix, :json_parser
4
+
5
+ def initialize
6
+ self.api_key = ENV['GIPHY_API_KEY']
7
+ self.api_prefix = 'v1'
8
+ self.json_parser = ::JSON
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,63 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
4
+ module GiphyAPI
5
+ class Connection
6
+ SITE = URI.parse('http://api.giphy.com').freeze
7
+
8
+ def initialize
9
+ @http = Net::HTTP.new SITE.host, SITE.port
10
+ end
11
+
12
+ def get path, **options
13
+ request(:get, complete_path_with_query(path, options))
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :http
19
+
20
+ def request method, path, *arguments
21
+ result = http.send method, path, *arguments
22
+ handle_response(result)
23
+ end
24
+
25
+ def handle_response response
26
+ case response.code.to_i
27
+ when 200
28
+ response
29
+ when 400
30
+ raise BadRequest.new(response)
31
+ when 401
32
+ raise UnauthorizedAccess.new(response)
33
+ when 403
34
+ raise ForbiddenAccess.new(response)
35
+ when 404
36
+ raise NotFound.new(response)
37
+ when 429
38
+ raise TooManyRequests.new(response)
39
+ when 500..600
40
+ raise ServerError.new(response)
41
+ else
42
+ raise ConnectionError.new(response)
43
+ end
44
+ end
45
+
46
+ def configuration
47
+ GiphyAPI.configuration
48
+ end
49
+
50
+ def complete_options **options
51
+ options.merge(api_key: configuration.api_key)
52
+ end
53
+
54
+ def complete_path path
55
+ "/#{configuration.api_prefix}#{path}"
56
+ end
57
+
58
+ def complete_path_with_query path, **query_options
59
+ encoded_options = URI.encode_www_form complete_options(query_options)
60
+ "#{complete_path(path)}?#{encoded_options}"
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,28 @@
1
+ module GiphyAPI
2
+ class ConnectionError < StandardError
3
+ attr_reader :response
4
+ def initialize response, message = nil
5
+ super(message)
6
+ @response = response
7
+ end
8
+
9
+ def to_s
10
+ msg = 'Failed.'
11
+ msg << " Response code = #{response.code}." if response.respond_to?(:code)
12
+ msg << " Reason = #{response.message}" if response.respond_to?(:message)
13
+ msg
14
+ end
15
+ end
16
+
17
+ class BadRequest < ConnectionError; end
18
+
19
+ class UnauthorizedAccess < ConnectionError; end
20
+
21
+ class ForbiddenAccess < ConnectionError; end
22
+
23
+ class NotFound < ConnectionError; end
24
+
25
+ class TooManyRequests < ConnectionError; end
26
+
27
+ class ServerError < ConnectionError; end
28
+ end
@@ -0,0 +1,31 @@
1
+ module GiphyAPI
2
+ module RawDataAttributes
3
+
4
+ def assign_raw_data raw_data
5
+ self.raw_data = raw_data
6
+ end
7
+
8
+ def self.included mod
9
+ mod.send(:attr_accessor, :raw_data)
10
+ mod.extend ClassMethods
11
+ end
12
+
13
+ module ClassMethods
14
+ def raw_data_attr_accessor *attrs
15
+ @accessible_raw_attributes = accessible_raw_attributes + attrs.map!(&:to_s)
16
+ attrs.each do |attr|
17
+ define_method attr do
18
+ raw_data[attr]
19
+ end
20
+ define_method "#{attr}=" do |value|
21
+ raw_data[attr] = value
22
+ end
23
+ end
24
+ end
25
+
26
+ def accessible_raw_attributes
27
+ @accessible_raw_attributes ||= []
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ require 'giphy_api/resources/base'
2
+ Dir.glob("#{File.dirname(__FILE__)}/resources/*").each { |file| require(file) }
@@ -0,0 +1,53 @@
1
+ module GiphyAPI
2
+ class Base
3
+ include RawDataAttributes
4
+ class << self
5
+ def find_with_scope path, scope, **options
6
+ response = format.load get(path, options).body
7
+ case scope
8
+ when :all
9
+ instantiate_collection(response['data'] || [], response['pagination'] || {})
10
+ when :one
11
+ instantiate_record(response['data'] || {})
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def get path, **options
18
+ connection.get(path_with_prefix(path), options)
19
+ end
20
+
21
+ def instantiate_collection collection, pagination
22
+ Collection.new(collection).tap do |c|
23
+ c.total_count = pagination['total_count']
24
+ c.offset = pagination['offset']
25
+ end.collect! { |record| instantiate_record(record) }
26
+ end
27
+
28
+ def instantiate_record record
29
+ new(record)
30
+ end
31
+
32
+ def format
33
+ GiphyAPI.configuration.json_parser
34
+ end
35
+
36
+ def path_prefix
37
+ "/#{self.name.split('::').last.downcase}s"
38
+ end
39
+
40
+ def path_with_prefix path
41
+ "#{path_prefix}#{path}"
42
+ end
43
+
44
+ def connection
45
+ GiphyAPI::Connection.new
46
+ end
47
+ end
48
+
49
+ def initialize attributes = {}
50
+ assign_raw_data(attributes)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,41 @@
1
+ module GiphyAPI
2
+ class Gif < Base
3
+ raw_data_attr_accessor :type, :id, :slug, :url, :bitly_url, :embed_url, :source, :rating, :content_url, :username, :tags, :featured_tags,
4
+ :source_tld, :source_post_url, :update_datetime, :create_datetime, :import_datetime, :trending_datetime
5
+ attr_accessor :images, :user
6
+
7
+ class << self
8
+ def search keyword, **options
9
+ find_with_scope('/search', :all, options.merge(q: keyword))
10
+ end
11
+
12
+ def trending **options
13
+ find_with_scope('/trending', :all, options)
14
+ end
15
+
16
+ def translate term, **options
17
+ find_with_scope('/translate', :one, options.merge(s: term))
18
+ end
19
+
20
+ def random **options
21
+ find_with_scope('/random', :one, options)
22
+ end
23
+
24
+ def find id, **options
25
+ find_with_scope("/#{id}", :one, options)
26
+ end
27
+
28
+ def find_by_ids *ids, **options
29
+ find_with_scope('', :all, options.merge(ids: ids.join(',')))
30
+ end
31
+ end
32
+
33
+ def initialize attributes = {}
34
+ super(attributes)
35
+ self.user = User.new raw_data['user'] if raw_data['user']
36
+ self.images = (raw_data['images'] || Image.extract_images(raw_data)).collect do |type, image|
37
+ [type, Image.new(image)]
38
+ end.to_h
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ module GiphyAPI
2
+ class Image
3
+ include RawDataAttributes
4
+
5
+ IMAGE_TYPES = %w(original fixed_height fixed_height_still fixed_height_downsampled fixed_width
6
+ fixed_width_still fixed_width_downsampled fixed_height_small fixed_height_small_still
7
+ fixed_width_small fixed_width_small_still downsized downsized_still downsized_large
8
+ downsized_medium downsized_small original original_still looping preview preview_gif
9
+ ).freeze
10
+
11
+ raw_data_attr_accessor :url, :width, :height, :size, :frames, :mp4, :mp4_size, :webp, :webp_size
12
+
13
+ def self.extract_images payload
14
+ image_type_mapping = { "image" => "original" }
15
+
16
+ attr_regexp = "(#{accessible_raw_attributes.join('|')})"
17
+ type_regexp = "(#{IMAGE_TYPES.join('|')})"
18
+
19
+ image_attribute_regexp = Regexp.new("^#{type_regexp}_#{attr_regexp}$")
20
+ images = {}
21
+ payload.each do |key, value|
22
+ next unless image_attribute_regexp.match(key)
23
+ image_type = key.sub Regexp.new("_#{attr_regexp}$"), ''
24
+ image_attribute = key.sub Regexp.new("^#{type_regexp}_"), ''
25
+
26
+ type_mapping_value = image_type_mapping[image_type] || image_type
27
+
28
+ images[type_mapping_value] ||= {}
29
+ images[type_mapping_value][image_attribute] = value
30
+ end
31
+ images
32
+ end
33
+
34
+ def initialize(attributes = {})
35
+ assign_raw_data(attributes)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,33 @@
1
+ module GiphyAPI
2
+ class Sticker < Base
3
+ raw_data_attr_accessor :type, :id, :slug, :url, :bitly_url, :embed_url, :source, :rating, :content_url, :username, :tags, :featured_tags,
4
+ :source_tld, :source_post_url, :update_datetime, :create_datetime, :import_datetime, :trending_datetime
5
+ attr_accessor :images, :user
6
+
7
+ class << self
8
+ def search keyword, **options
9
+ find_with_scope('/search', :all, options.merge(q: keyword))
10
+ end
11
+
12
+ def trending **options
13
+ find_with_scope('/trending', :all, options)
14
+ end
15
+
16
+ def translate term, **options
17
+ find_with_scope('/translate', :one, options.merge(s: term))
18
+ end
19
+
20
+ def random **options
21
+ find_with_scope('/random', :one, options)
22
+ end
23
+ end
24
+
25
+ def initialize attributes = {}
26
+ super(attributes)
27
+ self.user = User.new raw_data['user'] if raw_data['user']
28
+ self.images = (raw_data['images'] || Image.extract_images(raw_data)).collect do |type, image|
29
+ [type, Image.new(image)]
30
+ end.to_h
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ module GiphyAPI
2
+ class User
3
+ include RawDataAttributes
4
+
5
+ raw_data_attr_accessor :username, :display_name, :twitter, :avatar_url, :banner_url, :profile_url
6
+
7
+ def initialize attributes = {}
8
+ assign_raw_data(attributes)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module GiphyApi
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ require 'giphy_api/version'
2
+ require 'json'
3
+ require 'giphy_api/configuration'
4
+ require 'giphy_api/exceptions'
5
+ require 'giphy_api/connection'
6
+ require 'giphy_api/collection'
7
+ require 'giphy_api/raw_data_attributes'
8
+ require 'giphy_api/resources'
9
+
10
+ module GiphyAPI
11
+ class << self
12
+ attr_writer :configuration
13
+
14
+ def configuration
15
+ @configuration ||= Configuration.new
16
+ end
17
+ def configure
18
+ yield configuration
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: giphy_api_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Farrukh Abdulkadyrov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fakeweb
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '9.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '9.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
97
+ description:
98
+ email:
99
+ - farrukhabdul@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".codecov.yml"
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - giphy_api_ruby.gemspec
114
+ - lib/giphy_api/collection.rb
115
+ - lib/giphy_api/configuration.rb
116
+ - lib/giphy_api/connection.rb
117
+ - lib/giphy_api/exceptions.rb
118
+ - lib/giphy_api/raw_data_attributes.rb
119
+ - lib/giphy_api/resources.rb
120
+ - lib/giphy_api/resources/base.rb
121
+ - lib/giphy_api/resources/gif.rb
122
+ - lib/giphy_api/resources/image.rb
123
+ - lib/giphy_api/resources/sticker.rb
124
+ - lib/giphy_api/resources/user.rb
125
+ - lib/giphy_api/version.rb
126
+ - lib/giphy_api_ruby.rb
127
+ homepage: https://gihtub.com/faragorn/giphy_api_ruby
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '2.0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.5.1
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Minimalistic Ruby Wrapper for Giphy API
151
+ test_files: []