remoji 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/remoji.rb +16 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b8be9381d8da6e70c35fcf073d787feec0744b3095aa4f7a8155aea75bdacf0
4
- data.tar.gz: 02d20c9d05a8ef84e230f2c29aa9a00efe7cc67d0091fbd834206da97dadbbd5
3
+ metadata.gz: d7d5a03e776d9a4c24279a76277ba676d67a6879e2b1abe5d581a6b21f159b18
4
+ data.tar.gz: b9e4c716805f748ac65a9b434dfb5752e8c9cad36dd4852df8b8693641d39c2c
5
5
  SHA512:
6
- metadata.gz: a2749f11e54985952a6e0436b9556a6e6c1ce500b09af943b3eb6f6194ce92a0c8afe0a3ba2900751955079b3f3d70c1ef68a7484af117ea447ccf9f42c1f350
7
- data.tar.gz: 6d07a84efc4c24b4626b0fe2aeccc2eb6d1a8727fbb7d8397f4d1cdc2898322ec119d25ef281d8294804344076e1a951b2e2744576afca6afdf84c4c7c28a9e7
6
+ metadata.gz: ebe90145555111865897b5769ab9102650c5aecc422b74addcc0584213cea92e0a00d59be27d5fb49519d612e44c25c252b76d340b46228fe886e441223220df
7
+ data.tar.gz: 2d55275638a5fa539719bb08f8d659accfbaf04018d7509481ff52b7e3613943574dfdf861cf8b69b750663f5e5c4f8b8fc2348eadcd4b8d144b67a54d0c0a67
data/lib/remoji.rb CHANGED
@@ -90,6 +90,10 @@ class Remoji # rubocop:disable Metrics/ClassLength
90
90
  import_emojis!
91
91
  end
92
92
 
93
+ def filter_array
94
+ @filter_array ||= filter_hash.to_a
95
+ end
96
+
93
97
  def filter_hash
94
98
  return @filter_hash if @filter_hash
95
99
 
@@ -107,18 +111,22 @@ class Remoji # rubocop:disable Metrics/ClassLength
107
111
  parse_opts! args
108
112
 
109
113
  if args.empty?
110
- output(filter_hash.keys.map { |key| { key => filter_hash[key] } })
114
+ output filter_array
111
115
  exit
112
116
  end
113
117
 
114
118
  found = []
115
119
  args.each do |arg|
116
- found << find_in_filter_hash(arg)
120
+ found += find_in_filter_array(arg)
117
121
  end
118
122
 
119
123
  output found
120
124
  end
121
125
 
126
+ def find_in_filter_array(arg)
127
+ find_in_filter_hash(arg).to_a || []
128
+ end
129
+
122
130
  def find_in_filter_hash(arg)
123
131
  filter_hash.select do |k, _v|
124
132
  s = k.to_s
@@ -190,19 +198,18 @@ class Remoji # rubocop:disable Metrics/ClassLength
190
198
  end
191
199
 
192
200
  def output(them) # rubocop:disab
193
- die! 'No matching emojis found', 2 if them.first == {}
201
+ die! 'No matching emojis found', 2 if them.empty?
194
202
 
195
- them.each do |k|
196
- key = k.keys.first
197
- v = k[key]
203
+ them.each do |name, attrs|
198
204
  if @options.no
199
- print "#{v[:sym]} "
205
+ print "#{attrs[:sym]} "
200
206
  elsif @options.verbose.positive?
201
- puts "#{key}: #{v}"
207
+ puts "#{name}: #{attrs}"
202
208
  else
203
- puts "#{key}: #{v[:sym]}"
209
+ puts "#{name}: #{attrs[:sym]}"
204
210
  end
205
211
  end
212
+ print "\n" if @options.no
206
213
  end
207
214
  end
208
215
 
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tj@rubyists.com