memegen 0.0.5 → 0.0.6
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/bin/memegen +26 -13
- data/lib/meme_generator.rb +1 -1
- metadata +6 -8
data/bin/memegen
CHANGED
@@ -4,9 +4,11 @@ $LOAD_PATH.unshift File.expand_path("lib")
|
|
4
4
|
$LOAD_PATH.unshift File.expand_path("../lib")
|
5
5
|
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
6
6
|
|
7
|
-
|
7
|
+
URL_REGEX = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix
|
8
|
+
|
9
|
+
def images
|
8
10
|
local_generator_dir = File.expand_path("~/.memegen")
|
9
|
-
Dir.glob(["generators/*", "#{local_generator_dir}/*"])
|
11
|
+
Dir.glob(["generators/*", "#{local_generator_dir}/*"])
|
10
12
|
end
|
11
13
|
|
12
14
|
def usage
|
@@ -15,25 +17,36 @@ def usage
|
|
15
17
|
end
|
16
18
|
|
17
19
|
# Process command
|
18
|
-
|
20
|
+
image, top, bottom = ARGV[0..2]
|
19
21
|
|
20
22
|
# List
|
21
|
-
if
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
if image == "--list"
|
24
|
+
names = images.map { |path|
|
25
|
+
File.basename(path).gsub(/\..*/, '')
|
26
|
+
}.sort
|
27
|
+
|
28
|
+
names.each { |name| puts name }
|
25
29
|
exit 0
|
26
30
|
end
|
27
31
|
|
28
|
-
#
|
29
|
-
|
32
|
+
# URL
|
33
|
+
if image =~ URL_REGEX
|
34
|
+
path = "/tmp/memegen-download-#{Time.now.to_i}"
|
35
|
+
`curl "#{image}" -o #{path} --silent`
|
36
|
+
elsif path = images.find { |p| p =~ /#{image}\./ }
|
37
|
+
# Success!
|
38
|
+
else
|
39
|
+
puts "Error: Image not found. Use --list to view installed images."
|
40
|
+
exit 1
|
41
|
+
end
|
30
42
|
|
31
|
-
#
|
32
|
-
if
|
43
|
+
# Require at least one text argument
|
44
|
+
if top || bottom
|
33
45
|
require "meme_generator"
|
34
46
|
MemeGenerator.generate(path, top, bottom)
|
35
47
|
exit 0
|
36
48
|
else
|
37
|
-
puts "
|
38
|
-
|
49
|
+
puts "Error: You must provide at least one piece of text"
|
50
|
+
usage
|
39
51
|
end
|
52
|
+
|
data/lib/meme_generator.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memegen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brandon Keene
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-05-08 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: Locally generate two-caption 'Advice Dog'-style meme images
|
@@ -33,7 +32,6 @@ files:
|
|
33
32
|
- lib/meme_generator.rb
|
34
33
|
- LICENSE
|
35
34
|
- README.md
|
36
|
-
has_rdoc: true
|
37
35
|
homepage: http://github.com/cmdrkeene/memegen
|
38
36
|
licenses: []
|
39
37
|
|
@@ -65,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
63
|
requirements: []
|
66
64
|
|
67
65
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.7.2
|
69
67
|
signing_key:
|
70
68
|
specification_version: 3
|
71
69
|
summary: Two-caption meme generator CLI
|