gitmoji-regex 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +127 -0
- data/SECURITY.md +13 -0
- data/lib/gitmoji/regex/reference.rb +83 -0
- data/lib/gitmoji/regex/version.rb +7 -0
- data/lib/gitmoji/regex.rb +9 -0
- data/spec/config/rspec/rspec_core.rb +13 -0
- data/spec/gitmoji/regex/reference_spec.rb +73 -0
- data/spec/gitmoji/regex_spec.rb +21 -0
- data/spec/spec_helper.rb +36 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 472cec967facea7821ca6ac337adf22ead47a8a5556cc3dc51a7122220de29b5
|
4
|
+
data.tar.gz: 3052e67724706709839448d091780953f5fa5450902fc4ef282c1901fce32bda
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ecb15203b969ad67bf7069027140f4cd37967ed320a3c198f913f78ff4fd82cccc150152f0ce6befdf0a43d9bf3ba1d67c83232f186b7b9b6b36a3c60e544fb9
|
7
|
+
data.tar.gz: 80584b80f9b1f2a933a5bb0cd1afaa4113447d3a9f81b823fbffae97b10e41af98ef5fa7b0b9c203aa0e18def7c79ae3d8a7517832b26a19979856631c141c49
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at peter.boling@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## Contributing
|
2
|
+
|
3
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/pboling/gitmoji-regex][source]
|
4
|
+
. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
|
5
|
+
the [code of conduct][conduct].
|
6
|
+
|
7
|
+
To submit a patch, please fork the project and create a patch with tests. Once you're happy with it send a pull request!
|
8
|
+
|
9
|
+
## Contributors
|
10
|
+
|
11
|
+
[![Contributors](https://contrib.rocks/image?repo=pboling/gitmoji-regex)][contributors]
|
12
|
+
|
13
|
+
Made with [contributors-img][contrib-rocks].
|
14
|
+
|
15
|
+
[comment]: <> (Following links are used by README, CONTRIBUTING)
|
16
|
+
|
17
|
+
[conduct]: https://github.com/pboling/gitmoji-regex/blob/master/CODE_OF_CONDUCT.md
|
18
|
+
|
19
|
+
[contrib-rocks]: https://contrib.rocks
|
20
|
+
|
21
|
+
[contributors]: https://github.com/pboling/gitmoji-regex/graphs/contributors
|
22
|
+
|
23
|
+
[comment]: <> (Following links are used by README, CONTRIBUTING, Homepage)
|
24
|
+
|
25
|
+
[source]: https://github.com/pboling/gitmoji-regex/
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Peter Boling
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# Gitmoji::Regex
|
2
|
+
|
3
|
+
This gem provides a regex that allows Ruby code to test a string for a [Gitmoji](https://github.com/carloscuesta/gitmoji) character. Gitmoji is a [subset](https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json) of the Unicode Emoji character set. This gem is _not_ a fork of, but was **inspired** by, the wonderful [emoji-regex](https://github.com/ticky/ruby-emoji-regex) gem.
|
4
|
+
|
5
|
+
This gem has no runtime dependencies.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
$ bundle add gitmoji-regex
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
$ gem install gitmoji-regex
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
TODO: Write usage instructions here
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
See [CONTRIBUTING.md][contributing]
|
30
|
+
|
31
|
+
## Contributors
|
32
|
+
|
33
|
+
[![Contributors](https://contrib.rocks/image?repo=pboling/gitmoji-regex)]("https://github.com/pboling/gitmoji-regex/graphs/contributors")
|
34
|
+
|
35
|
+
Made with [contributors-img](https://contrib.rocks).
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of
|
40
|
+
the [MIT License][license] [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][license-ref].
|
41
|
+
See [LICENSE][license] for the official [Copyright Notice][copyright-notice-explainer].
|
42
|
+
|
43
|
+
* Copyright (c) 2022 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
|
44
|
+
|
45
|
+
NOTE: the [gitmoji project](https://github.com/carloscuesta/gitmoji) is also [MIT Licensed](https://github.com/carloscuesta/gitmoji/blob/master/LICENSE), and the file `src/gitmojis.json` comes from that project.
|
46
|
+
|
47
|
+
## Code of Conduct
|
48
|
+
|
49
|
+
Everyone interacting in the Gitmoji::Regex project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/gitmoji-regex/blob/main/CODE_OF_CONDUCT.md).
|
50
|
+
|
51
|
+
## Versioning
|
52
|
+
|
53
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
|
54
|
+
bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be
|
55
|
+
immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new
|
56
|
+
major versions.
|
57
|
+
|
58
|
+
As a result of this policy, you can (and should) specify a dependency on this gem using
|
59
|
+
the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
60
|
+
|
61
|
+
For example:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
spec.add_dependency "gitmoji-regex", "~> 0.1"
|
65
|
+
```
|
66
|
+
|
67
|
+
[copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
68
|
+
|
69
|
+
[gh_discussions]: https://github.com/pboling/gitmoji-regex/discussions
|
70
|
+
|
71
|
+
[conduct]: https://github.com/pboling/gitmoji-regex/blob/main/CODE_OF_CONDUCT.md
|
72
|
+
|
73
|
+
[contributing]: https://github.com/pboling/gitmoji-regex/blob/main/CONTRIBUTING.md
|
74
|
+
|
75
|
+
[security]: https://github.com/pboling/gitmoji-regex/blob/main/SECURITY.md
|
76
|
+
|
77
|
+
[license]: https://github.com/pboling/gitmoji-regex/blob/main/LICENSE.txt
|
78
|
+
|
79
|
+
[license-ref]: https://opensource.org/licenses/MIT
|
80
|
+
|
81
|
+
[semver]: http://semver.org/
|
82
|
+
|
83
|
+
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
84
|
+
|
85
|
+
[railsbling]: http://www.railsbling.com
|
86
|
+
|
87
|
+
[peterboling]: http://www.peterboling.com
|
88
|
+
|
89
|
+
[aboutme]: https://about.me/peter.boling
|
90
|
+
|
91
|
+
[angelme]: https://angel.co/peter-boling
|
92
|
+
|
93
|
+
[coderme]:http://coderwall.com/pboling
|
94
|
+
|
95
|
+
[followme-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
|
96
|
+
|
97
|
+
[tweetme]: http://twitter.com/galtzo
|
98
|
+
|
99
|
+
[politicme]: https://nationalprogressiveparty.org
|
100
|
+
|
101
|
+
[documentation]: https://rubydoc.info/github/pboling/gitmoji-regex/main
|
102
|
+
|
103
|
+
[source]: https://github.com/pboling/gitmoji-regex/
|
104
|
+
|
105
|
+
[actions]: https://github.com/pboling/gitmoji-regex/actions
|
106
|
+
|
107
|
+
[issues]: https://github.com/pboling/gitmoji-regex/issues
|
108
|
+
|
109
|
+
[climate_maintainability]: https://codeclimate.com/github/pboling/gitmoji-regex/maintainability
|
110
|
+
|
111
|
+
[climate_coverage]: https://codeclimate.com/github/pboling/gitmoji-regex/test_coverage
|
112
|
+
|
113
|
+
[codecov_coverage]: https://codecov.io/gh/pboling/gitmoji-regex
|
114
|
+
|
115
|
+
[code_triage]: https://www.codetriage.com/pboling/gitmoji-regex
|
116
|
+
|
117
|
+
[blogpage]: http://www.railsbling.com/tags/gitmoji-regex/
|
118
|
+
|
119
|
+
[rubygems]: https://rubygems.org/gems/gitmoji-regex
|
120
|
+
|
121
|
+
[chat]: https://gitter.im/pboling/gitmoji-regex?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
122
|
+
|
123
|
+
[maintenancee_policy]: https://guides.rubyonrails.org/maintenance_policy.html#security-issues
|
124
|
+
|
125
|
+
[liberapay_donate]: https://liberapay.com/pboling/donate
|
126
|
+
|
127
|
+
[gh_sponsors]: https://github.com/sponsors/pboling
|
data/SECURITY.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
| Version | Supported |
|
6
|
+
| ------- | ------------------ |
|
7
|
+
| 0.x | :white_check_mark: |
|
8
|
+
|
9
|
+
## Reporting a Vulnerability
|
10
|
+
|
11
|
+
Peter Boling is the primary maintainer of this gem. Please find a way
|
12
|
+
to [contact him directly](https://railsbling.com/contact) to report the issue. Include as much relevant information as
|
13
|
+
possible.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "singleton"
|
4
|
+
require "http"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
# Download the list of all possible gitmojis from the project's github repository
|
8
|
+
module Gitmoji
|
9
|
+
# Regex provides the namespace for this gem
|
10
|
+
module Regex
|
11
|
+
# Reference provides utility tools for maintaining and testing this gem
|
12
|
+
class Reference
|
13
|
+
GITMOJI_REFERENCE = "https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json"
|
14
|
+
GITMOJI_PATH = "src/gitmojis.json"
|
15
|
+
LIB_SRC = "lib/gitmoji/regex.rb"
|
16
|
+
TEMPLATE_SRC = "src/regex.rb"
|
17
|
+
|
18
|
+
include Singleton
|
19
|
+
|
20
|
+
def compare_json
|
21
|
+
return true if cached_pattern == fetched_pattern
|
22
|
+
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def cached_pattern
|
27
|
+
pattern(cached)
|
28
|
+
end
|
29
|
+
|
30
|
+
def fetched_pattern
|
31
|
+
pattern(fetch)
|
32
|
+
end
|
33
|
+
|
34
|
+
def compare_src
|
35
|
+
return true if current_src == next_src
|
36
|
+
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
def current_src
|
41
|
+
File.read(LIB_SRC)
|
42
|
+
end
|
43
|
+
|
44
|
+
def next_src
|
45
|
+
template_src = File.read(TEMPLATE_SRC)
|
46
|
+
template_src = template_src.sub(/% gitmojiRegex %/, pattern(fetch).to_s)
|
47
|
+
template_src.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_a(body = nil)
|
51
|
+
body ||= cached
|
52
|
+
json = JSON.parse(body)
|
53
|
+
gitmoji = json["gitmojis"]
|
54
|
+
gitmoji.map { |g| g["emoji"] }
|
55
|
+
end
|
56
|
+
|
57
|
+
def write_json
|
58
|
+
file = File.write(GITMOJI_PATH, fetch)
|
59
|
+
@cached = nil
|
60
|
+
@cached_pattern = nil
|
61
|
+
file
|
62
|
+
end
|
63
|
+
|
64
|
+
def write_src
|
65
|
+
File.write(LIB_SRC, next_src)
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def pattern(body)
|
71
|
+
Regexp.union(to_a(body))
|
72
|
+
end
|
73
|
+
|
74
|
+
def fetch
|
75
|
+
@fetch ||= HTTP.get(GITMOJI_REFERENCE).body
|
76
|
+
end
|
77
|
+
|
78
|
+
def cached
|
79
|
+
@cached ||= File.read(GITMOJI_PATH)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "regex/version"
|
4
|
+
|
5
|
+
module Gitmoji
|
6
|
+
module Regex
|
7
|
+
REGEX = Regexp.new("(?-mix:🎨|⚡️|🔥|🐛|🚑️|✨|📝|🚀|💄|🎉|✅|🔒️|🔐|🔖|🚨|🚧|💚|⬇️|⬆️|📌|👷|📈|♻️|➕|➖|🔧|🔨|🌐|✏️|💩|⏪️|🔀|📦️|👽️|🚚|📄|💥|🍱|♿️|💡|🍻|💬|🗃️|🔊|🔇|👥|🚸|🏗️|📱|🤡|🥚|🙈|📸|⚗️|🔍️|🏷️|🌱|🚩|🥅|💫|🗑️|🛂|🩹|🧐|⚰️|🧪|👔|🩺|🧱|🧑💻)")
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
# Enable flags like --only-failures and --next-failure
|
5
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
6
|
+
|
7
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
8
|
+
config.disable_monkey_patching!
|
9
|
+
|
10
|
+
config.expect_with :rspec do |c|
|
11
|
+
c.syntax = :expect
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Gitmoji::Regex::Reference do
|
4
|
+
subject(:instance) { described_class.instance }
|
5
|
+
|
6
|
+
it "Cached reference has all gitmoji" do
|
7
|
+
expect(instance.to_a).to eq(["🎨", "⚡️", "🔥", "🐛", "🚑️", "✨", "📝", "🚀", "💄", "🎉", "✅",
|
8
|
+
"🔒️", "🔐", "🔖", "🚨", "🚧", "💚", "⬇️", "⬆️", "📌", "👷", "📈",
|
9
|
+
"♻️", "➕", "➖", "🔧", "🔨", "🌐", "✏️", "💩", "⏪️", "🔀", "📦️",
|
10
|
+
"👽️", "🚚", "📄", "💥", "🍱", "♿️", "💡", "🍻", "💬", "🗃️", "🔊",
|
11
|
+
"🔇", "👥", "🚸", "🏗️", "📱", "🤡", "🥚", "🙈", "📸", "⚗️", "🔍️",
|
12
|
+
"🏷️", "🌱", "🚩", "🥅", "💫", "🗑️", "🛂", "🩹", "🧐", "⚰️", "🧪",
|
13
|
+
"👔", "🩺", "🧱", "🧑💻"])
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#compare_src" do
|
17
|
+
it "Cached source is current" do
|
18
|
+
expect(instance.compare_src).to be(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "detects change" do
|
22
|
+
allow(File).to receive(:read).and_return("a", "b")
|
23
|
+
expect(instance.compare_src).to be(false)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "reads files" do
|
27
|
+
allow(File).to receive(:read).and_return("a", "b")
|
28
|
+
instance.compare_src
|
29
|
+
expect(File).to have_received(:read).twice
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "Cached source is current" do
|
34
|
+
expect(instance.current_src).to eq(instance.next_src)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "Cached pattern is current" do
|
38
|
+
expect(instance.cached_pattern).to eq(instance.fetched_pattern)
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#compare_json" do
|
42
|
+
it "Cached reference is current" do
|
43
|
+
expect(instance.compare_json).to be(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "detects change" do
|
47
|
+
allow(Regexp).to receive(:union).and_return("a", "b")
|
48
|
+
expect(instance.compare_json).to be(false)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "calls pattern" do
|
52
|
+
allow(Regexp).to receive(:union).and_return("a", "b")
|
53
|
+
instance.compare_json
|
54
|
+
expect(Regexp).to have_received(:union).twice
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#write_json" do
|
59
|
+
it "writes" do
|
60
|
+
allow(File).to receive(:write).with(described_class::GITMOJI_PATH, anything)
|
61
|
+
instance.write_json
|
62
|
+
expect(File).to have_received(:write)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#write_src" do
|
67
|
+
it "writes" do
|
68
|
+
allow(File).to receive(:write).with(described_class::LIB_SRC, anything)
|
69
|
+
instance.write_src
|
70
|
+
expect(File).to have_received(:write)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Gitmoji::Regex do
|
4
|
+
it "has a version number" do
|
5
|
+
expect(Gitmoji::Regex::VERSION).not_to be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
GITMOJI_REF.to_a.each do |gitmoji|
|
9
|
+
it "matches #{gitmoji}" do
|
10
|
+
expect(gitmoji).to match(Gitmoji::Regex::REGEX)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "regex.rb source template" do
|
15
|
+
let(:template_file) { File.read(described_class::Reference::TEMPLATE_SRC) }
|
16
|
+
|
17
|
+
it "has the template token" do
|
18
|
+
expect(template_file).to include("REGEX = Regexp.new(\"% gitmojiRegex %\")")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
DEBUG = ENV["DEBUG"] == "true"
|
4
|
+
|
5
|
+
ruby_version = Gem::Version.new(RUBY_VERSION)
|
6
|
+
minimum_version = ->(version, engine = "ruby") { ruby_version >= Gem::Version.new(version) && RUBY_ENGINE == engine }
|
7
|
+
actual_version = lambda do |major, minor|
|
8
|
+
actual = Gem::Version.new(ruby_version)
|
9
|
+
major == actual.segments[0] && minor == actual.segments[1] && RUBY_ENGINE == "ruby"
|
10
|
+
end
|
11
|
+
debugging = minimum_version.call("2.7") && DEBUG
|
12
|
+
RUN_COVERAGE = minimum_version.call("2.6") && (ENV["COVER_ALL"] || ENV["CI_CODECOV"] || ENV["CI"].nil?)
|
13
|
+
ALL_FORMATTERS = actual_version.call(2, 7) && (ENV["COVER_ALL"] || ENV["CI_CODECOV"] || ENV["CI"])
|
14
|
+
|
15
|
+
if DEBUG
|
16
|
+
if debugging
|
17
|
+
require "byebug"
|
18
|
+
elsif minimum_version.call("2.7", "jruby")
|
19
|
+
require "pry-debugger-jruby"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require "simplecov" if RUN_COVERAGE
|
24
|
+
|
25
|
+
# This gem
|
26
|
+
require "gitmoji/regex"
|
27
|
+
|
28
|
+
# Not required by default, as it is not part of the gem's API, primarily for specs and maintainers
|
29
|
+
require "gitmoji/regex/reference"
|
30
|
+
|
31
|
+
# RSpec Configs
|
32
|
+
require "config/rspec/rspec_core"
|
33
|
+
|
34
|
+
# Support Files
|
35
|
+
|
36
|
+
GITMOJI_REF = Gitmoji::Regex::Reference.instance
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitmoji-regex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Boling
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.4.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.4.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: json
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 2.0.2
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.0.2
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rake
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '13.0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '13.0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '3.10'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '3.10'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec-benchmark
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.6'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0.6'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec-block_is_expected
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '1.0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: yard
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 0.9.20
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.9.20
|
123
|
+
description: A regular expression matching Gitmoji (a subset of Unicode Emoji) symbols
|
124
|
+
email:
|
125
|
+
- peter.boling@gmail.com
|
126
|
+
executables: []
|
127
|
+
extensions: []
|
128
|
+
extra_rdoc_files: []
|
129
|
+
files:
|
130
|
+
- CHANGELOG.md
|
131
|
+
- CODE_OF_CONDUCT.md
|
132
|
+
- CONTRIBUTING.md
|
133
|
+
- LICENSE.txt
|
134
|
+
- README.md
|
135
|
+
- SECURITY.md
|
136
|
+
- lib/gitmoji/regex.rb
|
137
|
+
- lib/gitmoji/regex/reference.rb
|
138
|
+
- lib/gitmoji/regex/version.rb
|
139
|
+
- spec/config/rspec/rspec_core.rb
|
140
|
+
- spec/gitmoji/regex/reference_spec.rb
|
141
|
+
- spec/gitmoji/regex_spec.rb
|
142
|
+
- spec/spec_helper.rb
|
143
|
+
homepage: https://github.com/pboling/gitmoji-regex
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata:
|
147
|
+
homepage_uri: https://github.com/pboling/gitmoji-regex
|
148
|
+
source_code_uri: https://github.com/pboling/gitmoji-regex/tree/v0.1.0
|
149
|
+
changelog_uri: https://github.com/pboling/gitmoji-regex/blob/v0.1.0/CHANGELOG.md
|
150
|
+
bug_tracker_uri: https://github.com/pboling/gitmoji-regex/issues
|
151
|
+
documentation_uri: https://www.rubydoc.info/gems/gitmoji-regex/0.1.0
|
152
|
+
wiki_uri: https://github.com/pboling/gitmoji-regex/wiki
|
153
|
+
rubygems_mfa_required: 'true'
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 2.4.0
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubygems_version: 3.3.10
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: A regular expression for Gitmoji symbols
|
173
|
+
test_files:
|
174
|
+
- spec/config/rspec/rspec_core.rb
|
175
|
+
- spec/gitmoji/regex/reference_spec.rb
|
176
|
+
- spec/gitmoji/regex_spec.rb
|
177
|
+
- spec/spec_helper.rb
|