memegen 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +6 -1
  2. data/bin/memegen +33 -2
  3. data/lib/meme_generator.rb +3 -35
  4. metadata +3 -3
data/README.md CHANGED
@@ -39,7 +39,12 @@ You can add generators to your local `~/.memegen` folder:
39
39
  $ ls ~/.memegen
40
40
  my_custom_generator.png
41
41
 
42
+ ## Bash completion
43
+
44
+ Source or copy `script/autocomplete.sh` inside `~/.bashrc` to get generator
45
+ name autocompletion.
46
+
42
47
  ## Contribute
43
48
 
44
- Feel free to improve this and add your own generator images!
49
+ Pull requests welcome!
45
50
 
data/bin/memegen CHANGED
@@ -3,6 +3,37 @@
3
3
  $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
- require "meme_generator"
7
6
 
8
- MemeGenerator.run
7
+ def generators
8
+ local_generator_dir = File.expand_path("~/.memegen")
9
+ Dir.glob(["generators/*", "#{local_generator_dir}/*"]).sort
10
+ end
11
+
12
+ def usage
13
+ puts 'usage: memegen <generator> <top text> <bottom text> [--list]'
14
+ exit 1
15
+ end
16
+
17
+ # Process command
18
+ generator, top, bottom = ARGV[0..2]
19
+
20
+ # List
21
+ if generator == "--list"
22
+ generators.each do |path|
23
+ puts File.basename(path).gsub(/\..*/, '')
24
+ end
25
+ exit 0
26
+ end
27
+
28
+ # Require arguments
29
+ usage unless generator && (top || bottom)
30
+
31
+ # Generate
32
+ if path = generators.find { |p| p =~ /#{generator}\./ }
33
+ require "meme_generator"
34
+ MemeGenerator.generate(path, top, bottom)
35
+ exit 0
36
+ else
37
+ puts "Meme not found"
38
+ exit 1
39
+ end
@@ -3,39 +3,10 @@ require "bundler/setup"
3
3
  require "RMagick"
4
4
 
5
5
  class MemeGenerator
6
- VERSION = "0.0.4"
6
+ VERSION = "0.0.5"
7
7
  IMPACT_PATH = "fonts/Impact.ttf" # If you don't have OS X, fork me :)
8
8
 
9
9
  class << self
10
- def run(argv = ARGV)
11
- generator, top, bottom = argv[0..2]
12
-
13
- return list_generators if generator == "--list"
14
- return usage unless generator && (top || bottom)
15
-
16
- if path = generators.find { |p| p =~ /#{generator}\./}
17
- generate(path, top, bottom)
18
- exit 0
19
- else
20
- puts "Meme not found"
21
- exit 1
22
- end
23
- end
24
-
25
- private
26
-
27
- def usage
28
- puts 'usage: memegen <generator> <top text> <bottom text> [--list]'
29
- exit 1
30
- end
31
-
32
- def list_generators
33
- generators.each do |path|
34
- puts File.basename(path).gsub(/\..*/, '')
35
- end
36
- exit 0
37
- end
38
-
39
10
  def generate(path, top, bottom)
40
11
  top = top.upcase
41
12
  bottom = bottom.upcase
@@ -88,6 +59,8 @@ class MemeGenerator
88
59
  exit 0
89
60
  end
90
61
 
62
+ private
63
+
91
64
  def word_wrap(txt, col = 80)
92
65
  txt.gsub(/(.{1,#{col + 4}})(\s+|\Z)/, "\\1\n")
93
66
  end
@@ -105,10 +78,5 @@ class MemeGenerator
105
78
  end
106
79
  [scale, text.strip]
107
80
  end
108
-
109
- def generators
110
- local_generator_dir = File.expand_path("~/.memegen")
111
- Dir.glob(["generators/*", "#{local_generator_dir}/*"]).sort
112
- end
113
81
  end
114
82
  end
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Keene