memegen 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/memegen +26 -13
  2. data/lib/meme_generator.rb +1 -1
  3. metadata +6 -8
@@ -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
- def generators
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}/*"]).sort
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
- generator, top, bottom = ARGV[0..2]
20
+ image, top, bottom = ARGV[0..2]
19
21
 
20
22
  # List
21
- if generator == "--list"
22
- generators.each do |path|
23
- puts File.basename(path).gsub(/\..*/, '')
24
- end
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
- # Require arguments
29
- usage unless generator && (top || bottom)
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
- # Generate
32
- if path = generators.find { |p| p =~ /#{generator}\./ }
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 "Meme not found"
38
- exit 1
49
+ puts "Error: You must provide at least one piece of text"
50
+ usage
39
51
  end
52
+
@@ -3,7 +3,7 @@ require "bundler/setup"
3
3
  require "RMagick"
4
4
 
5
5
  class MemeGenerator
6
- VERSION = "0.0.5"
6
+ VERSION = "0.0.6"
7
7
  IMPACT_PATH = "fonts/Impact.ttf" # If you don't have OS X, fork me :)
8
8
 
9
9
  class << self
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: 21
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
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-07 00:00:00 -04:00
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.3.7
66
+ rubygems_version: 1.7.2
69
67
  signing_key:
70
68
  specification_version: 3
71
69
  summary: Two-caption meme generator CLI