ibo_ipsum 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: a2b9de6c28d751b85144c29a49e73c45b79b0f60
4
- data.tar.gz: 9206ac5a070aec9828ad0e5accfc71a2ecd4dc96
3
+ metadata.gz: bd04deddd38eaaa6e57a726c4a3552b62df0b603
4
+ data.tar.gz: 084060695263b4d38958f607499961dd0bab9efa
5
5
  SHA512:
6
- metadata.gz: 50b7d76879b4111725415066594c4665628592091d0cb677f2cba56337ec0216923eaf253239da5f685b26c9fcc5cdce148461f2f814d5fa7e341c99f82ce7f5
7
- data.tar.gz: 7ddf381a3a8811a184de71e37ddb15d6c5db18e621dcd1e322cca4195cbd4d3423b6bd4563c3966f5371eb01a29083cd8e01eb11e546c5950716330c386bdb07
6
+ metadata.gz: 5414e68ae57d417374845a3b021dd6acd9999bb7ab5d0cff83f6a599e6d20017f11822e0ca91299ccbac0f47e7330bf5e24e03815919a41d611dfcae7c4298e9
7
+ data.tar.gz: 9d243fddc74787fd4101696cafcd7f85fed1d4b52b100771c08854b0b513781202ab30ffc2c8160d94e565570f89f5b25b89a955dd3e744a2cd7c049628dcd57
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ meme_*.jpg
data/bin/ibo CHANGED
@@ -15,6 +15,12 @@ class IboCli < Thor
15
15
  color IboIpsum::Ibo.new.cite
16
16
  end
17
17
 
18
+ desc "meme TEXT", "Generate Meme"
19
+ def meme(*text)
20
+ text = text.empty? ? IboIpsum::Ibo.new.cite : text.join(" ")
21
+ IboIpsum::Meme.new(text).generate
22
+ end
23
+
18
24
  desc "version", "Show current version"
19
25
  def version
20
26
  puts "Ibo Ipsum #{IboIpsum::VERSION}"
data/ibo_ipsum.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "thor", "~> 0.18.1"
22
+ spec.add_dependency "rmagick", "~> 2.13.2"
22
23
  spec.add_development_dependency "bundler", "~> 1.5"
23
24
  spec.add_development_dependency "rake"
24
25
  spec.add_development_dependency "pry"
data/img/ibo_1.jpg ADDED
Binary file
data/lib/ibo_ipsum.rb CHANGED
@@ -2,4 +2,5 @@ require "ibo_ipsum/version"
2
2
 
3
3
  module IboIpsum
4
4
  autoload :Ibo, "ibo_ipsum/ibo"
5
+ autoload :Meme, "ibo_ipsum/meme"
5
6
  end
@@ -0,0 +1,55 @@
1
+ require 'RMagick'
2
+ require 'securerandom'
3
+ require 'ibo_ipsum'
4
+
5
+ module IboIpsum
6
+ class Meme
7
+ include Magick
8
+
9
+ attr_reader :sentence, :image, :name
10
+
11
+ def initialize(sentence, path = default_path)
12
+ @sentence = sentence
13
+ @image = Image.read(path).first
14
+ @name = "meme_#{SecureRandom::hex(3)}.jpg"
15
+ end
16
+
17
+ def default_path
18
+ File.join(File.dirname(__FILE__), "../../img/ibo_1.jpg")
19
+ end
20
+
21
+ def prepared_sentence
22
+ word_wrap(sentence) + "\n"
23
+ end
24
+
25
+ def generate
26
+ text = Draw.new
27
+ text.annotate(image, 0,0,0,0, prepared_sentence) do
28
+ self.gravity = Magick::SouthGravity
29
+ self.pointsize = 35
30
+ self.font_family = "Helvetica"
31
+ self.font_weight = 900
32
+ self.fill = "#FF1493"
33
+ self.stroke = "#FFF"
34
+ self.stroke_width = 1
35
+ end
36
+ save_and_open!
37
+ end
38
+
39
+ def save_and_open!
40
+ puts "saved: #{name}"
41
+ image.write name
42
+ `open #{name}`
43
+ end
44
+
45
+ private
46
+
47
+ # stolen from rails
48
+ def word_wrap(text, options = {})
49
+ line_width = options.fetch(:line_width, 25)
50
+ text.split("\n").collect do |line|
51
+ line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
52
+ end * "\n"
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module IboIpsum
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibo_ipsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Schaden
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.18.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rmagick
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.13.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.13.2
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,8 +95,10 @@ files:
81
95
  - Rakefile
82
96
  - bin/ibo
83
97
  - ibo_ipsum.gemspec
98
+ - img/ibo_1.jpg
84
99
  - lib/ibo_ipsum.rb
85
100
  - lib/ibo_ipsum/ibo.rb
101
+ - lib/ibo_ipsum/meme.rb
86
102
  - lib/ibo_ipsum/version.rb
87
103
  - samples.yml
88
104
  homepage: ''