tsukimoji 0.1.1 β†’ 0.1.2

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +51 -48
  3. data/lib/tsukimoji.rb +68 -64
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cbd8314413fd0da84dc2e71d44c30a20c12b3490e2096f3217d6a1082f71e4a
4
- data.tar.gz: a386a3203c772550e91df4b5edf1e80e69a8d060a886a3d7a2891c2ef1ccd0ab
3
+ metadata.gz: db5da3254050bfb603c97f5c55a0c990d8c49676af3df8baf054a08b6b83c08d
4
+ data.tar.gz: e7824f345eb8a39f1002363a05bc6ef9470be1f82b431f07cdbdd93ecc0c2e9c
5
5
  SHA512:
6
- metadata.gz: 4490a686543b5a04c11a20c87a1fc41b724299d74bf1adfdc42e29aae2f5d88816ddb61ccad38d20efc699bc1a86b48f35d01d19981d1e594d786922d5add44e
7
- data.tar.gz: 58c0905adba6d2f789d828b1878faecfacb964edf00100cfa5b80efd40a001edf235a4b705f6b74901ee84077a00f61dde2e3ff504ef23e0778463154879fc63
6
+ metadata.gz: bd030575b8e4e7a7908a58ff44ad95fd903c8e9ec1d1e404889a094b1b591f4f3f22f8a3f4ee40dc2d5211e01a60745a665fa210b205cdeba20f5725cba37cdb
7
+ data.tar.gz: ac14edf172c6166962bd112a0b8e64f35c6c4a31da149599ed47c4dcffd56f2fdca81de3f0a989d558b32af8b8f9f154fcdf7ec243172be545edd3aaf3149866
data/README.md CHANGED
@@ -1,48 +1,51 @@
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>
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
+ # Moon faces: 🌚 for New Moon and 🌝 for Full Moon
18
+ Tsukimoji.emoji(Time.utc(2026, 10, 26, 4), faces: true) # => "🌝"
19
+ ```
20
+
21
+ ## Installation
22
+
23
+ ```
24
+ gem install tsukimoji
25
+ ```
26
+
27
+ Or add to your Gemfile:
28
+
29
+ ```ruby
30
+ gem "tsukimoji"
31
+ ```
32
+
33
+ ## How it works
34
+
35
+ tsukiMOJi measures elapsed time since a known new moon (2000-01-06
36
+ 18:14 UTC) against the synodic month (29.530588853 days) to find how far
37
+ into the current lunar cycle a given moment falls, then maps that
38
+ fraction onto the eight standard moon-phase emoji (πŸŒ‘πŸŒ’πŸŒ“πŸŒ”πŸŒ•πŸŒ–πŸŒ—πŸŒ˜).
39
+ Illumination is derived separately from the same cycle position via a
40
+ cosine curve, for display purposes.
41
+
42
+ ## License
43
+
44
+ MIT
45
+
46
+ ---
47
+
48
+ <p align="center">
49
+ <img src="https://raw.githubusercontent.com/samlehman/tsukimoji/main/made-in-baltimore.png" alt="Made in Baltimore" width="88" align="middle">
50
+ &nbsp;&nbsp;β˜• <a href="https://paypal.me/samlehman">Buy me a coffee</a> Β· <a href="https://paypal.me/samlehman">γ“γƒΌγ²γƒΌγ‚’γŠγ”γ£γ¦</a>
51
+ </p>
data/lib/tsukimoji.rb CHANGED
@@ -1,64 +1,68 @@
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
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
+ # Optional face emoji, by phase index: 🌚 for New Moon, 🌝 for Full Moon.
29
+ FACES = { 0 => "\u{1F31A}", 4 => "\u{1F31D}" }.freeze
30
+
31
+ # Immutable result of a phase calculation.
32
+ Phase = Struct.new(:emoji, :name, :age_days, :illumination, keyword_init: true) do
33
+ def to_s
34
+ emoji
35
+ end
36
+ end
37
+
38
+ class << self
39
+ # Returns a Tsukimoji::Phase for the given time (defaults to now, UTC).
40
+ # Pass faces: true to get 🌚 and 🌝 for new and full moons.
41
+ def phase(time = Time.now.utc, faces: false)
42
+ time = time.utc
43
+ elapsed_seconds = time.to_f - KNOWN_NEW_MOON.to_f
44
+ cycles = elapsed_seconds / SYNODIC_MONTH_SECONDS
45
+ age = ((cycles % 1) + 1) % 1
46
+ index = ((age + 1.0 / 16) * 8).floor % 8
47
+ illumination = (1 - Math.cos(age * 2 * Math::PI)) / 2
48
+
49
+ data = PHASES[index]
50
+ Phase.new(
51
+ emoji: (faces && FACES[index]) || data[:emoji],
52
+ name: data[:name],
53
+ age_days: age * SYNODIC_MONTH_DAYS,
54
+ illumination: illumination
55
+ )
56
+ end
57
+
58
+ # Convenience shortcut: just the emoji for the given time.
59
+ def emoji(time = Time.now.utc, faces: false)
60
+ phase(time, faces: faces).emoji
61
+ end
62
+
63
+ # Convenience shortcut: just the phase name for the given time.
64
+ def name(time = Time.now.utc)
65
+ phase(time).name
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tsukimoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Lehman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-02 00:00:00.000000000 Z
11
+ date: 2026-10-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: tsukiMOJi computes the current (or any) lunar phase and returns the matching
14
14
  emoji, phase name, age in days, and illumination fraction.