meem 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in meem.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Johannes Gorset
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Meem
2
+
3
+ Meem is a command-line tool to create memes.
4
+
5
+ ### Usage
6
+
7
+ $ meem good-guy-greg --top "makes memes" --bottom "saves to disk"
8
+ /tmp/meme.jpg
9
+
10
+ $ meem good-guy-greg --top "makes memes" --bottom "uploads to imgur" | imgur
11
+ http://i.imgur.com/VBCRwlb.jpg
12
+
13
+ Meem comes with a bunch of templates, but you can add your own in `~/.meem`.
14
+
15
+ ### Installation
16
+
17
+ $ gem install meem
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/meem ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "meem"
4
+
5
+ Meem.run ARGV
data/fonts/impact.ttf ADDED
Binary file
@@ -0,0 +1,3 @@
1
+ module Meem
2
+ VERSION = "0.0.1"
3
+ end
data/lib/meem.rb ADDED
@@ -0,0 +1,115 @@
1
+ require "meem/version"
2
+ require "optparse"
3
+ require "ostruct"
4
+ require "meme_captain"
5
+ require "open-uri"
6
+
7
+ DIRECTORY = File.expand_path File.dirname __FILE__
8
+
9
+ module Meem
10
+ PATHS = [
11
+ "#{ENV['HOME']}/.meem/",
12
+ "#{DIRECTORY}/../templates/"
13
+ ]
14
+
15
+ def self.run arguments
16
+ options = parse arguments
17
+
18
+ image = MemeCaptain.meme_top_bottom fetch(options.meme), options.top, options.bottom,
19
+ font: "#{DIRECTORY}/../fonts/impact.ttf"
20
+
21
+ if STDOUT.tty?
22
+ path = "/tmp/meme.jpg"
23
+
24
+ image.write path
25
+ puts path
26
+ else
27
+ puts image.to_blob
28
+ end
29
+ end
30
+
31
+ # Parse options.
32
+ #
33
+ # arguments - An Array of arguments.
34
+ #
35
+ # Returns options.
36
+ def self.parse arguments
37
+ options = OpenStruct.new
38
+
39
+ options.meme = arguments.first
40
+
41
+ OptionParser.new do |opts|
42
+ opts.program_name = "meem"
43
+ opts.banner = "usage: meem <meme> <top text> <bottom text>"
44
+ opts.version = Meem::VERSION
45
+
46
+ opts.on "-l", "--list", "List memes" do
47
+ list
48
+ exit
49
+ end
50
+
51
+ opts.on "-t", "--top TEXT", "Set top text" do |value|
52
+ options.top = value
53
+ end
54
+
55
+ opts.on "-b", "--bottom TEXT", "Set bottom text" do |value|
56
+ options.bottom = value
57
+ end
58
+
59
+ opts.on "-h", "--help", "Show this message" do
60
+ puts opts
61
+ exit
62
+ end
63
+
64
+ opts.on "-v", "--version", "Show version" do
65
+ puts Meem::VERSION
66
+ exit
67
+ end
68
+ end.parse! arguments
69
+
70
+ options
71
+ end
72
+
73
+ # List memes.
74
+ def self.list
75
+ PATHS.each do |path|
76
+ Dir.glob "#{path}/*.jpg" do |file|
77
+ file = Pathname.new file
78
+
79
+ puts "* " + file.basename.to_s[/(.*)\.jpg/, 1]
80
+ end
81
+ end
82
+ end
83
+
84
+ private
85
+
86
+ # Print a message and exit.
87
+ #
88
+ # message - A String describing the message.
89
+ # code - An Integer describing the error code.
90
+ def self.error message, code = 1
91
+ puts "meem: #{message}"
92
+ exit code
93
+ end
94
+
95
+ # Load a meme.
96
+ #
97
+ # meme - A String describing a meme.
98
+ #
99
+ # Returns a File.
100
+ def self.fetch meme
101
+ if meme[/^http:\/\//]
102
+ return open meme
103
+ else
104
+ PATHS.each do |path|
105
+ image = path + "#{meme}.jpg"
106
+
107
+ if File.exists? image
108
+ return open image
109
+ end
110
+ end
111
+
112
+ error "meme not found"
113
+ end
114
+ end
115
+ end
data/meem.gemspec ADDED
@@ -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 'meem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "meem"
8
+ spec.version = Meem::VERSION
9
+ spec.authors = ["Johannes Gorset"]
10
+ spec.email = ["jgorset@gmail.com"]
11
+ spec.description = "Meme generator"
12
+ spec.summary = "Meem is a command-line tool to create memes"
13
+ spec.homepage = "https://github.com/jgorset/meem"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "meme_captain"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
data/spec/meem_spec.rb ADDED
@@ -0,0 +1,20 @@
1
+ require "meem"
2
+
3
+ describe Meem do
4
+ describe "#parse" do
5
+
6
+ it "accepts a meme" do
7
+ options = subject.parse ["y-u-no"]
8
+
9
+ expect(options.meme).to eq "y-u-no"
10
+ end
11
+
12
+ it "sets text" do
13
+ options = subject.parse ["y-u-no", "--top", "foo", "--bottom", "bar"]
14
+
15
+ expect(options.top).to eq "foo"
16
+ expect(options.bottom).to eq "bar"
17
+ end
18
+
19
+ end
20
+ end
Binary file
Binary file
data/templates/fry.jpg ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: meem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Johannes Gorset
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: meme_captain
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
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: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
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: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
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: rspec
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
+ description: Meme generator
79
+ email:
80
+ - jgorset@gmail.com
81
+ executables:
82
+ - meem
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/meem
92
+ - fonts/impact.ttf
93
+ - lib/meem.rb
94
+ - lib/meem/version.rb
95
+ - meem.gemspec
96
+ - spec/meem_spec.rb
97
+ - templates/butthurt.jpg
98
+ - templates/dos-equis.jpg
99
+ - templates/fry.jpg
100
+ - templates/good-guy-greg.jpg
101
+ - templates/j-ducreux.jpg
102
+ - templates/jackie-chan.jpg
103
+ - templates/pedobear.jpg
104
+ - templates/philosoraptor.jpg
105
+ - templates/rage.jpg
106
+ - templates/scumbag.jpg
107
+ - templates/success-kid.jpg
108
+ - templates/xzibit.jpg
109
+ - templates/y-u-no.jpg
110
+ - templates/yao-ming.jpg
111
+ homepage: https://github.com/jgorset/meem
112
+ licenses:
113
+ - MIT
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
125
+ - 0
126
+ hash: -3347627383807597533
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
134
+ - 0
135
+ hash: -3347627383807597533
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.23
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Meem is a command-line tool to create memes
142
+ test_files:
143
+ - spec/meem_spec.rb