imgflip 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73c7bd99540f4c187e24605dfe90c668313dd2da
4
- data.tar.gz: 743c553cd7b40b9bbe05a68fb95d7f6a75b51655
3
+ metadata.gz: 60c1f5afc3664b10835adf3a47c61b233fafb448
4
+ data.tar.gz: 0d7de37aaca329a93be245078595bd060e1599f5
5
5
  SHA512:
6
- metadata.gz: d819db74682050055f32150d687c36a690868a5eda91ab3066bb7400069cabf593e94062094bb8ebefa3cf3d8b4aeaf86367b913ba14f661ee290e6b88f1bcc3
7
- data.tar.gz: 043e76808cee05fd12d89fef97a75e04c10f87139e91ad507b4f88285309d646612560f5a6c61af0fdd772bf5657af4bfa89263dd2d35fd690f54cc7b80e4d4a
6
+ metadata.gz: 47117c74f19e40f26fb61f9ec88a64f0183a37ea3c361b29d3c71092e9c6181046bbdbf7216024c0040cd5ef8cd4c77890777d906ddab29ad8bbc26c648d92ce
7
+ data.tar.gz: 71b3bc6d6cb1be1b4f8ea336c9d5f7327bd6fa5d8bb49b406874905e215f07754f907ecfe4e5e0776099cc9369d91563c48460f69d1848ca38beef04a76dbf16
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.2.0] - 2018-02-25
8
+ ### Added
9
+ - `get_memes` command to get list of most popular meme templates.
10
+ - Changelog to keep track of notable changes.
11
+ - Raise hopefully-useful errors when imgflip doesn't return success.
12
+
13
+ ### Changed
14
+ - Rename `generate_meme` to `caption_image` to match the API specification.
15
+
16
+ ## 0.1.0 - 2018-02-24
17
+ ### Added
18
+ - `generate_meme` command to generate meme via imgflip API.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- imgflip (0.1.0)
4
+ imgflip (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Imgflip
2
2
 
3
- Access the imgflip Meme Generator API to generate your own spicy memes.
3
+ Access the imgflip [Meme Generator API](https://api.imgflip.com/) to generate your own spicy memes.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,10 +18,22 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install imgflip
20
20
 
21
+ If you are going to make a lot of requests you will need to make your own imgflip account and set the environment variables `IMGFLIP_USERNAME` and `IMGFLIP_PASSWORD`.
22
+
21
23
  ## Usage
22
24
 
25
+ To return an array of the most popular memes with template_ids and name run:
26
+
27
+ ```ruby
28
+ Imgflip.get_memes
29
+ ```
30
+
31
+ For a list of `template_ids` you can also visit: https://api.imgflip.com/popular_meme_ids
32
+
33
+ To generate a meme and get the url run:
34
+
23
35
  ```ruby
24
- Imgflip.generate_meme(template_id, text0, text1)
36
+ Imgflip.caption_image(template_id, text0, text1)
25
37
  ```
26
38
 
27
39
  ## Development
@@ -1,13 +1,31 @@
1
1
  require 'imgflip/version'
2
2
  require 'net/http'
3
+ require 'json'
3
4
 
4
5
  module Imgflip
5
- IMGLFIP_USERNAME = ENV['imglfip_username'] || 'imgflip_hubot'
6
- IMGLFIP_PASSWORD = ENV['imglfip_password'] || 'imgflip_hubot'
6
+ IMGLFIP_USERNAME = ENV['IMGFLIP_USERNAME'] || 'imgflip_hubot'
7
+ IMGLFIP_PASSWORD = ENV['IMGLFIP_PASSWORD'] || 'imgflip_hubot'
7
8
 
8
- def self.generate_meme(template_id, text0, text1)
9
- Net::HTTP.post_form(URI.parse('https://api.imgflip.com/caption_image'),
10
- template_id: template_id, text0: text0, text1: text1,
11
- username: IMGLFIP_USERNAME, password: IMGLFIP_PASSWORD)
9
+ def self.get_memes
10
+ response = Net::HTTP.get(URI.parse('https://api.imgflip.com/get_memes'))
11
+ response_json = JSON.parse(response)
12
+
13
+ raise response_json['error_message'] unless response_json['success'] == true
14
+
15
+ response_json['data']['memes']
16
+ end
17
+
18
+ def self.caption_image(template_id, text0, text1)
19
+ response = Net::HTTP.post_form(URI.parse('https://api.imgflip.com/caption_image'),
20
+ template_id: template_id,
21
+ text0: text0,
22
+ text1: text1,
23
+ username: IMGLFIP_USERNAME,
24
+ password: IMGLFIP_PASSWORD)
25
+ response_json = JSON.parse(response.body)
26
+
27
+ raise response_json['error_message'] unless response_json['success'] == true
28
+
29
+ response_json['data']['url']
12
30
  end
13
31
  end
@@ -1,3 +1,3 @@
1
1
  module Imgflip
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgflip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ingo Albers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-24 00:00:00.000000000 Z
11
+ date: 2018-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,6 +62,7 @@ files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
64
  - ".travis.yml"
65
+ - CHANGELOG.md
65
66
  - CODE_OF_CONDUCT.md
66
67
  - Gemfile
67
68
  - Gemfile.lock