emot 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ module Emot
2
+ module SymbolExt
3
+ def ~
4
+ to_s.split
5
+ .map { |word| Emot.icon(word) || word.sub(/^\./, '') }
6
+ .join(" ")
7
+ end
8
+ end
9
+ end
10
+
11
+ Symbol.send(:include, Emot::SymbolExt)
@@ -0,0 +1,3 @@
1
+ module Emot
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Emot::CLI do
4
+ before do
5
+ $stdout, $stderr = StringIO.new, StringIO.new
6
+ end
7
+
8
+ after() do
9
+ $stdout, $stderr = STDOUT, STDERR
10
+ end
11
+
12
+ describe "#show" do
13
+ context "with emoji name" do
14
+ it "outputs icon with its unicode" do
15
+ Emot::CLI.start(['show', 'sunflower'])
16
+ expect($stdout.string).to eq "\u{1F33B} \e[32msunflower\e[0m (U+1F33B)\n"
17
+ end
18
+
19
+ it "outputs no emoji message" do
20
+ Emot::CLI.start(['show', 'hello'])
21
+ expect($stdout.string).to eq "No emoji for 'hello'\n"
22
+ end
23
+ end
24
+
25
+ context "without emoji name" do
26
+ it "outputs all emoji with name and unicode" do
27
+ Emot::CLI.start(['show'])
28
+ expect($stdout.string).to match /hash.*sunflower.*1F618.*bathtub/m
29
+ end
30
+
31
+ it "outputs all emoji with name" do
32
+ Emot::CLI.start(['show', '--only', 'name'])
33
+ expect($stdout.string).to match /hash.*sunflower.*bathtub/m
34
+ expect($stdout.string).not_to match /1F618/
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#icons" do
40
+ it "outputs all emoji icons" do
41
+ Emot::CLI.start(['icons'])
42
+ expect($stdout.string).to match /\u{1F33B}/
43
+ expect($stdout.string).not_to match /sunflower/
44
+ expect($stdout.string).not_to match /1F33B/
45
+ end
46
+ end
47
+
48
+ describe "#names" do
49
+ it "outputs all available names for emojis" do
50
+ Emot::CLI.start(['names'])
51
+ expect($stdout.string).to match /hash.*sunflower.*bathtub/m
52
+ expect($stdout.string).not_to match /\u{1F33B}/
53
+ expect($stdout.string).not_to match /1F33B/
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Emot do
4
+ it 'has a version number' do
5
+ expect(Emot::VERSION).not_to be nil
6
+ end
7
+
8
+ describe ".icon" do
9
+ it "returns icon for given name" do
10
+ expect(Emot.icon :apple).to eq "\u{1F34E}"
11
+ expect(Emot.icon 'airplane').to eq "\u{2708}\u{FE0F}"
12
+ expect(Emot.icon :hello_world).to be_nil
13
+ end
14
+ end
15
+
16
+ describe ".unicode" do
17
+ it "returns unicode in string" do
18
+ expect(Emot.unicode 'apple').to eq "U+1F34E"
19
+ expect(Emot.unicode :airplane).to eq "U+2708 U+FE0F"
20
+ expect(Emot.unicode :hello_world).to be_nil
21
+ end
22
+ end
23
+
24
+ describe ".list" do
25
+ it "returns emoji list" do
26
+ list = Emot.list
27
+ expect(list[:"+1"]).to eq ["\u{1F44D}", "U+1F44D"]
28
+ expect(list[:airplane]).to eq ["\u{2708}\u{FE0F}", "U+2708 U+FE0F"]
29
+ expect(list.first).to eq [:hash, ["\u{23}\u{FE0F}\u{20E3}", "U+23 U+FE0F U+20E3"]]
30
+ end
31
+ end
32
+ end
33
+
34
+ describe Symbol do
35
+ describe "#~" do
36
+ it "returns emoji string" do
37
+ expect(~:smile).to eq "\u{1F604}"
38
+ expect(~:jack_o_lantern).to eq "\u{1F383}"
39
+ end
40
+
41
+ it "returns emoji mixed string" do
42
+ expect(~:'dango is better than sunflower').to eq "\u{1F361} is better than \u{1F33B}"
43
+ expect(~:'fish + hocho => sushi').to eq "\u{1F41F} + \u{1F52A} => \u{1F363}"
44
+ end
45
+
46
+ it "escape emojiaze with prefix '.'" do
47
+ expect(~:'jp + .us + .fr').to eq "\u{1F1EF}\u{1F1F5} + us + fr"
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'emot'
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kyoendo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Yet another emoji handler.
70
+ email:
71
+ - postagie@gmail.com
72
+ executables:
73
+ - emot
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/emot
85
+ - emot.gemspec
86
+ - lib/emot.rb
87
+ - lib/emot/cli.rb
88
+ - lib/emot/map.rb
89
+ - lib/emot/symbol_ext.rb
90
+ - lib/emot/version.rb
91
+ - spec/cli_spec.rb
92
+ - spec/emot_spec.rb
93
+ - spec/spec_helper.rb
94
+ homepage: https://github.com/melborne/emot
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.0.0
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.2.2
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Yet another emoji handler.
118
+ test_files:
119
+ - spec/cli_spec.rb
120
+ - spec/emot_spec.rb
121
+ - spec/spec_helper.rb