zodiacly 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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +8 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/bin/zodiacly +81 -0
- data/lib/zodiacly/ephemeris.rb +160 -0
- data/lib/zodiacly/horizons_client.rb +80 -0
- data/lib/zodiacly/version.rb +5 -0
- data/lib/zodiacly/zodiac.rb +16 -0
- data/lib/zodiacly.rb +10 -0
- data/sig/zodiacly.rbs +4 -0
- metadata +119 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bf95987853a81cb2bbc612f3580472085897800b805ce50cdc8afe9198f29f08
|
|
4
|
+
data.tar.gz: d0bfaec6acc6a54eaae7d7eceee401b69a7f705ab965d2955ed1ba65529dece5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0b8937ad9d47996c5bb2622bf1cbaa3178f7750f359e0509aee1084c82e7ccf38591a38cef5e7348d550b6e087181f451f3dbb88dcfb6eaf8c6c5d7585faf77c
|
|
7
|
+
data.tar.gz: 41c40976e3ff326808fd4368d77dd801fe877b79d3f04c4f67f14dcee2d4876f587ec25c9a0e23131211304aec6e8abaff45abf2faf060d76f80ecf3a99001d2
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
"zodiacly" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
|
|
4
|
+
|
|
5
|
+
* Participants will be tolerant of opposing views.
|
|
6
|
+
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
|
|
7
|
+
* When interpreting the words and actions of others, participants should always assume good intentions.
|
|
8
|
+
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
|
9
|
+
|
|
10
|
+
If you have any concerns about behaviour within this project, please contact us at ["milorad.gojkovic@t-mobile.cz"](mailto:"milorad.gojkovic@t-mobile.cz").
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Milorad Gojkovic
|
|
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,43 @@
|
|
|
1
|
+
# Zodiacly
|
|
2
|
+
|
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
|
4
|
+
|
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/zodiacly`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
|
10
|
+
|
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
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).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/zodiacly. 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]/zodiacly/blob/master/CODE_OF_CONDUCT.md).
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
40
|
+
|
|
41
|
+
## Code of Conduct
|
|
42
|
+
|
|
43
|
+
Everyone interacting in the Zodiacly project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/zodiacly/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "zodiacly"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
require "irb"
|
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/zodiacly
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "optparse"
|
|
5
|
+
require "time"
|
|
6
|
+
require "pp"
|
|
7
|
+
require_relative "../lib/zodiacly"
|
|
8
|
+
|
|
9
|
+
options = {
|
|
10
|
+
time: Time.now.utc,
|
|
11
|
+
bodies: :all
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
parser = OptionParser.new do |opts|
|
|
15
|
+
opts.banner = <<~BANNER
|
|
16
|
+
Usage: zodiacly ephemeris [options]
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
zodiacly ephemeris --bodies all
|
|
20
|
+
BANNER
|
|
21
|
+
|
|
22
|
+
opts.on("-t", "--time TIME", "UTC time (ISO8601, e.g. 2026-02-07T00:00:00Z or 'now')") do |v|
|
|
23
|
+
options[:time] =
|
|
24
|
+
if v.to_s.strip.downcase == "now"
|
|
25
|
+
Time.now.utc
|
|
26
|
+
else
|
|
27
|
+
Time.parse(v).utc
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
opts.on("-b", "--bodies LIST", "sun,moon,mars or all") do |v|
|
|
32
|
+
val = v.to_s.strip.downcase
|
|
33
|
+
options[:bodies] =
|
|
34
|
+
if val == "all"
|
|
35
|
+
:all
|
|
36
|
+
else
|
|
37
|
+
val.split(",").map { |s| s.strip.to_sym }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
opts.on("-v", "--version", "Show version") { puts Zodiacly::VERSION; exit }
|
|
42
|
+
opts.on("-h", "--help", "Show help") { puts opts; exit }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
original_argv = ARGV.dup
|
|
46
|
+
|
|
47
|
+
begin
|
|
48
|
+
parser.order!(ARGV)
|
|
49
|
+
|
|
50
|
+
# If no args at all, show help (keep old behavior).
|
|
51
|
+
if original_argv.empty?
|
|
52
|
+
puts parser
|
|
53
|
+
exit 0
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Optional subcommand; default to ephemeris if omitted.
|
|
57
|
+
cmd = (ARGV.first == "ephemeris") ? ARGV.shift : "ephemeris"
|
|
58
|
+
|
|
59
|
+
parser.parse!(ARGV)
|
|
60
|
+
rescue OptionParser::ParseError => e
|
|
61
|
+
warn "Error: #{e.message}"
|
|
62
|
+
warn
|
|
63
|
+
warn parser.to_s
|
|
64
|
+
exit 1
|
|
65
|
+
rescue ArgumentError => e
|
|
66
|
+
warn "Error: #{e.message}"
|
|
67
|
+
warn
|
|
68
|
+
warn "Tip: use ISO8601 like 2026-02-07T00:00:00Z or 'now'."
|
|
69
|
+
warn
|
|
70
|
+
warn parser.to_s
|
|
71
|
+
exit 1
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if cmd == "ephemeris"
|
|
75
|
+
pp Zodiacly::Ephemeris.at(options[:time], bodies: options[:bodies])
|
|
76
|
+
else
|
|
77
|
+
warn "Unknown command: #{cmd}"
|
|
78
|
+
warn
|
|
79
|
+
puts parser
|
|
80
|
+
exit 1
|
|
81
|
+
end
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "time"
|
|
4
|
+
require_relative "zodiac"
|
|
5
|
+
require_relative "horizons_client"
|
|
6
|
+
require "json"
|
|
7
|
+
require "digest"
|
|
8
|
+
require "fileutils"
|
|
9
|
+
require "tmpdir"
|
|
10
|
+
|
|
11
|
+
module Zodiacly
|
|
12
|
+
class Ephemeris
|
|
13
|
+
# Horizons target IDs (common major bodies)
|
|
14
|
+
BODY_TO_COMMAND = {
|
|
15
|
+
sun: "10",
|
|
16
|
+
moon: "301",
|
|
17
|
+
mercury: "199",
|
|
18
|
+
venus: "299",
|
|
19
|
+
mars: "499",
|
|
20
|
+
jupiter: "599",
|
|
21
|
+
saturn: "699",
|
|
22
|
+
uranus: "799",
|
|
23
|
+
neptune: "899",
|
|
24
|
+
pluto: "999"
|
|
25
|
+
}.freeze
|
|
26
|
+
|
|
27
|
+
DEFAULT_BODIES = %i[sun moon].freeze
|
|
28
|
+
|
|
29
|
+
# Public API: Zodiacly::Ephemeris.at(time, bodies:)
|
|
30
|
+
#
|
|
31
|
+
# bodies:
|
|
32
|
+
# - Array of symbols (e.g. %i[sun moon mars])
|
|
33
|
+
# - :all (for all supported major bodies)
|
|
34
|
+
#
|
|
35
|
+
# cache_ttl:
|
|
36
|
+
# - seconds to keep cached results (default: 3600)
|
|
37
|
+
def self.at(time_utc = Time.now.utc, center: "500@399", bodies: DEFAULT_BODIES, cache_ttl: 3600)
|
|
38
|
+
time = Time.parse(time_utc.to_s).utc
|
|
39
|
+
iso = time.iso8601
|
|
40
|
+
|
|
41
|
+
bodies =
|
|
42
|
+
if bodies == :all
|
|
43
|
+
%i[
|
|
44
|
+
sun moon mercury venus mars
|
|
45
|
+
jupiter saturn uranus neptune pluto
|
|
46
|
+
]
|
|
47
|
+
else
|
|
48
|
+
Array(bodies).map(&:to_sym)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
cache_key = Digest::SHA256.hexdigest([
|
|
52
|
+
iso,
|
|
53
|
+
center,
|
|
54
|
+
bodies.sort.join(",")
|
|
55
|
+
].join("|"))
|
|
56
|
+
|
|
57
|
+
cache_fetch(cache_key, cache_ttl) do
|
|
58
|
+
results = {}
|
|
59
|
+
|
|
60
|
+
bodies.each do |body|
|
|
61
|
+
command = BODY_TO_COMMAND.fetch(body) do
|
|
62
|
+
raise Zodiacly::Error, "Unknown body: #{body.inspect}. Known: #{BODY_TO_COMMAND.keys.join(", ")}"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
json = Zodiacly::Horizons.vectors(command: command, center: center, time_utc: iso)
|
|
66
|
+
vec = parse_vectors(json)
|
|
67
|
+
|
|
68
|
+
lon = ecliptic_longitude_deg(vec[:x], vec[:y])
|
|
69
|
+
speed = ecliptic_longitude_speed_deg_per_day(vec[:x], vec[:y], vec[:vx], vec[:vy])
|
|
70
|
+
|
|
71
|
+
results[body] = {
|
|
72
|
+
lon: lon.round(2),
|
|
73
|
+
sign: Zodiacly::Zodiac.sign_for_lon(lon),
|
|
74
|
+
retrograde: speed.negative?,
|
|
75
|
+
speed: speed.round(4)
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
time_utc: iso,
|
|
81
|
+
center: center,
|
|
82
|
+
bodies: results
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# ---- Parsing ----
|
|
88
|
+
|
|
89
|
+
# Horizons JSON has a "result" string which contains a table between $$SOE and $$EOE.
|
|
90
|
+
# With CSV_FORMAT=YES and VEC_TABLE=2, each row is CSV and includes x,y,z,vx,vy,vz.
|
|
91
|
+
def self.parse_vectors(json)
|
|
92
|
+
result = json.fetch("result") { raise Zodiacly::Error, "Horizons response missing 'result' key" }
|
|
93
|
+
|
|
94
|
+
line = extract_soe_line(result)
|
|
95
|
+
parts = line.split(",").map(&:strip)
|
|
96
|
+
|
|
97
|
+
# We expect the last 6 CSV columns to be numeric x,y,z,vx,vy,vz (in km and km/s typically)
|
|
98
|
+
nums = parts.last(6).map { |v| Float(v) }
|
|
99
|
+
|
|
100
|
+
{
|
|
101
|
+
x: nums[0],
|
|
102
|
+
y: nums[1],
|
|
103
|
+
z: nums[2],
|
|
104
|
+
vx: nums[3],
|
|
105
|
+
vy: nums[4],
|
|
106
|
+
vz: nums[5]
|
|
107
|
+
}
|
|
108
|
+
rescue KeyError, ArgumentError => e
|
|
109
|
+
raise Zodiacly::Error, "Failed to parse Horizons vectors: #{e.message}"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def self.extract_soe_line(result_text)
|
|
113
|
+
start_idx = result_text.index("$$SOE")
|
|
114
|
+
stop_idx = result_text.index("$$EOE")
|
|
115
|
+
raise Zodiacly::Error, "Horizons result missing $$SOE/$$EOE markers" unless start_idx && stop_idx
|
|
116
|
+
|
|
117
|
+
block = result_text[(start_idx + 5)...stop_idx].strip
|
|
118
|
+
# Take the first non-empty line
|
|
119
|
+
line = block.lines.map(&:strip).find { |l| !l.empty? }
|
|
120
|
+
raise Zodiacly::Error, "Horizons SOE block was empty" unless line
|
|
121
|
+
line
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# ---- Math ----
|
|
125
|
+
|
|
126
|
+
def self.ecliptic_longitude_deg(x, y)
|
|
127
|
+
rad = Math.atan2(y, x)
|
|
128
|
+
deg = rad * 180.0 / Math::PI
|
|
129
|
+
deg %= 360.0
|
|
130
|
+
deg += 360.0 if deg.negative?
|
|
131
|
+
deg
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Angular speed of longitude using planar angular velocity:
|
|
135
|
+
# omega = (x*vy - y*vx) / (x^2 + y^2) [rad/s]
|
|
136
|
+
# convert to deg/day
|
|
137
|
+
def self.ecliptic_longitude_speed_deg_per_day(x, y, vx, vy)
|
|
138
|
+
r2 = (x * x) + (y * y)
|
|
139
|
+
return 0.0 if r2.zero?
|
|
140
|
+
|
|
141
|
+
omega = (x * vy - y * vx) / r2 # rad / s
|
|
142
|
+
omega * (180.0 / Math::PI) * 86_400.0
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.cache_fetch(key, ttl)
|
|
146
|
+
dir = File.join(Dir.tmpdir, "zodiacly-cache")
|
|
147
|
+
FileUtils.mkdir_p(dir)
|
|
148
|
+
|
|
149
|
+
path = File.join(dir, "#{key}.json")
|
|
150
|
+
|
|
151
|
+
if File.exist?(path) && (Time.now - File.mtime(path) < ttl)
|
|
152
|
+
return JSON.parse(File.read(path), symbolize_names: true)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
data = yield
|
|
156
|
+
File.write(path, JSON.pretty_generate(data))
|
|
157
|
+
data
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "time"
|
|
4
|
+
require "csv"
|
|
5
|
+
require "httparty"
|
|
6
|
+
|
|
7
|
+
module Zodiacly
|
|
8
|
+
# Minimal wrapper for NASA/JPL Horizons API.
|
|
9
|
+
# Docs: https://ssd-api.jpl.nasa.gov/doc/horizons.html
|
|
10
|
+
class HorizonsClient
|
|
11
|
+
include HTTParty
|
|
12
|
+
base_uri "https://ssd.jpl.nasa.gov/api"
|
|
13
|
+
|
|
14
|
+
DEFAULTS = {
|
|
15
|
+
"format" => "json",
|
|
16
|
+
"MAKE_EPHEM" => "'YES'",
|
|
17
|
+
"OBJ_DATA" => "'NO'"
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
20
|
+
def fetch(params)
|
|
21
|
+
res = self.class.get("/horizons.api", query: DEFAULTS.merge(params))
|
|
22
|
+
unless res.success?
|
|
23
|
+
raise Zodiacly::Error, "Horizons HTTP #{res.code}: #{res.body.to_s[0..300]}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
json = res.parsed_response
|
|
27
|
+
if json.is_a?(Hash) && json["error"]
|
|
28
|
+
raise Zodiacly::Error, "Horizons error: #{json["error"]}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
json
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Fetch vectors (position+velocity) in the ecliptic plane for a single instant.
|
|
35
|
+
#
|
|
36
|
+
# Returns the full JSON payload; the ephemeris text is inside json["result"].
|
|
37
|
+
def vectors(command:, center:, time_utc:)
|
|
38
|
+
# Horizons is picky about timestamp formats. Using START/STOP with a short window
|
|
39
|
+
# avoids TLIST parsing issues with ISO8601 "T...Z".
|
|
40
|
+
start_t = ensure_utc_horizons(time_utc)
|
|
41
|
+
stop_t = ensure_utc_horizons(Time.parse(time_utc.to_s).utc + 60) # +60s
|
|
42
|
+
|
|
43
|
+
fetch(
|
|
44
|
+
"COMMAND" => "'#{command}'",
|
|
45
|
+
"CENTER" => "'#{center}'",
|
|
46
|
+
"EPHEM_TYPE" => "'VECTORS'",
|
|
47
|
+
"REF_PLANE" => "'ECLIPTIC'",
|
|
48
|
+
"CSV_FORMAT" => "'YES'",
|
|
49
|
+
"VEC_TABLE" => "'2'",
|
|
50
|
+
"START_TIME" => "'#{start_t}'",
|
|
51
|
+
"STOP_TIME" => "'#{stop_t}'",
|
|
52
|
+
"STEP_SIZE" => "'1 m'"
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def ensure_utc_horizons(time_utc)
|
|
59
|
+
# Example acceptable format: "2026-02-07 19:53:27"
|
|
60
|
+
Time.parse(time_utc.to_s).utc.strftime("%Y-%m-%d %H:%M:%S")
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Convenience module wrapper, as requested: Zodiacly::Horizons.fetch(...)
|
|
65
|
+
module Horizons
|
|
66
|
+
module_function
|
|
67
|
+
|
|
68
|
+
def client
|
|
69
|
+
@client ||= HorizonsClient.new
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def fetch(params)
|
|
73
|
+
client.fetch(params)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def vectors(command:, center:, time_utc:)
|
|
77
|
+
client.vectors(command: command, center: center, time_utc: time_utc)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zodiacly
|
|
4
|
+
module Zodiac
|
|
5
|
+
SIGNS = %i[
|
|
6
|
+
aries taurus gemini cancer leo virgo
|
|
7
|
+
libra scorpio sagittarius capricorn aquarius pisces
|
|
8
|
+
].freeze
|
|
9
|
+
|
|
10
|
+
def self.sign_for_lon(lon)
|
|
11
|
+
lon = lon % 360.0
|
|
12
|
+
index = (lon / 30.0).floor
|
|
13
|
+
SIGNS[index]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/zodiacly.rb
ADDED
data/sig/zodiacly.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: zodiacly
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Gojko
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-02-07 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: httparty
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0.21'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0.21'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: csv
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.3'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.3'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rake
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '13.0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '13.0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rspec
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '3.10'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.10'
|
|
68
|
+
description: Zodiacly is a small Ruby library that fetches public NASA/JPL Horizons
|
|
69
|
+
ephemeris data and converts it into astrology-friendly output (ecliptic longitude,
|
|
70
|
+
zodiac sign, retrograde flag, and simple speed estimates) for common bodies like
|
|
71
|
+
Sun and Moon. Designed for server-side use with caching.
|
|
72
|
+
email:
|
|
73
|
+
- gojko1980@gmail.com
|
|
74
|
+
executables:
|
|
75
|
+
- zodiacly
|
|
76
|
+
extensions: []
|
|
77
|
+
extra_rdoc_files: []
|
|
78
|
+
files:
|
|
79
|
+
- CHANGELOG.md
|
|
80
|
+
- CODE_OF_CONDUCT.md
|
|
81
|
+
- LICENSE.txt
|
|
82
|
+
- README.md
|
|
83
|
+
- Rakefile
|
|
84
|
+
- bin/console
|
|
85
|
+
- bin/setup
|
|
86
|
+
- bin/zodiacly
|
|
87
|
+
- lib/zodiacly.rb
|
|
88
|
+
- lib/zodiacly/ephemeris.rb
|
|
89
|
+
- lib/zodiacly/horizons_client.rb
|
|
90
|
+
- lib/zodiacly/version.rb
|
|
91
|
+
- lib/zodiacly/zodiac.rb
|
|
92
|
+
- sig/zodiacly.rbs
|
|
93
|
+
homepage: https://zodiacly.app
|
|
94
|
+
licenses:
|
|
95
|
+
- MIT
|
|
96
|
+
metadata:
|
|
97
|
+
allowed_push_host: https://rubygems.org
|
|
98
|
+
homepage_uri: https://zodiacly.app
|
|
99
|
+
source_code_uri: https://zodiacly.app
|
|
100
|
+
changelog_uri: https://zodiacly.app/changelog
|
|
101
|
+
rdoc_options: []
|
|
102
|
+
require_paths:
|
|
103
|
+
- lib
|
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: 3.2.0
|
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0'
|
|
114
|
+
requirements: []
|
|
115
|
+
rubygems_version: 3.6.2
|
|
116
|
+
specification_version: 4
|
|
117
|
+
summary: Ruby helper for fetching NASA/JPL ephemeris data and formatting astrology-friendly
|
|
118
|
+
planetary positions.
|
|
119
|
+
test_files: []
|