Class: Gitmoji::Regex::Reference
- Inherits:
-
Object
- Object
- Gitmoji::Regex::Reference
- Includes:
- Singleton
- Defined in:
- lib/gitmoji/regex/reference.rb
Overview
Reference provides utility tools for maintaining and testing this gem
Constant Summary collapse
- GITMOJI_REFERENCE =
"https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json"
- GITMOJI_PATH =
"src/gitmojis.json"
- LIB_SRC =
"lib/gitmoji/regex.rb"
- TEMPLATE_SRC =
"src/regex.rb"
Instance Method Summary collapse
- #cached_pattern ⇒ Object
- #compare_json ⇒ Object
- #compare_src ⇒ Object
- #current_src ⇒ Object
- #fetched_pattern ⇒ Object
- #next_src ⇒ Object
- #to_a(body = nil) ⇒ Object
- #write_json ⇒ Object
- #write_src ⇒ Object
Instance Method Details
#cached_pattern ⇒ Object
26 27 28 |
# File 'lib/gitmoji/regex/reference.rb', line 26 def cached_pattern pattern(cached) end |
#compare_json ⇒ Object
20 21 22 23 24 |
# File 'lib/gitmoji/regex/reference.rb', line 20 def compare_json return true if cached_pattern == fetched_pattern false end |
#compare_src ⇒ Object
34 35 36 37 38 |
# File 'lib/gitmoji/regex/reference.rb', line 34 def compare_src return true if current_src == next_src false end |
#current_src ⇒ Object
40 41 42 |
# File 'lib/gitmoji/regex/reference.rb', line 40 def current_src File.read(LIB_SRC) end |
#fetched_pattern ⇒ Object
30 31 32 |
# File 'lib/gitmoji/regex/reference.rb', line 30 def fetched_pattern pattern(fetch) end |
#next_src ⇒ Object
44 45 46 47 48 |
# File 'lib/gitmoji/regex/reference.rb', line 44 def next_src template_src = File.read(TEMPLATE_SRC) template_src = template_src.sub(/% gitmojiRegex %/, pattern(fetch).to_s) template_src.to_s end |
#to_a(body = nil) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/gitmoji/regex/reference.rb', line 50 def to_a(body = nil) body ||= cached json = JSON.parse(body) gitmoji = json["gitmojis"] gitmoji.map { |g| g["emoji"] } end |
#write_json ⇒ Object
57 58 59 60 61 62 |
# File 'lib/gitmoji/regex/reference.rb', line 57 def write_json file = File.write(GITMOJI_PATH, fetch) @cached = nil @cached_pattern = nil file end |
#write_src ⇒ Object
64 65 66 |
# File 'lib/gitmoji/regex/reference.rb', line 64 def write_src File.write(LIB_SRC, next_src) end |