emoji_clock 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 21e730deb39bd4fcb6464d4f00d224200ed5244417490a65e1158822883e748f
4
+ data.tar.gz: 476934e59a8807f375e805c16d299845f4a7a0b10472ca0b303b369c9cabbcba
5
+ SHA512:
6
+ metadata.gz: e4fbd64973b9336cf145fbbd3577968d484d8b86ec2c7b0259ac09c38528e3d732695a3348a858b685140fdd2309907bdc0c4c026dc44b6082a0f1ed6c243e36
7
+ data.tar.gz: 8d313e74328e13526370d05a428f726e13ee8fb9e5a00affc5b098815223f9bb096f7a6382f516282b8f64aa4021b2c67e41ef6dafde13e2ab8fb6a7b128d201
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -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 sh07e1916@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/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in emoji_clock.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ emoji_clock (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.5.0)
10
+ rake (13.0.6)
11
+ rspec (3.12.0)
12
+ rspec-core (~> 3.12.0)
13
+ rspec-expectations (~> 3.12.0)
14
+ rspec-mocks (~> 3.12.0)
15
+ rspec-core (3.12.2)
16
+ rspec-support (~> 3.12.0)
17
+ rspec-expectations (3.12.3)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.12.0)
20
+ rspec-mocks (3.12.5)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.12.0)
23
+ rspec-support (3.12.0)
24
+
25
+ PLATFORMS
26
+ x86_64-darwin-21
27
+
28
+ DEPENDENCIES
29
+ emoji_clock!
30
+ rake (~> 13.0)
31
+ rspec (~> 3.0)
32
+
33
+ BUNDLED WITH
34
+ 2.4.13
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 a5-stable
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,71 @@
1
+ # EmojiClock
2
+
3
+ Welcome to EmojiClock!
4
+ This is a cute little gem that will display the current time in (the nearest) emoji clock format.
5
+
6
+ ## Installation
7
+
8
+ Install the gem and add to the application's Gemfile by executing:
9
+
10
+ $ bundle add emoji_clock
11
+
12
+ If bundler is not being used to manage dependencies, install the gem by executing:
13
+
14
+ $ gem install emoji_clock
15
+
16
+ ## Usage
17
+
18
+ You can get the nearest emoji clock by calling the `EmojiClock.now` method.
19
+ ```
20
+ EmojiClock.now
21
+
22
+ # => "🕧"
23
+ ```
24
+
25
+ You can also get the emoji clock for a specific time by calling the `EmojiClock.at` method.
26
+ ```
27
+ time = Time.new(2021, 1, 1, 12, 30)
28
+ EmojiClock.at(time)
29
+
30
+ # => "🕧"
31
+ ```
32
+
33
+ Since there are no clock emojis for times other than 00 minutes and 30 minutes, EmojiClock will return the nearest emoji clock for such times.
34
+ ```
35
+ time = Time.new(2021, 1, 1, 12, 10)
36
+ EmojiClock.at(time)
37
+
38
+ # => "🕛"
39
+
40
+ time = Time.new(2021, 1, 1, 12, 50)
41
+ EmojiClock.at(time)
42
+
43
+ # => "🕐"
44
+ ```
45
+
46
+ If you want to get emoji only when the time is exactly on the hour or half hour, you can pass `:exact` as an option.
47
+ EmojiClock will return `nil` if the time is not exactly on the hour or half hour.
48
+ ```
49
+ time = Time.new(2021, 1, 1, 12, 10)
50
+ EmojiClock.at(time, exact: true)
51
+
52
+ # => nil
53
+ ```
54
+
55
+ ## Development
56
+
57
+ 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.
58
+
59
+ 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).
60
+
61
+ ## Contributing
62
+
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/emoji_clock. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/emoji_clock/blob/main/CODE_OF_CONDUCT.md).
64
+
65
+ ## License
66
+
67
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
68
+
69
+ ## Code of Conduct
70
+
71
+ Everyone interacting in the EmojiClock project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/emoji_clock/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/emoji_clock/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "emoji_clock"
7
+ spec.version = EmojiClock::VERSION
8
+ spec.authors = ["a5-stable"]
9
+ spec.email = ["sh07e1916@gmail.com"]
10
+
11
+ spec.summary = "Fetch emoji clock by given time."
12
+ spec.description = "emoji_clock is a gem that fetches emoji clock by given time. You can get emoji clock by using EmojiClock.at method."
13
+ spec.homepage = "https://github.com/a5-stable/emoji_clock"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/a5-stable/emoji_clock"
19
+ spec.metadata["changelog_uri"] = "https://github.com/a5-stable/emoji_clock/blob/master/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
@@ -0,0 +1,38 @@
1
+ module ClockVariety
2
+ EMOJI_CLOCK_CODE_POINT = 128336
3
+ ALARM_CLOCK = "\u{23F0}"
4
+ TIMER_CLOCK = "\u{23F2}"
5
+ WATCH_CLOCK = "\u{231A}"
6
+ STOP_WATCH_CLOCK = "\u{23F1}"
7
+ HOUR_GLASS_DONE = "\u{231B}"
8
+ HOUR_GLASS_UNDONE = "\u{23F3}"
9
+ MANTELPIECE_CLOCK = "\u{1F570}"
10
+
11
+ def alarm
12
+ ALARM_CLOCK
13
+ end
14
+
15
+ def timer
16
+ TIMER_CLOCK
17
+ end
18
+
19
+ def watch
20
+ WATCH_CLOCK
21
+ end
22
+
23
+ def stop_watch
24
+ STOP_WATCH_CLOCK
25
+ end
26
+
27
+ def hourglass_done
28
+ HOUR_GLASS_DONE
29
+ end
30
+
31
+ def hourglass_undone
32
+ HOUR_GLASS_UNDONE
33
+ end
34
+
35
+ def mantelpiece
36
+ MANTELPIECE_CLOCK
37
+ end
38
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class EmojiClockFetcher
4
+ EMOJI_CLOCK_CODE_POINT = 0x1F550
5
+
6
+ def initialize(hour, minute)
7
+ @hour = hour
8
+ @minute = minute
9
+ end
10
+
11
+ def fetch
12
+ code_point = EMOJI_CLOCK_CODE_POINT + hour_offset + minute_offset
13
+ [code_point].pack('U')
14
+ end
15
+
16
+ def exact_fetch
17
+ fetch if [0, 30].include?(@minute)
18
+ end
19
+
20
+ private
21
+
22
+ def hour_offset
23
+ h = @minute >= 45 ? @hour + 1 : @hour
24
+ ((h % 12).nonzero? || 12) - 1
25
+ end
26
+
27
+ def minute_offset
28
+ @minute >= 15 && @minute < 45 ? 12 : 0
29
+ end
30
+
31
+ end
@@ -0,0 +1,16 @@
1
+ class TimeParser
2
+ def self.parse(*args)
3
+ if args.size > 1
4
+ Time.new(*args)
5
+ else
6
+ case args.first
7
+ when Time
8
+ args.first
9
+ when String
10
+ Time.new(args.first)
11
+ when Integer
12
+ Time.at(args.first)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class EmojiClock
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "emoji_clock/version"
4
+ require_relative "emoji_clock/emoji_clock_fetcher"
5
+ require_relative "emoji_clock/clock_variety"
6
+ require_relative "emoji_clock/time_parser"
7
+
8
+ class EmojiClock
9
+ attr_reader :hour, :minute
10
+ extend ClockVariety
11
+
12
+ def initialize(hour, minute)
13
+ @hour = hour
14
+ @minute = minute
15
+ end
16
+
17
+ def fetch_emoji
18
+ fetcher.fetch
19
+ end
20
+
21
+ def fetch_exact_emoji
22
+ fetcher.exact_fetch
23
+ end
24
+
25
+ def self.now(exact: false)
26
+ at(Time.now, exact: exact)
27
+ end
28
+
29
+ def self.at(*args, exact: false)
30
+ time = TimeParser.parse(*args)
31
+ clock = new(time.hour, time.min)
32
+
33
+ exact ? clock.fetch_exact_emoji : clock.fetch_emoji
34
+ end
35
+
36
+ def fetcher
37
+ @fetcher ||= EmojiClockFetcher.new(hour, minute)
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ module EmojiClock
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emoji_clock
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - a5-stable
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: emoji_clock is a gem that fetches emoji clock by given time. You can
14
+ get emoji clock by using EmojiClock.at method.
15
+ email:
16
+ - sh07e1916@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - emoji_clock.gemspec
29
+ - lib/emoji_clock.rb
30
+ - lib/emoji_clock/clock_variety.rb
31
+ - lib/emoji_clock/emoji_clock_fetcher.rb
32
+ - lib/emoji_clock/time_parser.rb
33
+ - lib/emoji_clock/version.rb
34
+ - sig/emoji_clock.rbs
35
+ homepage: https://github.com/a5-stable/emoji_clock
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ homepage_uri: https://github.com/a5-stable/emoji_clock
40
+ source_code_uri: https://github.com/a5-stable/emoji_clock
41
+ changelog_uri: https://github.com/a5-stable/emoji_clock/blob/master/CHANGELOG.md
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.6.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.0.3.1
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Fetch emoji clock by given time.
61
+ test_files: []