tsukimoji 0.1.1

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 (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +48 -0
  4. data/lib/tsukimoji.rb +64 -0
  5. metadata +49 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8cbd8314413fd0da84dc2e71d44c30a20c12b3490e2096f3217d6a1082f71e4a
4
+ data.tar.gz: a386a3203c772550e91df4b5edf1e80e69a8d060a886a3d7a2891c2ef1ccd0ab
5
+ SHA512:
6
+ metadata.gz: 4490a686543b5a04c11a20c87a1fc41b724299d74bf1adfdc42e29aae2f5d88816ddb61ccad38d20efc699bc1a86b48f35d01d19981d1e594d786922d5add44e
7
+ data.tar.gz: 58c0905adba6d2f789d828b1878faecfacb964edf00100cfa5b80efd40a001edf235a4b705f6b74901ee84077a00f61dde2e3ff504ef23e0778463154879fc63
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sam Lehman
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # tsukiMOJi
2
+
3
+ Moon phase emoji for any date. 月 (tsuki, "moon") + moji, as in emoji.
4
+
5
+ ```ruby
6
+ require "tsukimoji"
7
+
8
+ phase = Tsukimoji.phase
9
+ phase.emoji # => "πŸŒ”"
10
+ phase.name # => "Waxing Gibbous"
11
+ phase.age_days # => 12.3
12
+ phase.illumination # => 0.87
13
+
14
+ Tsukimoji.emoji # just the emoji, for "now"
15
+ Tsukimoji.phase(Time.utc(2026, 1, 1)) # phase for any specific time
16
+ ```
17
+
18
+ ## Installation
19
+
20
+ ```
21
+ gem install tsukimoji
22
+ ```
23
+
24
+ Or add to your Gemfile:
25
+
26
+ ```ruby
27
+ gem "tsukimoji"
28
+ ```
29
+
30
+ ## How it works
31
+
32
+ tsukiMOJi measures elapsed time since a known new moon (2000-01-06
33
+ 18:14 UTC) against the synodic month (29.530588853 days) to find how far
34
+ into the current lunar cycle a given moment falls, then maps that
35
+ fraction onto the eight standard moon-phase emoji (πŸŒ‘πŸŒ’πŸŒ“πŸŒ”πŸŒ•πŸŒ–πŸŒ—πŸŒ˜).
36
+ Illumination is derived separately from the same cycle position via a
37
+ cosine curve, for display purposes.
38
+
39
+ ## License
40
+
41
+ MIT
42
+
43
+ ---
44
+
45
+ <p align="center">
46
+ <img src="https://raw.githubusercontent.com/samlehman/tsukimoji/main/made-in-baltimore.png" alt="Made in Baltimore" width="88" align="middle">
47
+ &nbsp;&nbsp;β˜• <a href="https://paypal.me/samlehman">Buy me a coffee</a> Β· <a href="https://paypal.me/samlehman">γ“γƒΌγ²γƒΌγ‚’γŠγ”γ£γ¦</a>
48
+ </p>
data/lib/tsukimoji.rb ADDED
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "time"
4
+
5
+ # tsukiMOJi ("moon" + "moji", as in emoji) computes the current lunar
6
+ # phase for any date and returns the matching emoji, phase name, age in
7
+ # days, and illumination fraction.
8
+ #
9
+ # Ported from the original moon-phase.html JavaScript prototype.
10
+ module Tsukimoji
11
+ SYNODIC_MONTH_DAYS = 29.530588853
12
+ SYNODIC_MONTH_SECONDS = SYNODIC_MONTH_DAYS * 24 * 60 * 60
13
+
14
+ # A known new moon reference point: 2000-01-06 18:14 UTC.
15
+ KNOWN_NEW_MOON = Time.utc(2000, 1, 6, 18, 14, 0)
16
+
17
+ PHASES = [
18
+ { emoji: "\u{1F311}", name: "New Moon" },
19
+ { emoji: "\u{1F312}", name: "Waxing Crescent" },
20
+ { emoji: "\u{1F313}", name: "First Quarter" },
21
+ { emoji: "\u{1F314}", name: "Waxing Gibbous" },
22
+ { emoji: "\u{1F315}", name: "Full Moon" },
23
+ { emoji: "\u{1F316}", name: "Waning Gibbous" },
24
+ { emoji: "\u{1F317}", name: "Last Quarter" },
25
+ { emoji: "\u{1F318}", name: "Waning Crescent" },
26
+ ].freeze
27
+
28
+ # Immutable result of a phase calculation.
29
+ Phase = Struct.new(:emoji, :name, :age_days, :illumination, keyword_init: true) do
30
+ def to_s
31
+ emoji
32
+ end
33
+ end
34
+
35
+ class << self
36
+ # Returns a Tsukimoji::Phase for the given time (defaults to now, UTC).
37
+ def phase(time = Time.now.utc)
38
+ time = time.utc
39
+ elapsed_seconds = time.to_f - KNOWN_NEW_MOON.to_f
40
+ cycles = elapsed_seconds / SYNODIC_MONTH_SECONDS
41
+ age = ((cycles % 1) + 1) % 1
42
+ index = ((age + 1.0 / 16) * 8).floor % 8
43
+ illumination = (1 - Math.cos(age * 2 * Math::PI)) / 2
44
+
45
+ data = PHASES[index]
46
+ Phase.new(
47
+ emoji: data[:emoji],
48
+ name: data[:name],
49
+ age_days: age * SYNODIC_MONTH_DAYS,
50
+ illumination: illumination
51
+ )
52
+ end
53
+
54
+ # Convenience shortcut: just the emoji for the given time.
55
+ def emoji(time = Time.now.utc)
56
+ phase(time).emoji
57
+ end
58
+
59
+ # Convenience shortcut: just the phase name for the given time.
60
+ def name(time = Time.now.utc)
61
+ phase(time).name
62
+ end
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tsukimoji
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Sam Lehman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-10-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: tsukiMOJi computes the current (or any) lunar phase and returns the matching
14
+ emoji, phase name, age in days, and illumination fraction.
15
+ email:
16
+ - sam@bmore.md
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/tsukimoji.rb
24
+ homepage: https://github.com/samlehman/tsukimoji
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://github.com/samlehman/tsukimoji
29
+ source_code_uri: https://github.com/samlehman/tsukimoji
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '2.7'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.5.22
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Moon phase emoji for any date
49
+ test_files: []