remoji 0.0.7 โ†’ 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +25 -2
  3. data/lib/remoji.rb +30 -9
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b9db4127ee7587facc91d5fda0cff2e023b1fc4401d9288e40cb996f1674946
4
- data.tar.gz: c34a8d4b9f42d3c762b634f6e38dfae06fce156e4172c176d143f52ceff25e6d
3
+ metadata.gz: c75476c47ca7b6c763454e478fd9799bce7c53faf3e07dbb918b6dcfe2f7cfb6
4
+ data.tar.gz: 48f4c44378c1c6974bc65e337b9fa375d68c3f11b70ca9009937aeefa80acfeb
5
5
  SHA512:
6
- metadata.gz: cd8d43180007fef0022bcad5ca2787836832d1f372f4e9870552b143fad4c0fa806d2e9f798d8c526d4f730a9485226853b47b53dbf888cdb72252ff1d416ac1
7
- data.tar.gz: 6dac25b8a00d534b9618717da7badc1d51a0d0ce6bfc96096096153175bdcad5761a63465708cee1c95aad3f6aa66de7340a85701e42c44333ba9acb5af7d68c
6
+ metadata.gz: aaf22d4a603b6e68c3ddc65e34b585cc04046999ffd73c7f4d91389d926434bab57b99a1bdc1a88988144aefa621678f64b29d7f541e4fab72174563a28f46de
7
+ data.tar.gz: bee77b6c23833062797fb0d63d9160755cd5e7c81f8e427722e4011b166ba6a168b5ede7b734cf396ea563de236d37e20c76f0d79297325b2867c6c4840761e5
data/README.adoc CHANGED
@@ -29,7 +29,7 @@ Where EMOJI is an emoji name to search for
29
29
 
30
30
  == Examples
31
31
 
32
- Normal List
32
+ Normal List, searching the main category 'Animal' for 'cat'
33
33
 
34
34
  ----
35
35
  % emj -c Animal cat
@@ -37,7 +37,7 @@ cat face: ๐Ÿฑ
37
37
  cat: ๐Ÿˆ
38
38
  ----
39
39
 
40
- Without any metadata
40
+ Without any metadata (-n)
41
41
 
42
42
  ----
43
43
  % emj -n -c Animal cat
@@ -59,3 +59,26 @@ see-no-evil monkey: {:code=>"U+1F648", :sym=>"๐Ÿ™ˆ", :cat=>"Smileys & Emotion",
59
59
  hear-no-evil monkey: {:code=>"U+1F649", :sym=>"๐Ÿ™‰", :cat=>"Smileys & Emotion", :subcat=>"monkey-face"}
60
60
  speak-no-evil monkey: {:code=>"U+1F64A", :sym=>"๐Ÿ™Š", :cat=>"Smileys & Emotion", :subcat=>"monkey-face"}
61
61
  ----
62
+
63
+ Show all emojis in the 'household' subcategory
64
+
65
+ ----
66
+ % emj -s household
67
+ door: ๐Ÿšช
68
+ bed: ๐Ÿ›
69
+ couch and lamp: ๐Ÿ›‹
70
+ chair: ๐Ÿช‘
71
+ toilet: ๐Ÿšฝ
72
+ shower: ๐Ÿšฟ
73
+ bathtub: ๐Ÿ›
74
+ razor: ๐Ÿช’
75
+ lotion bottle: ๐Ÿงด
76
+ safety pin: ๐Ÿงท
77
+ broom: ๐Ÿงน
78
+ basket: ๐Ÿงบ
79
+ roll of paper: ๐Ÿงป
80
+ soap: ๐Ÿงผ
81
+ sponge: ๐Ÿงฝ
82
+ fire extinguisher: ๐Ÿงฏ
83
+ shopping cart: ๐Ÿ›’
84
+ ----
data/lib/remoji.rb CHANGED
@@ -10,7 +10,7 @@ require 'open-uri'
10
10
  require 'awesome_print'
11
11
 
12
12
  # The Remoji command
13
- class Remoji
13
+ class Remoji # rubocop:disable Metrics/ClassLength
14
14
  EMOJI_TABLE = 'http://unicode.org/emoji/charts/full-emoji-list.html'.freeze
15
15
 
16
16
  def self.run!(args)
@@ -107,23 +107,36 @@ class Remoji
107
107
  parse_opts! args
108
108
 
109
109
  if args.empty?
110
- output filter_hash, @options
110
+ output filter_hash
111
111
  exit
112
112
  end
113
113
 
114
114
  found = {}
115
- args.each do |argv|
116
- found.merge!(filter_hash.select { |k, _v| k =~ /#{argv}/i })
115
+ args.each do |arg|
116
+ found.merge!(find_in_filter_hash(arg))
117
117
  end
118
118
 
119
- output found, @options
119
+ output found
120
+ end
121
+
122
+ def find_in_filter_hash(arg)
123
+ filter_hash.select do |k, _v|
124
+ s = k.to_s
125
+ if @options.exact
126
+ s == arg
127
+ elsif @options.regex
128
+ s =~ /#{arg}/
129
+ else
130
+ s =~ /#{arg}/i
131
+ end
132
+ end
120
133
  end
121
134
 
122
135
  def parse_opts!(args)
123
136
  OptionParser.new do |o|
124
137
  o.banner = "#{$PROGRAM_NAME} [options] EMOJI ANOTHER_EMOJI ..."
125
138
  o.separator 'Where EMOJI is an emoji name to search for'
126
- %i[cat subcat details cats subcats verbose].each do |sym|
139
+ %i[cat subcat details cats subcats verbose exact regex].each do |sym|
127
140
  send "#{sym}_opt".to_sym, o
128
141
  end
129
142
  o.on('-h', '--help') do
@@ -133,6 +146,14 @@ class Remoji
133
146
  end.parse!(args)
134
147
  end
135
148
 
149
+ def exact_opt(opt)
150
+ opt.on('-e', '--exact', 'Exactly match the emoji given, do not search for it') { @options.exact = true }
151
+ end
152
+
153
+ def regex_opt(opt)
154
+ opt.on('-r', '--regex', 'Consider each argument a regular expressoin') { @options.regex = true }
155
+ end
156
+
136
157
  def verbose_opt(opt)
137
158
  opt.on('-v', '--verbose', 'Increase verbosity') { @options.verbose += 1 }
138
159
  end
@@ -163,12 +184,12 @@ class Remoji
163
184
  opt.on('-n', '--no-details', 'Just print the emojis') { |_| @options.no = true }
164
185
  end
165
186
 
166
- def output(them, options = OpenStruct.new)
167
- if options.no
187
+ def output(them)
188
+ if @options.no
168
189
  puts them.map { |_k, v| v[:sym] }.join(' ')
169
190
  else
170
191
  them.each do |k, v|
171
- if options.verbose.positive?
192
+ if @options.verbose.positive?
172
193
  puts "#{k}: #{v}"
173
194
  else
174
195
  puts "#{k}: #{v[:sym]}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - tj@rubyists.com