mememe 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +64 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/fry.jpg +0 -0
- data/bin/joe.jpg +0 -0
- data/bin/mm +9 -0
- data/lib/mememe.rb +40 -0
- data/lib/mememe/fonts/impact.ttf +0 -0
- data/lib/mememe/images/clarity.jpg +0 -0
- data/lib/mememe/images/fry.jpg +0 -0
- data/lib/mememe/images/fwp.png +0 -0
- data/lib/mememe/images/joe.jpg +0 -0
- data/lib/mememe/images/yes.jpg +0 -0
- data/lib/mememe/meme.rb +80 -0
- data/lib/mememe/memes/fry_meme.rb +21 -0
- data/lib/mememe/memes/joe_meme.rb +13 -0
- data/mememe.gemspec +101 -0
- data/spec/.DS_Store +0 -0
- data/spec/fixtures/joe.jpg +0 -0
- data/spec/fry_meme_spec.rb +31 -0
- data/spec/joe_meme_spec.rb +21 -0
- data/spec/meme_spec.rb +61 -0
- data/spec/mememe_spec.rb +36 -0
- data/spec/spec_helper.rb +21 -0
- metadata +260 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@mememe --create
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "bundler"
|
10
|
+
gem "growl"
|
11
|
+
gem "guard-rspec"
|
12
|
+
gem "jeweler"
|
13
|
+
gem "mini_magick"
|
14
|
+
gem "pry"
|
15
|
+
gem "pry-doc"
|
16
|
+
gem "pry-nav"
|
17
|
+
gem "rb-fsevent"
|
18
|
+
gem "rdoc"
|
19
|
+
gem "rspec"
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
coderay (1.0.8)
|
5
|
+
diff-lcs (1.1.3)
|
6
|
+
git (1.2.5)
|
7
|
+
growl (1.0.3)
|
8
|
+
guard (1.4.0)
|
9
|
+
listen (>= 0.4.2)
|
10
|
+
thor (>= 0.14.6)
|
11
|
+
guard-rspec (2.1.0)
|
12
|
+
guard (>= 1.1)
|
13
|
+
rspec (~> 2.11)
|
14
|
+
jeweler (1.8.4)
|
15
|
+
bundler (~> 1.0)
|
16
|
+
git (>= 1.2.5)
|
17
|
+
rake
|
18
|
+
rdoc
|
19
|
+
json (1.7.5)
|
20
|
+
listen (0.5.3)
|
21
|
+
method_source (0.8.1)
|
22
|
+
mini_magick (3.4)
|
23
|
+
subexec (~> 0.2.1)
|
24
|
+
pry (0.9.10)
|
25
|
+
coderay (~> 1.0.5)
|
26
|
+
method_source (~> 0.8)
|
27
|
+
slop (~> 3.3.1)
|
28
|
+
pry-doc (0.4.4)
|
29
|
+
pry (>= 0.9.9.6)
|
30
|
+
yard (~> 0.8.1)
|
31
|
+
pry-nav (0.2.2)
|
32
|
+
pry (~> 0.9.10)
|
33
|
+
rake (0.9.2.2)
|
34
|
+
rb-fsevent (0.9.2)
|
35
|
+
rdoc (3.12)
|
36
|
+
json (~> 1.4)
|
37
|
+
rspec (2.11.0)
|
38
|
+
rspec-core (~> 2.11.0)
|
39
|
+
rspec-expectations (~> 2.11.0)
|
40
|
+
rspec-mocks (~> 2.11.0)
|
41
|
+
rspec-core (2.11.1)
|
42
|
+
rspec-expectations (2.11.3)
|
43
|
+
diff-lcs (~> 1.1.3)
|
44
|
+
rspec-mocks (2.11.3)
|
45
|
+
slop (3.3.3)
|
46
|
+
subexec (0.2.2)
|
47
|
+
thor (0.16.0)
|
48
|
+
yard (0.8.3)
|
49
|
+
|
50
|
+
PLATFORMS
|
51
|
+
ruby
|
52
|
+
|
53
|
+
DEPENDENCIES
|
54
|
+
bundler
|
55
|
+
growl
|
56
|
+
guard-rspec
|
57
|
+
jeweler
|
58
|
+
mini_magick
|
59
|
+
pry
|
60
|
+
pry-doc
|
61
|
+
pry-nav
|
62
|
+
rb-fsevent
|
63
|
+
rdoc
|
64
|
+
rspec
|
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Dayton Nolan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= mememe
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to mememe
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Dayton Nolan. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "mememe"
|
18
|
+
gem.homepage = "http://github.com/daytonn/mememe"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{MemeMe is a command line meme generator loosely based on quickmeme.com}
|
21
|
+
gem.description = %Q{MemeMe is a command line meme generator loosely based on quickmeme.com}
|
22
|
+
gem.email = "dnolan@gmail.com"
|
23
|
+
gem.authors = ["Dayton Nolan"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "mememe #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/fry.jpg
ADDED
Binary file
|
data/bin/joe.jpg
ADDED
Binary file
|
data/bin/mm
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
3
|
+
require 'mememe'
|
4
|
+
MemeMe::require_memes
|
5
|
+
|
6
|
+
meme = MemeMe::installed_memes[ARGV[0].to_sym].new
|
7
|
+
meme.top_phrase = ARGV[1] if ARGV[1]
|
8
|
+
meme.bottom_phrase = ARGV[2] if ARGV[2]
|
9
|
+
meme.generate Dir.pwd
|
data/lib/mememe.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
2
|
+
|
3
|
+
module MemeMe
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def images
|
8
|
+
images = {}
|
9
|
+
Dir.glob("#{File.join(File.expand_path(File.dirname(__FILE__)), 'mememe', 'images')}/*").each { |i| images[File.basename(i).gsub(/\.\w+$/, '').to_sym] = i }
|
10
|
+
images
|
11
|
+
end
|
12
|
+
|
13
|
+
def fonts
|
14
|
+
fonts = {}
|
15
|
+
Dir.glob("#{File.join(File.join(File.dirname(__FILE__)), 'mememe', 'fonts')}/*").each { |f| fonts[File.basename(f).gsub(/\.\w+$/, '').to_sym] = f }
|
16
|
+
fonts
|
17
|
+
end
|
18
|
+
|
19
|
+
def memes
|
20
|
+
memes = {}
|
21
|
+
Dir.glob("#{File.join(File.join(File.dirname(__FILE__)), 'mememe', 'memes')}/*").each { |f| memes[File.basename(f).gsub(/\.\w+$/, '').to_sym] = f }
|
22
|
+
memes
|
23
|
+
end
|
24
|
+
|
25
|
+
def install(name, constructor)
|
26
|
+
@installed_memes ||= {}
|
27
|
+
@installed_memes[name] = constructor
|
28
|
+
end
|
29
|
+
|
30
|
+
def installed_memes
|
31
|
+
@installed_memes ||= {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def require_memes
|
35
|
+
memes.each_pair { |n, m| require m }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/mememe/meme.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'mini_magick'
|
2
|
+
|
3
|
+
module MemeMe
|
4
|
+
module Meme
|
5
|
+
|
6
|
+
attr_accessor :image
|
7
|
+
|
8
|
+
def name
|
9
|
+
@name || "meme"
|
10
|
+
end
|
11
|
+
|
12
|
+
def top_phrase
|
13
|
+
@top_phrase || ""
|
14
|
+
end
|
15
|
+
|
16
|
+
def top_phrase=(phrase)
|
17
|
+
@top_phrase = phrase
|
18
|
+
end
|
19
|
+
|
20
|
+
def bottom_phrase
|
21
|
+
@bottom_phrase || ""
|
22
|
+
end
|
23
|
+
|
24
|
+
def bottom_phrase=(phrase)
|
25
|
+
@bottom_phrase = phrase
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate(path)
|
29
|
+
raise ArgumentError, "MemeMe::Meme.generate requires a valid image path" unless @image && File.exists?(image)
|
30
|
+
img = MiniMagick::Image.open(image)
|
31
|
+
write_top_phrase img
|
32
|
+
write_bottom_phrase img
|
33
|
+
img.write(File.join(path, "#{name}#{File.extname(image)}"))
|
34
|
+
end
|
35
|
+
|
36
|
+
def write_top_phrase(img)
|
37
|
+
img.combine_options do |c|
|
38
|
+
meme_text top_phrase, c
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def write_bottom_phrase(img)
|
43
|
+
img.combine_options do |c|
|
44
|
+
meme_text bottom_phrase, c, { position: 'South' }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def meme_text(text, c, config = {})
|
49
|
+
settings = {
|
50
|
+
font: MemeMe.fonts[:impact],
|
51
|
+
position: 'North',
|
52
|
+
pointsize: 50,
|
53
|
+
stroke_color: '#000',
|
54
|
+
stroke_width: 2,
|
55
|
+
color: '#FFF'
|
56
|
+
}.merge! config
|
57
|
+
|
58
|
+
settings[:pointsize] = calculate_pointsize text, settings[:pointsize]
|
59
|
+
|
60
|
+
c.gravity settings[:position]
|
61
|
+
c.font settings[:font]
|
62
|
+
c.pointsize settings[:pointsize]
|
63
|
+
c.stroke settings[:stroke_color]
|
64
|
+
c.strokewidth settings[:stroke_width].to_s
|
65
|
+
c.fill settings[:color]
|
66
|
+
c.draw "text 0,0 '#{text.upcase}'"
|
67
|
+
end
|
68
|
+
|
69
|
+
def calculate_pointsize text, pointsize
|
70
|
+
if text.size > 20
|
71
|
+
pointsize = pointsize - (text.size - 20) * 1.25
|
72
|
+
pointsize = 28 if pointsize < 28
|
73
|
+
pointsize.to_s
|
74
|
+
else
|
75
|
+
pointsize.to_s
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'mememe/meme'
|
2
|
+
|
3
|
+
class FryMeme
|
4
|
+
include MemeMe::Meme
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@name = 'fry'
|
8
|
+
@image = MemeMe::images[:fry]
|
9
|
+
end
|
10
|
+
|
11
|
+
def top_phrase
|
12
|
+
"not sure if #{@top_phrase}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def bottom_phrase
|
16
|
+
"or #{@bottom_phrase}"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
MemeMe::install(:fry, FryMeme)
|
data/mememe.gemspec
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "mememe"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dayton Nolan"]
|
12
|
+
s.date = "2012-10-23"
|
13
|
+
s.description = "MemeMe is a command line meme generator loosely based on quickmeme.com"
|
14
|
+
s.email = "dnolan@gmail.com"
|
15
|
+
s.executables = ["fry.jpg", "joe.jpg", "mm"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
".rvmrc",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"Guardfile",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.rdoc",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"bin/fry.jpg",
|
32
|
+
"bin/joe.jpg",
|
33
|
+
"bin/mm",
|
34
|
+
"lib/mememe.rb",
|
35
|
+
"lib/mememe/fonts/impact.ttf",
|
36
|
+
"lib/mememe/images/clarity.jpg",
|
37
|
+
"lib/mememe/images/fry.jpg",
|
38
|
+
"lib/mememe/images/fwp.png",
|
39
|
+
"lib/mememe/images/joe.jpg",
|
40
|
+
"lib/mememe/images/yes.jpg",
|
41
|
+
"lib/mememe/meme.rb",
|
42
|
+
"lib/mememe/memes/fry_meme.rb",
|
43
|
+
"lib/mememe/memes/joe_meme.rb",
|
44
|
+
"mememe.gemspec",
|
45
|
+
"spec/.DS_Store",
|
46
|
+
"spec/fixtures/joe.jpg",
|
47
|
+
"spec/fry_meme_spec.rb",
|
48
|
+
"spec/joe_meme_spec.rb",
|
49
|
+
"spec/meme_spec.rb",
|
50
|
+
"spec/mememe_spec.rb",
|
51
|
+
"spec/spec_helper.rb"
|
52
|
+
]
|
53
|
+
s.homepage = "http://github.com/daytonn/mememe"
|
54
|
+
s.licenses = ["MIT"]
|
55
|
+
s.require_paths = ["lib"]
|
56
|
+
s.rubygems_version = "1.8.24"
|
57
|
+
s.summary = "MemeMe is a command line meme generator loosely based on quickmeme.com"
|
58
|
+
|
59
|
+
if s.respond_to? :specification_version then
|
60
|
+
s.specification_version = 3
|
61
|
+
|
62
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
63
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<growl>, [">= 0"])
|
65
|
+
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
67
|
+
s.add_development_dependency(%q<mini_magick>, [">= 0"])
|
68
|
+
s.add_development_dependency(%q<pry>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<pry-doc>, [">= 0"])
|
70
|
+
s.add_development_dependency(%q<pry-nav>, [">= 0"])
|
71
|
+
s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
|
72
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
73
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
76
|
+
s.add_dependency(%q<growl>, [">= 0"])
|
77
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
78
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
79
|
+
s.add_dependency(%q<mini_magick>, [">= 0"])
|
80
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
81
|
+
s.add_dependency(%q<pry-doc>, [">= 0"])
|
82
|
+
s.add_dependency(%q<pry-nav>, [">= 0"])
|
83
|
+
s.add_dependency(%q<rb-fsevent>, [">= 0"])
|
84
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
85
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
86
|
+
end
|
87
|
+
else
|
88
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
89
|
+
s.add_dependency(%q<growl>, [">= 0"])
|
90
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
91
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
92
|
+
s.add_dependency(%q<mini_magick>, [">= 0"])
|
93
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
94
|
+
s.add_dependency(%q<pry-doc>, [">= 0"])
|
95
|
+
s.add_dependency(%q<pry-nav>, [">= 0"])
|
96
|
+
s.add_dependency(%q<rb-fsevent>, [">= 0"])
|
97
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
98
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
data/spec/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'mememe'
|
3
|
+
require 'mememe/memes/fry_meme'
|
4
|
+
|
5
|
+
describe FryMeme do
|
6
|
+
|
7
|
+
let(:meme) { FryMeme.new }
|
8
|
+
|
9
|
+
it "prepends not sure if to the begining of the top phrase" do
|
10
|
+
meme.top_phrase = "my code is good"
|
11
|
+
expect(meme.top_phrase).to eq "not sure if my code is good"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "prepends or to the begining of the bottom phrase" do
|
15
|
+
meme.bottom_phrase = "my code is bad"
|
16
|
+
expect(meme.bottom_phrase).to eq "or my code is bad"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "uses the fry.jpg image" do
|
20
|
+
expect(meme.image).to eq(MemeMe.images[:fry])
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has a name of 'fry'" do
|
24
|
+
FileUtils.rm_rf TMP_DIR if File.exists? TMP_DIR
|
25
|
+
FileUtils.mkdir TMP_DIR
|
26
|
+
meme.top_phrase = "my code is an unbearable mess word"
|
27
|
+
meme.generate TMP_DIR
|
28
|
+
expect(meme.name).to eq('fry')
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'mememe'
|
3
|
+
require 'mememe/memes/joe_meme'
|
4
|
+
|
5
|
+
describe JoeMeme do
|
6
|
+
|
7
|
+
let(:meme) { JoeMeme.new }
|
8
|
+
|
9
|
+
it "says 'Then I Spoke To Joe' at the bottom" do
|
10
|
+
expect(meme.bottom_phrase).to eq "then i spoke to joe"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "uses the joe.jpg image" do
|
14
|
+
expect(meme.image).to eq(MemeMe.images[:joe])
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has a name of 'joe'" do
|
18
|
+
expect(meme.name).to eq('joe')
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/spec/meme_spec.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require "mememe/meme"
|
3
|
+
|
4
|
+
class TestMeme
|
5
|
+
include MemeMe::Meme
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@image = File.join(FIXTURES_PATH, 'joe.jpg')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe MemeMe::Meme do
|
13
|
+
|
14
|
+
let(:meme) { TestMeme.new }
|
15
|
+
|
16
|
+
it "has a name" do
|
17
|
+
expect(meme.name).to eq "meme"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has an image" do
|
21
|
+
expect(meme).to respond_to(:image)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has a top_phrase" do
|
25
|
+
expect(meme.top_phrase).to eq ""
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets the top_phrase" do
|
29
|
+
meme.top_phrase = "Test"
|
30
|
+
expect(meme.top_phrase).to eq "Test"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "hase a bottom_phrase" do
|
34
|
+
expect(meme.bottom_phrase).to eq ""
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'generate' do
|
38
|
+
|
39
|
+
before :each do
|
40
|
+
FileUtils.mkdir TMP_DIR unless File.exists? TMP_DIR
|
41
|
+
end
|
42
|
+
|
43
|
+
after :each do
|
44
|
+
FileUtils.rm_rf TMP_DIR if File.exists? TMP_DIR
|
45
|
+
end
|
46
|
+
|
47
|
+
it "requires a valid image path" do
|
48
|
+
expect { meme.generate }.to raise_error ArgumentError
|
49
|
+
end
|
50
|
+
|
51
|
+
it "generates an image" do
|
52
|
+
meme.top_phrase = "I was proud of my tests"
|
53
|
+
meme.bottom_phrase = "Then I spoke to Joe"
|
54
|
+
meme.generate(TMP_DIR)
|
55
|
+
generated_image = File.join(TMP_DIR, 'meme.jpg')
|
56
|
+
expect(File.exists?(generated_image)).to be_true
|
57
|
+
expect(FileUtils.cmp(generated_image, meme.image)).to be_false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/spec/mememe_spec.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
describe MemeMe do
|
5
|
+
it "has a map of meme images" do
|
6
|
+
MemeMe.images.should == {
|
7
|
+
yes: File.join(IMAGES_PATH, "yes.jpg"),
|
8
|
+
fry: File.join(IMAGES_PATH, "fry.jpg"),
|
9
|
+
joe: File.join(IMAGES_PATH, "joe.jpg"),
|
10
|
+
clarity: File.join(IMAGES_PATH, "clarity.jpg"),
|
11
|
+
fwp: File.join(IMAGES_PATH, "fwp.png")
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has a map of fonts" do
|
16
|
+
expect(MemeMe.fonts).to eq({ impact: File.join(LIB_PATH, 'mememe', 'fonts', 'impact.ttf') })
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has a map of memes" do
|
20
|
+
expect(MemeMe.memes).to eq({
|
21
|
+
joe_meme: "/Volumes/Storage/Development/mememe/lib/mememe/memes/joe_meme.rb",
|
22
|
+
fry_meme: "/Volumes/Storage/Development/mememe/lib/mememe/memes/fry_meme.rb"
|
23
|
+
})
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can require all the installed memes" do
|
27
|
+
MemeMe::require_memes
|
28
|
+
expect(JoeMeme).not_to be_nil
|
29
|
+
expect(FryMeme).not_to be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has a map of all installed memes" do
|
33
|
+
MemeMe::require_memes
|
34
|
+
expect(MemeMe::installed_memes[:fry]).to eq(FryMeme)
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'mememe'
|
5
|
+
require 'pry'
|
6
|
+
require 'pry-nav'
|
7
|
+
require 'pry-doc'
|
8
|
+
|
9
|
+
# Requires supporting files with custom matchers and macros, etc,
|
10
|
+
# in ./support/ and its subdirectories.
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
LIB_PATH = File.expand_path('../lib', File.dirname(__FILE__))
|
18
|
+
IMAGES_PATH = File.join(LIB_PATH, 'mememe', 'images')
|
19
|
+
FIXTURES_PATH = File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures')
|
20
|
+
TMP_DIR = File.join(File.expand_path(File.dirname(__FILE__)), 'temp')
|
21
|
+
# :first_world_problem=>"/Volumes/Storage/Development/mememe/lib/mememe/images/first_world_problem.png", :not_sure=>"/Volumes/Storage/Development/mememe/lib/mememe/images/not_sure.jpg", :spoke_to_joe=>"/Volumes/Storage/Development/mememe/lib/mememe/images/spoke_to_joe.jpg", :success_kid=>"/Volumes/Storage/Development/mememe/lib/mememe/images/success_kid.jpg", :sudden_clarity=>"/Volumes/Storage/Development/mememe/lib/mememe/images/sudden_clarity.jpg"}
|
metadata
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mememe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dayton Nolan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: growl
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jeweler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mini_magick
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: pry
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pry-doc
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: pry-nav
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rb-fsevent
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: rdoc
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: rspec
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
description: MemeMe is a command line meme generator loosely based on quickmeme.com
|
191
|
+
email: dnolan@gmail.com
|
192
|
+
executables:
|
193
|
+
- fry.jpg
|
194
|
+
- joe.jpg
|
195
|
+
- mm
|
196
|
+
extensions: []
|
197
|
+
extra_rdoc_files:
|
198
|
+
- LICENSE.txt
|
199
|
+
- README.rdoc
|
200
|
+
files:
|
201
|
+
- .document
|
202
|
+
- .rspec
|
203
|
+
- .rvmrc
|
204
|
+
- Gemfile
|
205
|
+
- Gemfile.lock
|
206
|
+
- Guardfile
|
207
|
+
- LICENSE.txt
|
208
|
+
- README.rdoc
|
209
|
+
- Rakefile
|
210
|
+
- VERSION
|
211
|
+
- bin/fry.jpg
|
212
|
+
- bin/joe.jpg
|
213
|
+
- bin/mm
|
214
|
+
- lib/mememe.rb
|
215
|
+
- lib/mememe/fonts/impact.ttf
|
216
|
+
- lib/mememe/images/clarity.jpg
|
217
|
+
- lib/mememe/images/fry.jpg
|
218
|
+
- lib/mememe/images/fwp.png
|
219
|
+
- lib/mememe/images/joe.jpg
|
220
|
+
- lib/mememe/images/yes.jpg
|
221
|
+
- lib/mememe/meme.rb
|
222
|
+
- lib/mememe/memes/fry_meme.rb
|
223
|
+
- lib/mememe/memes/joe_meme.rb
|
224
|
+
- mememe.gemspec
|
225
|
+
- spec/.DS_Store
|
226
|
+
- spec/fixtures/joe.jpg
|
227
|
+
- spec/fry_meme_spec.rb
|
228
|
+
- spec/joe_meme_spec.rb
|
229
|
+
- spec/meme_spec.rb
|
230
|
+
- spec/mememe_spec.rb
|
231
|
+
- spec/spec_helper.rb
|
232
|
+
homepage: http://github.com/daytonn/mememe
|
233
|
+
licenses:
|
234
|
+
- MIT
|
235
|
+
post_install_message:
|
236
|
+
rdoc_options: []
|
237
|
+
require_paths:
|
238
|
+
- lib
|
239
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
240
|
+
none: false
|
241
|
+
requirements:
|
242
|
+
- - ! '>='
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
245
|
+
segments:
|
246
|
+
- 0
|
247
|
+
hash: 1017743430015989419
|
248
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ! '>='
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '0'
|
254
|
+
requirements: []
|
255
|
+
rubyforge_project:
|
256
|
+
rubygems_version: 1.8.24
|
257
|
+
signing_key:
|
258
|
+
specification_version: 3
|
259
|
+
summary: MemeMe is a command line meme generator loosely based on quickmeme.com
|
260
|
+
test_files: []
|