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 +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +1 -1
- data/README.md +14 -2
- data/lib/imgflip.rb +24 -6
- data/lib/imgflip/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60c1f5afc3664b10835adf3a47c61b233fafb448
|
|
4
|
+
data.tar.gz: 0d7de37aaca329a93be245078595bd060e1599f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47117c74f19e40f26fb61f9ec88a64f0183a37ea3c361b29d3c71092e9c6181046bbdbf7216024c0040cd5ef8cd4c77890777d906ddab29ad8bbc26c648d92ce
|
|
7
|
+
data.tar.gz: 71b3bc6d6cb1be1b4f8ea336c9d5f7327bd6fa5d8bb49b406874905e215f07754f907ecfe4e5e0776099cc9369d91563c48460f69d1848ca38beef04a76dbf16
|
data/CHANGELOG.md
ADDED
|
@@ -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.
|
data/Gemfile.lock
CHANGED
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.
|
|
36
|
+
Imgflip.caption_image(template_id, text0, text1)
|
|
25
37
|
```
|
|
26
38
|
|
|
27
39
|
## Development
|
data/lib/imgflip.rb
CHANGED
|
@@ -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['
|
|
6
|
-
IMGLFIP_PASSWORD = ENV['
|
|
6
|
+
IMGLFIP_USERNAME = ENV['IMGFLIP_USERNAME'] || 'imgflip_hubot'
|
|
7
|
+
IMGLFIP_PASSWORD = ENV['IMGLFIP_PASSWORD'] || 'imgflip_hubot'
|
|
7
8
|
|
|
8
|
-
def self.
|
|
9
|
-
Net::HTTP.
|
|
10
|
-
|
|
11
|
-
|
|
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
|
data/lib/imgflip/version.rb
CHANGED
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.
|
|
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-
|
|
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
|