emojify 0.0.1 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
data/emojify.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "emojify"
|
7
|
-
gem.version = '0.0.
|
7
|
+
gem.version = '0.0.7'
|
8
8
|
gem.authors = ["Robert Evans"]
|
9
9
|
gem.email = ["robert@codewranglers.org"]
|
10
10
|
gem.description = %q{Use emoji in your content. Pass it a string and it will return the string with emoji images.}
|
data/lib/emojify.rb
CHANGED
@@ -4,24 +4,33 @@ module Emojify
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def emojify(text)
|
7
|
-
text.gsub(/:(.*?):/)
|
7
|
+
text.gsub(/:(.*?):/) do |word|
|
8
|
+
"<image src='#{Emojify::Config.image_directory}/#{$1}.png' height='#{Emojify::Config.height}' width='#{Emojify::Config.width}'/>"
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
module ClassMethods
|
11
|
-
def
|
12
|
-
Config.image_directory
|
13
|
+
def emoji(options={})
|
14
|
+
Config.image_directory = options[:directory]
|
15
|
+
Config.width = options[:width]
|
16
|
+
Config.height = options[:height]
|
13
17
|
end
|
14
18
|
|
15
|
-
def dir
|
16
|
-
Config.image_directory
|
17
|
-
end
|
18
19
|
end
|
19
20
|
|
20
21
|
class Config
|
21
22
|
class << self
|
22
|
-
attr_writer :image_directory
|
23
|
+
attr_writer :image_directory, :width, :height
|
23
24
|
def image_directory
|
24
|
-
@image_directory || '
|
25
|
+
@image_directory || '/assets/emojis'
|
26
|
+
end
|
27
|
+
|
28
|
+
def width
|
29
|
+
@width || 20
|
30
|
+
end
|
31
|
+
|
32
|
+
def height
|
33
|
+
@height || 20
|
25
34
|
end
|
26
35
|
end
|
27
36
|
end
|
@@ -7,9 +7,10 @@ module Emojify
|
|
7
7
|
source_root File.expand_path('../../../../../vendor/assets/images', __FILE__)
|
8
8
|
|
9
9
|
def copy_images
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
copy_to_dir = 'vendor/assets/images/emojis'
|
11
|
+
say_status("copying", "Emojis to #{copy_to_dir}", :green)
|
12
|
+
directory "emojis", copy_to_dir
|
13
|
+
copy_file "stucco.png", "#{copy_to_dir}/stucco.png"
|
13
14
|
end
|
14
15
|
|
15
16
|
end
|
@@ -7,15 +7,15 @@ class EmojifyDefaultTest < MiniTest::Unit::TestCase
|
|
7
7
|
include Emojify
|
8
8
|
|
9
9
|
def test_replacing_keyword
|
10
|
-
assert_equal "Keywords <image src='
|
10
|
+
assert_equal "Keywords <image src='/assets/emojis/smile.png' height='20' width='20'/>", emojify("Keywords :smile:")
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_replacing_with_numbers
|
14
|
-
assert_equal "Keywords <image src='
|
14
|
+
assert_equal "Keywords <image src='/assets/emojis/+1.png' height='20' width='20'/>", emojify("Keywords :+1:")
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_replacing_multiple_words
|
18
|
-
assert_equal "Keywords <image src='
|
18
|
+
assert_equal "Keywords <image src='/assets/emojis/smile.png' height='20' width='20'/> when <image src='/assets/emojis/rain.png' height='20' width='20'/> and <image src='/assets/emojis/laughter.png' height='20' width='20'/> today",
|
19
19
|
emojify("Keywords :smile: when :rain: and :laughter: today")
|
20
20
|
end
|
21
21
|
end
|
data/test/lib/emojify_test.rb
CHANGED
@@ -5,14 +5,14 @@ require './lib/emojify'
|
|
5
5
|
|
6
6
|
class EmojifyTest < MiniTest::Unit::TestCase
|
7
7
|
include Emojify
|
8
|
-
|
8
|
+
emoji directory: 'public/images/emojify', width: 25, height: 25
|
9
9
|
|
10
10
|
def test_replacing_keyword
|
11
|
-
assert_equal "Keywords <image src='public/images/emojify/smile.png'/>", emojify("Keywords :smile:")
|
11
|
+
assert_equal "Keywords <image src='public/images/emojify/smile.png' height='25' width='25'/>", emojify("Keywords :smile:")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_replacing_multiple_words
|
15
|
-
assert_equal "Keywords <image src='public/images/emojify/smile.png'/> when <image src='public/images/emojify/rain.png'/> and <image src='public/images/emojify/laughter.png'/> today",
|
15
|
+
assert_equal "Keywords <image src='public/images/emojify/smile.png' height='25' width='25'/> when <image src='public/images/emojify/rain.png' height='25' width='25'/> and <image src='public/images/emojify/laughter.png' height='25' width='25'/> today",
|
16
16
|
emojify("Keywords :smile: when :rain: and :laughter: today")
|
17
17
|
end
|
18
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emojify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -958,4 +958,3 @@ summary: Use emoji in your content
|
|
958
958
|
test_files:
|
959
959
|
- test/lib/emojify_default_test.rb
|
960
960
|
- test/lib/emojify_test.rb
|
961
|
-
has_rdoc:
|