emoji2020 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11d2bad986bb6c043a565d393f900d7ee4f98589f144f0deb7ff7bc6295d76a7
4
- data.tar.gz: d8c3567c008207981264510df9d3be4957ff29cd782f44c3b13b7cd65aec896c
3
+ metadata.gz: 8e7c097ecb7b075dcf76d48d18b248d0f403e51aaec053f3347d21a811b43b43
4
+ data.tar.gz: 0b563ddff60006ffeac7a8048968e58e1a2607b7edcd06487457de026e841ca7
5
5
  SHA512:
6
- metadata.gz: c1aa4227345887e65574101648575b62d234b2097cb266c40ffdcae3d41238c0b576e8687f41a39eef4213858f0000c37b3a7d07c463c15c388c159285933b81
7
- data.tar.gz: e8013d2ca6d8112f097432e4da7332afd737f3e0d5fc5538b0b02da16664ee3cc2524ffa53813061e958e249f99716d1327a9897245942753706b07a534d1c9c
6
+ metadata.gz: adb686bb39adb1f6705ff9b94b2adec7a42f051012a6ab62ac8ffe4c96ca67ee5d6a2596fd141014a2c79d909e355dded5fd0b9d8f4e88f8c7a0d12ae4f7cc53
7
+ data.tar.gz: def9385b7be172922c435ae27f549a7f95a4ab8c634aada0ba3884485f0b7db6b89fcdad1ce3f528e3a256cae960538c7331d384580c669366ea197ce00b53e4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -563,7 +563,7 @@ EMOJI = "
563
563
  🕸 Spider Web
564
564
  🦂 Scorpion
565
565
  🦟 Mosquito
566
- 🦠 Microbe
566
+ 🦠 Microbe #virus
567
567
  💐 Bouquet
568
568
  🌸 Cherry Blossom
569
569
  💮 White Flower
@@ -1776,16 +1776,19 @@ EMOJI = "
1776
1776
 
1777
1777
  class Emoji2020
1778
1778
 
1779
- def initialize(obj, debug: false)
1779
+ def initialize(obj=nil, debug: false)
1780
1780
 
1781
- a = EMOJI.strip.gsub(/^#[^\n]+\n/,'').gsub(/^\n/,'').lines\
1781
+ a = EMOJI.strip.gsub(/\s+#[^\n]+/,'').gsub(/^\n/,'').lines\
1782
1782
  .map {|x| x.chomp.lstrip.split(/ /,2).reverse}
1783
1783
  h = a.map {|key, value| [key.downcase.gsub(/\W+/,'_').to_sym, value]}.to_h
1784
1784
  puts 'h: ' + h.inspect if debug
1785
1785
 
1786
1786
  @s = case obj.class.to_s
1787
1787
  when 'Symbol'
1788
- h[obj]
1788
+
1789
+ keyword = obj
1790
+ r = h[keyword]
1791
+ r ? r : h[find(keyword)]
1789
1792
 
1790
1793
  when 'String'
1791
1794
 
@@ -1806,15 +1809,42 @@ class Emoji2020
1806
1809
  end
1807
1810
 
1808
1811
  end
1812
+
1813
+ # accepts a search keyword and returns the markdown name of the emoji
1814
+ # e.g. find('sunrise') #=> :sunrise:
1815
+ #
1816
+ def find(keyword)
1817
+
1818
+ r = search(keyword.to_s)
1819
+ return unless r
1820
+
1821
+ line = r.first
1822
+ _, title = line.strip.gsub(/\s+#[^\n]+/,'').split(/ /,2)
1823
+ title.downcase.gsub(/\W+/,'_').to_sym
1824
+
1825
+ end
1826
+
1827
+ # accepts a search keyword and returns a raw listing of emoji search results
1828
+ #
1829
+ def search(keyword)
1830
+ EMOJI.lines.grep /#{keyword}/i
1831
+ end
1809
1832
 
1833
+ # returns decimal value of each Unicode byte sequence used to
1834
+ # construct the emoji
1835
+ #
1810
1836
  def to_a()
1811
1837
  @s.unpack('U*')
1812
1838
  end
1813
1839
 
1840
+ # returns the emoji
1841
+ #
1814
1842
  def to_s()
1815
1843
  @s
1816
1844
  end
1817
1845
 
1846
+ # returns the Unicode value of the current emoji
1847
+ #
1818
1848
  def to_unicode()
1819
1849
  "U+{%s}" % self.to_a.map {|x| x.to_s(16)}.join(' ')
1820
1850
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emoji2020
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
  - James Robertson
metadata.gz.sig CHANGED
Binary file