le_meme 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +7 -1
- data/bin/meme +6 -1
- data/le_meme.gemspec +11 -10
- data/lib/le_meme/version.rb +1 -1
- data/lib/le_meme.rb +6 -4
- data/spec/le_meme_spec.rb +60 -0
- data/spec/spec_helper.rb +6 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66f7f3d32fc6267a4bedde418374d413bd9638e0
|
4
|
+
data.tar.gz: 8a8cbcd49e5dc42a5dbb41477149fa4364145c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b022383b8dc44d85a43886520ae3da88e50e64fc8bd6f0f27effed9d10f3d5a051c4fa67974ffec1f1eb029a165be9bcfb4a324a983aedeb433c3b50ecfb367
|
7
|
+
data.tar.gz: dca9ac81f463c1e880ecd5f685d7e1447f8b045e4637886fb063532906d3afba401051b0685beb7fed98a780b9b023ba7c58269164442ceda1ab778fbaf90529
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/meme
CHANGED
@@ -19,6 +19,7 @@ HEREDOC
|
|
19
19
|
on 'm', 'meme=', 'meme template you want to use, see --templates'
|
20
20
|
on 'p', 'path=', 'path to an image to use for the meme'
|
21
21
|
on 'w', 'watermark=', 'text to watermark the image'
|
22
|
+
on 'o', 'outpath=', 'path to save the final meme to'
|
22
23
|
|
23
24
|
on 'templates', 'list all the meme templates' do
|
24
25
|
puts memegen.memes.keys.join("\n")
|
@@ -34,5 +35,9 @@ end
|
|
34
35
|
top = opts[:top] || ARGV[0]
|
35
36
|
bottom = opts[:bottom] || ARGV[1]
|
36
37
|
|
37
|
-
|
38
|
+
if opts[:path]
|
39
|
+
$stdout.puts memegen.meme(path: opts[:path], top: top, bottom: bottom, watermark: opts[:watermark], outpath: opts[:outpath])
|
40
|
+
else
|
41
|
+
$stdout.puts memegen.fast_meme(name: opts[:meme], top: top, bottom: bottom, watermark: opts[:watermark], outpath: opts[:outpath])
|
42
|
+
end
|
38
43
|
exit
|
data/le_meme.gemspec
CHANGED
@@ -4,23 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'le_meme/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'le_meme'
|
8
8
|
spec.version = LeMeme::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Jeff Sandberg']
|
10
|
+
spec.email = ['paradox460@gmail.com']
|
11
|
+
spec.summary = 'Dank memes, in gem form'
|
12
|
+
spec.description = 'A gem that generates memes. Can be used as a library or command-line executable.'
|
13
|
+
spec.homepage = 'http://github.com/paradox460/le_meme'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
24
25
|
|
25
26
|
spec.add_runtime_dependency 'rmagick', '~> 2.13'
|
26
27
|
spec.add_runtime_dependency 'word_wrapper', '~> 0.5.0'
|
data/lib/le_meme/version.rb
CHANGED
data/lib/le_meme.rb
CHANGED
@@ -28,8 +28,9 @@ class LeMeme
|
|
28
28
|
# @param top [String] The text you want to appear on the top of the meme.
|
29
29
|
# @param bottom [String] The text you want to appear on the bottom of the meme.
|
30
30
|
# @param watermark [String] The watermark text. If nil it is omitted
|
31
|
+
# @param outpath [String] Where do you want to put the generated meme. Defaults to /tmp/
|
31
32
|
# @return [String] Path to the generated meme
|
32
|
-
def generate(path:, top: nil, bottom: nil, watermark: nil)
|
33
|
+
def generate(path:, top: nil, bottom: nil, watermark: nil, outpath: nil)
|
33
34
|
top = (top || '').upcase
|
34
35
|
bottom = (bottom || '').upcase
|
35
36
|
|
@@ -54,7 +55,7 @@ class LeMeme
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
|
-
output_path = "/tmp/meme-#{Time.now.to_i}#{path.extname}"
|
58
|
+
output_path = outpath || "/tmp/meme-#{Time.now.to_i}#{path.extname}"
|
58
59
|
canvas.write(output_path)
|
59
60
|
output_path
|
60
61
|
end
|
@@ -67,8 +68,9 @@ class LeMeme
|
|
67
68
|
# @param top [String] The text you want to appear on the top of the meme.
|
68
69
|
# @param bottom [String] The text you want to appear on the bottom of the meme.
|
69
70
|
# @param watermark [String] The watermark text. If nil it is omitted
|
71
|
+
# @param outpath [String] Where do you want to put the generated meme. Defaults to /tmp/
|
70
72
|
# @return [String] Path to the generated meme
|
71
|
-
def fast_meme(name: nil, top: nil, bottom: nil, watermark: nil)
|
73
|
+
def fast_meme(name: nil, top: nil, bottom: nil, watermark: nil, outpath: nil)
|
72
74
|
if name.nil?
|
73
75
|
path = @memes[@memes.keys.sample]
|
74
76
|
elsif @memes[name].nil?
|
@@ -76,7 +78,7 @@ class LeMeme
|
|
76
78
|
else
|
77
79
|
path = @memes[name]
|
78
80
|
end
|
79
|
-
generate(path: path, top: top, bottom: bottom, watermark: watermark)
|
81
|
+
generate(path: path, top: top, bottom: bottom, watermark: watermark, outpath: outpath)
|
80
82
|
end
|
81
83
|
alias_method :m, :fast_meme
|
82
84
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LeMeme do
|
4
|
+
let(:meme) { LeMeme.new }
|
5
|
+
|
6
|
+
describe '#generate' do
|
7
|
+
let(:image) { File.join(File.dirname(File.expand_path(__FILE__)), '../memes/maymay.jpg') }
|
8
|
+
context 'without an image path' do
|
9
|
+
it 'should raise ArgumentError with "missing keyword: path"' do
|
10
|
+
expect { meme.generate }.to raise_error(ArgumentError, 'missing keyword: path')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'with an image path' do
|
14
|
+
x = ['text', nil] * 3
|
15
|
+
x.permutation(3).to_a.uniq.each do |top, bottom, watermark|
|
16
|
+
it "should generate a meme with top: '#{top}', bottom: '#{bottom}', and watermark: '#{watermark}'" do
|
17
|
+
expect(meme.generate(path: image, top: top, bottom: bottom, watermark: watermark)).to match(%r{/tmp/meme-\d+.jpg})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
context 'with an outpath' do
|
22
|
+
it 'should generate a meme at the specified outpath' do
|
23
|
+
expect_any_instance_of(Magick::ImageList).to receive(:write).and_return('test.jpg')
|
24
|
+
expect(meme.generate(path: image, top: 'top', bottom: 'bottom', outpath: 'test.jpg')).to eq('test.jpg')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#meme' do
|
30
|
+
it 'should be an alias of #generate' do
|
31
|
+
expect(meme.method(:meme)).to eq(meme.method(:generate))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#fast_meme' do
|
36
|
+
let(:template) { 'maymay' }
|
37
|
+
it 'should pass its params to generate_meme' do
|
38
|
+
expect(meme).to receive(:generate) do |args|
|
39
|
+
expect(args[:path]).to eq(Pathname.new('/Users/jeffsandberg/Developer/le_meme/memes/maymay.jpg'))
|
40
|
+
expect(args[:top]).to eq('top text')
|
41
|
+
expect(args[:bottom]).to eq('bottom text')
|
42
|
+
expect(args[:watermark]).to eq('watermark')
|
43
|
+
expect(args[:outpath]).to eq('outpath')
|
44
|
+
end
|
45
|
+
meme.fast_meme(name: template, top: 'top text', bottom: 'bottom text', watermark: 'watermark', outpath: 'outpath')
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'without a specified template' do
|
49
|
+
it 'should generate a meme' do
|
50
|
+
expect(meme.fast_meme).to match(%r{/tmp/meme-\d+.jpg})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#m' do
|
56
|
+
it 'should be an alias of #fast_meme' do
|
57
|
+
expect(meme.method(:m)).to eq(meme.method(:fast_meme))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: le_meme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Sandberg
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rmagick
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,6 +209,8 @@ files:
|
|
195
209
|
- memes/yee.jpg
|
196
210
|
- memes/yuno.jpg
|
197
211
|
- open
|
212
|
+
- spec/le_meme_spec.rb
|
213
|
+
- spec/spec_helper.rb
|
198
214
|
homepage: http://github.com/paradox460/le_meme
|
199
215
|
licenses:
|
200
216
|
- MIT
|
@@ -219,5 +235,6 @@ rubygems_version: 2.4.5
|
|
219
235
|
signing_key:
|
220
236
|
specification_version: 4
|
221
237
|
summary: Dank memes, in gem form
|
222
|
-
test_files:
|
223
|
-
|
238
|
+
test_files:
|
239
|
+
- spec/le_meme_spec.rb
|
240
|
+
- spec/spec_helper.rb
|