repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/test/plugins/after_test.rb | test/plugins/after_test.rb | require_relative '../helper'
class AfterTestObject
include Roy
roy use: [:after], allow: [:get],
after: lambda { |response|
response.header['Content-Type'] = 'text/plain'
}
def get _
'success'
end
end
class AfterTest < MiniTest::Unit::TestCase
include Rack::Test::Methods
def app... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/test/plugins/plugins_test.rb | test/plugins/plugins_test.rb | require_relative '../helper'
require 'roy/before'
class PluginsTestObject
include Roy
roy use: [Before, :after], allow: [:get],
before: lambda { |env|
env['REQUEST_METHOD'] = 'GET'
},
after: lambda { |response|
response.header['Content-Type'] = 'text/plain'
}
def get(pat... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/test/plugins/render_test.rb | test/plugins/render_test.rb | require_relative '../helper'
Templates = {
simple: %q(<%= "Hello world!" %>),
locals: %q(<%= "Hello #{person}" %>),
scope: %q(<%= roy.conf.inspect %>),
yield: %q(<%= yield %>)
}
class RenderTestObject
include Roy
roy allow: [:get],
views: 'test/views',
use: [:render]
def get(path)
ca... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/test/plugins/before_test.rb | test/plugins/before_test.rb | require_relative '../helper'
class BeforeTestObject
include Roy
roy use: [:before], allow: [:get],
before: lambda { |env|
env['REQUEST_METHOD'] = 'GET'
}
def get(path)
'success'
end
end
class BeforeTest < MiniTest::Unit::TestCase
include Rack::Test::Methods
def app
BeforeTes... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy.rb | lib/roy.rb | require 'roy/base'
| ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/version.rb | lib/roy/version.rb | module Roy
# Roy version
VERSION = [0, 5, 3]
# Return the version as a String.
def self.version
VERSION.join('.')
end
end
| ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/halt.rb | lib/roy/halt.rb | module Roy
# This module adds a +halt+ method to the application context that allows you
# to break during a handler and immediately return a status code and a body.
#
# Included by default.
#
# @example A Not Found application
#
# class NotFoundApp
# include Roy
#
# def get(_)
# ... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/before.rb | lib/roy/before.rb | module Roy
# This module allows you to modify the environment before it is handled by the
# application. It does this by overriding the {Roy#call} method.
#
# == Configuration:
# roy.conf.before::
# A proc object that will be called with the environment as argument.
# Defaults to identity if not set.
... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/basic_auth.rb | lib/roy/basic_auth.rb | module Roy
# This module provides helpers for using the HTTP basic authentication system.
#
# == Configuration:
# roy.conf.auth [:realm]::
# The authentication realm to use.
# roy.conf.auth [:logic]::
# A proc that checks if an user is authorized. See #authorized? in
# InstanceMethods.
#
# @ex... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/render.rb | lib/roy/render.rb | require 'tilt'
module Roy
# A simple template rendering mechanism based on Tilt.
#
# == Configuration:
# roy.conf.render::
# A hash of options to pass to Tilt.
# roy.conf.views::
# The directory where views are kept. Defaults to +views/+
#
# @example Using <tt>roy.render</tt>
#
# class ErbA... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/base.rb | lib/roy/base.rb | # external dependencies
require 'rack'
# stdlib dependencies
require 'set'
require 'ostruct'
# local dependencies
require 'roy/version'
require 'roy/context'
# This is the main module that applications should include.
module Roy
# Default options.
Defaults = {allow: [:get], prefix: :'', use: [:halt]}
# Exten... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/after.rb | lib/roy/after.rb | module Roy
# This module allows you to modify the response before it is sent to the
# client. It does this by overriding the {Roy#call} method.
#
# == Configuration:
# roy.conf.after::
# A proc object that will be called with the response as argument.
# Defaults to identity if not set.
#
# @exampl... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
madx/roy | https://github.com/madx/roy/blob/7f9d96b146c15c7b2d3f4019a8a2078475983186/lib/roy/context.rb | lib/roy/context.rb | module Roy
# Application context for Roy applications.
#
# Everything must be namespaced in this context to avoid any clashes and to
# make the code cleaner.
class Context
# Returns the current application
attr_reader :app
# Returns the application's configuration
attr_reader :conf
# Ret... | ruby | MIT | 7f9d96b146c15c7b2d3f4019a8a2078475983186 | 2026-01-04T17:45:03.561436Z | false |
larskanis/pg-ldap-sync | https://github.com/larskanis/pg-ldap-sync/blob/d1d913ad4ed96c92c34d9a2d6a41559227c3cf17/test/ldap_server.rb | test/ldap_server.rb | #!/usr/local/bin/ruby -w
# This is a trivial LDAP server which just stores directory entries in RAM.
# It does no validation or authentication. This is intended just to
# demonstrate the API, it's not for real-world use!!
require "rubygems"
require "ldap/server"
# We subclass the Operation class, overriding the meth... | ruby | MIT | d1d913ad4ed96c92c34d9a2d6a41559227c3cf17 | 2026-01-04T17:45:02.165437Z | false |
larskanis/pg-ldap-sync | https://github.com/larskanis/pg-ldap-sync/blob/d1d913ad4ed96c92c34d9a2d6a41559227c3cf17/test/test_pg_ldap_sync.rb | test/test_pg_ldap_sync.rb | require "minitest/autorun"
require "minitest/hooks/test"
require "pg_ldap_sync"
require "yaml"
require "fileutils"
require_relative "ldap_server"
class TestPgLdapSync < Minitest::Test
include Minitest::Hooks
@@logid = 0
def log_and_run(*cmd)
if $DEBUG
puts cmd.join(" ")
system(*cmd)
else
... | ruby | MIT | d1d913ad4ed96c92c34d9a2d6a41559227c3cf17 | 2026-01-04T17:45:02.165437Z | false |
larskanis/pg-ldap-sync | https://github.com/larskanis/pg-ldap-sync/blob/d1d913ad4ed96c92c34d9a2d6a41559227c3cf17/lib/pg_ldap_sync.rb | lib/pg_ldap_sync.rb | require "pg_ldap_sync/application"
require "pg_ldap_sync/compat"
require "pg_ldap_sync/version"
module PgLdapSync
class LdapError < RuntimeError
end
class ApplicationExit < RuntimeError
attr_reader :exitcode
def initialize(exitcode, error = nil)
super(error)
@exitcode = exitcode
end
e... | ruby | MIT | d1d913ad4ed96c92c34d9a2d6a41559227c3cf17 | 2026-01-04T17:45:02.165437Z | false |
larskanis/pg-ldap-sync | https://github.com/larskanis/pg-ldap-sync/blob/d1d913ad4ed96c92c34d9a2d6a41559227c3cf17/lib/pg_ldap_sync/version.rb | lib/pg_ldap_sync/version.rb | module PgLdapSync
VERSION = "0.5.3"
end
| ruby | MIT | d1d913ad4ed96c92c34d9a2d6a41559227c3cf17 | 2026-01-04T17:45:02.165437Z | false |
larskanis/pg-ldap-sync | https://github.com/larskanis/pg-ldap-sync/blob/d1d913ad4ed96c92c34d9a2d6a41559227c3cf17/lib/pg_ldap_sync/application.rb | lib/pg_ldap_sync/application.rb | #!/usr/bin/env ruby
require "net/ldap"
require "optparse"
require "erb"
require "yaml"
require "json-schema"
require "pg"
require "pg_ldap_sync/logger"
module PgLdapSync
class Application
attr_accessor :config_fname
attr_accessor :log
attr_accessor :test
def string_to_symbol(hash)
if hash.is_... | ruby | MIT | d1d913ad4ed96c92c34d9a2d6a41559227c3cf17 | 2026-01-04T17:45:02.165437Z | false |
larskanis/pg-ldap-sync | https://github.com/larskanis/pg-ldap-sync/blob/d1d913ad4ed96c92c34d9a2d6a41559227c3cf17/lib/pg_ldap_sync/logger.rb | lib/pg_ldap_sync/logger.rb | require "logger"
module PgLdapSync
class Logger < ::Logger
def initialize(io)
super
@counters = {}
end
def add(severity, *args, &block)
super
return unless [Logger::FATAL, Logger::ERROR].include?(severity)
@counters[severity] ||= block ? block.call : args.first
end
... | ruby | MIT | d1d913ad4ed96c92c34d9a2d6a41559227c3cf17 | 2026-01-04T17:45:02.165437Z | false |
larskanis/pg-ldap-sync | https://github.com/larskanis/pg-ldap-sync/blob/d1d913ad4ed96c92c34d9a2d6a41559227c3cf17/lib/pg_ldap_sync/compat.rb | lib/pg_ldap_sync/compat.rb | #!/usr/bin/env ruby
class Hash
# transform_keys was added in ruby-2.5
unless method_defined? :transform_keys
def transform_keys
map do |k, v|
[yield(k), v]
end.to_h
end
end
end
| ruby | MIT | d1d913ad4ed96c92c34d9a2d6a41559227c3cf17 | 2026-01-04T17:45:02.165437Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/benchmarks/performance.rb | benchmarks/performance.rb | require "benchmark"
require "etc"
class PerformanceBenchmark
attr_reader :warmup_runs,
:measure_runs,
:iterations_per_run,
:planets,
:ephem
BENCHMARK_METRICS = [
:rts_event_on,
:rts_events_between,
:twilight_event_on,
:moon_phases
]
def initialize(warmup_runs: 2, measure_runs:... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/benchmarks/benchmark.rb | benchmarks/benchmark.rb | require "astronoby"
require "csv"
require "zip"
class Source
NAMES = [
ASTRONOBY = "astronoby",
IMCCE = "imcce",
SUN_CALC = "sun_calc"
].freeze
attr_accessor :name,
:sun_rising_time,
:sun_transit_time,
:sun_setting_time,
:moon_rising_time,
:moon_transit_time,
:moon_setting_ti... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby_spec.rb | spec/astronoby_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby do
it "has a version number" do
expect(Astronoby::VERSION).not_to be nil
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start
end
require "astronoby"
require "support/test_ephem_helper"
require "support/cache"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_st... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/support/test_ephem_helper.rb | spec/support/test_ephem_helper.rb | # frozen_string_literal: true
module TestEphemHelper
def test_ephem
path = File.path("#{__dir__}/data/de440s_2025_excerpt.bsp")
Astronoby::Ephem.load(path)
end
def test_ephem_moon
path = File.path("#{__dir__}/data/de440s_moon_2000_2030_excerpt.bsp")
Astronoby::Ephem.load(path)
end
def test_... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/support/cache.rb | spec/support/cache.rb | # frozen_string_literal: true
RSpec.configure do |config|
config.before(:each) do
Astronoby.reset_configuration!
Astronoby.configuration.cache_enabled = false
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/equinox_solstice_spec.rb | spec/astronoby/equinox_solstice_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::EquinoxSolstice do
include TestEphemHelper
describe ".new" do
it "raises an error if the event is not supported" do
ephem = double
expect { described_class.new(2024, 4, ephem) }.to(
raise_error(
Astronoby::UnsupportedEventE... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/precession_spec.rb | spec/astronoby/precession_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Precession do
describe "::for_equatorial_coordinates" do
# Source:
# Title: Practical Astronomy with your Calculator or Spreadsheet
# Authors: Peter Duffett-Smith and Jonathan Zwart
# Edition: Cambridge University Press
# Chapter: 34 - P... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/angular_velocity_spec.rb | spec/astronoby/angular_velocity_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::AngularVelocity do
describe "object immutability" do
context "when a mutable method is added" do
it "raises a FrozenError when immutability is broken" do
described_class.class_eval do
def clear
@radians_per_second = 0
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/configuration_spec.rb | spec/astronoby/configuration_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Configuration do
describe "cache configuration" do
it "allows disabling cache" do
Astronoby.reset_configuration!
Astronoby.configuration.cache_enabled = false
expect(Astronoby.cache).to be_a(Astronoby::NullCache)
end
it "allows c... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/vector_spec.rb | spec/astronoby/vector_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Vector do
describe ".new" do
it "creates a new vector with valid numeric inputs" do
vector = described_class[1, 2, 3]
expect(vector.x).to eq(1)
expect(vector.y).to eq(2)
expect(vector.z).to eq(3)
end
it "freezes the object"... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/refraction_spec.rb | spec/astronoby/refraction_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Refraction do
describe "::angle" do
it "returns an Angle" do
observer = instance_double(
Astronoby::Observer,
latitude: Astronoby::Angle.from_degrees(50),
longitude: Astronoby::Angle.zero,
pressure: Astronoby::Observer:... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/nutation_spec.rb | spec/astronoby/nutation_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Nutation do
describe "::matrix_for" do
it "returns a matrix of 3x3" do
time = Time.utc(2025, 8, 1)
instant = Astronoby::Instant.from_time(time)
matrix = described_class.matrix_for(instant)
expect(matrix.row_size).to eq(3)
exp... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/angle_spec.rb | spec/astronoby/angle_spec.rb | # frozen_string_literal: true
require "set" # rubocop:disable Lint/RedundantRequireStatement
RSpec.describe Astronoby::Angle do
describe "object immutability" do
context "when a mutable method is added" do
it "raises a FrozenError when immutability is broken" do
described_class.class_eval do
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/geocentric_parallax_spec.rb | spec/astronoby/geocentric_parallax_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::GeocentricParallax do
describe "::angle" do
it "returns an Angle" do
distance = Astronoby::Distance.from_meters(1_000_000_000)
expect(described_class.angle(distance: distance))
.to be_a(Astronoby::Angle)
end
# Source:
# Ti... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/observer_spec.rb | spec/astronoby/observer_spec.rb | # frozen_string_literal: true
require "set" # rubocop:disable Lint/RedundantRequireStatement
RSpec.describe Astronoby::Observer do
describe "equivalence (#==)" do
it "returns true when the observers are equivalent" do
observer1 = described_class.new(
latitude: Astronoby::Angle.from_degrees(45),
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/true_obliquity_spec.rb | spec/astronoby/true_obliquity_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::TrueObliquity do
describe "::at" do
it "returns an angle" do
instant = Astronoby::Instant
.from_terrestrial_time(Astronoby::JulianDate::J2000)
obliquity = described_class.at(instant)
expect(obliquity).to be_kind_of(Astronoby::Angl... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/stellar_propagation_spec.rb | spec/astronoby/stellar_propagation_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::StellarPropagation do
describe ".equatorial_coordinates_for" do
it "returns propagated coordinates for Aldebaran on 1991-01-01" do
time = Time.utc(1991, 1, 1)
equatorial_coordinates = Astronoby::Coordinates::Equatorial.new(
right_ascensi... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/velocity_spec.rb | spec/astronoby/velocity_spec.rb | # frozen_string_literal: true
require "set" # rubocop:disable Lint/RedundantRequireStatement
RSpec.describe Astronoby::Velocity do
describe "object immutability" do
context "when a mutable method is added" do
it "raises a FrozenError when immutability is broken" do
described_class.class_eval do
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/distance_spec.rb | spec/astronoby/distance_spec.rb | # frozen_string_literal: true
require "set" # rubocop:disable Lint/RedundantRequireStatement
RSpec.describe Astronoby::Distance do
describe "object immutability" do
context "when a mutable method is added" do
it "raises a FrozenError when immutability is broken" do
described_class.class_eval do
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/instant_spec.rb | spec/astronoby/instant_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Instant do
describe ".new / .from_terrestrial_time" do
it "creates an instance of Astronoby::Instant" do
instant = described_class.new(2451545.0)
expect(instant).to be_a(Astronoby::Instant)
end
it "creates an instance from a terrestria... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/mean_obliquity_spec.rb | spec/astronoby/mean_obliquity_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::MeanObliquity do
describe "::at" do
it "returns an angle" do
instant = Astronoby::Instant
.from_terrestrial_time(Astronoby::JulianDate::J2000)
obliquity = described_class.at(instant)
expect(obliquity).to be_kind_of(Astronoby::Angl... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/cache_spec.rb | spec/astronoby/cache_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Cache do
describe "::instance" do
it "returns the same instance every time" do
instance1 = described_class.instance
instance2 = described_class.instance
expect(instance1).to equal(instance2)
end
end
describe "#[] and #[]=" do
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/deflection_spec.rb | spec/astronoby/deflection_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Deflection do
include TestEphemHelper
describe "#corrected_position" do
it "returns the corrected position for Mars on 2025-04-01" do
time = Time.utc(2025, 4, 1)
instant = Astronoby::Instant.from_time(time)
ephem = test_ephem
mars... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/julian_date_spec.rb | spec/astronoby/julian_date_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::JulianDate do
describe "::from_time" do
# Source: https://quasar.as.utexas.edu/BillInfo/JulianDatesG.html
it "returns the Julian date associated with the time" do
time = Time.utc(1582, 10, 15, 0, 0, 0)
expect(described_class.from_time(time)... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/moon_phase_spec.rb | spec/astronoby/moon_phase_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::MoonPhase do
describe "::new_moon" do
it "returns a new Moon phase" do
time = Time.new
moon_phase = described_class.new_moon(time)
expect(moon_phase.phase).to eq(described_class::NEW_MOON)
expect(moon_phase.time).to eq(time)
end... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/ephem_spec.rb | spec/astronoby/ephem_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Ephem do
describe ".download" do
it "downloads the ephemeris using Ephem" do
allow(::Ephem::Download).to receive(:call)
described_class.download(name: "de440t.bsp", target: "tmp/de440t.bsp")
expect(::Ephem::Download)
.to have_rec... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/aberration_spec.rb | spec/astronoby/aberration_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Aberration do
include TestEphemHelper
describe "#corrected_position" do
it "returns the corrected position for Mars on 2025-04-01" do
time = Time.utc(2025, 4, 1)
instant = Astronoby::Instant.from_time(time)
ephem = test_ephem
eart... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/earth_spec.rb | spec/astronoby/bodies/earth_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Earth do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/moon_spec.rb | spec/astronoby/bodies/moon_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Moon do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/mercury_spec.rb | spec/astronoby/bodies/mercury_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Mercury do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3]... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/deep_sky_object_spec.rb | spec/astronoby/bodies/deep_sky_object_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::DeepSkyObject do
describe "#at" do
it "returns a DeepSkyObjectPosition instance" do
instant = Astronoby::Instant.from_time(Time.utc(2025, 1, 1))
equatorial_coordinates = Astronoby::Coordinates::Equatorial.new(
right_ascension: Astronoby:... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/neptune_spec.rb | spec/astronoby/bodies/neptune_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Neptune do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3]... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/sun_spec.rb | spec/astronoby/bodies/sun_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Sun do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/saturn_spec.rb | spec/astronoby/bodies/saturn_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Saturn do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/deep_sky_object_position_spec.rb | spec/astronoby/bodies/deep_sky_object_position_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::DeepSkyObjectPosition do
include TestEphemHelper
describe "#astrometric" do
it "returns an Astrometric position" do
time = Time.utc(2025, 10, 1)
instant = Astronoby::Instant.from_time(time)
equatorial_coordinates = Astronoby::Coordinate... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/jupiter_spec.rb | spec/astronoby/bodies/jupiter_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Jupiter do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3]... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/uranus_spec.rb | spec/astronoby/bodies/uranus_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Uranus do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/solar_system_body_spec.rb | spec/astronoby/bodies/solar_system_body_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::SolarSystemBody do
describe "::geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],
velocity... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/mars_spec.rb | spec/astronoby/bodies/mars_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Mars do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/bodies/venus_spec.rb | spec/astronoby/bodies/venus_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Venus do
include TestEphemHelper
describe "#geometric" do
it "returns a Geometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: Ephem::Core::Vector[1, 2, 3],
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/util/maths_spec.rb | spec/astronoby/util/maths_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Util::Maths do
describe ".dot_product" do
it "returns the dot product of two arrays" do
a = [1, 2, 3]
b = [4, 5, 6]
expect(described_class.dot_product(a, b)).to eq(32)
end
end
describe ".quadratic_maximum" do
it "finds the ma... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/util/trigonometry_spec.rb | spec/astronoby/util/trigonometry_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Util::Trigonometry do
# Source:
# Title: Celestial Calculations
# Author: J. L. Lawrence
# Edition: MIT Press
# Chapter: 4 - Orbits and Coordinate Systems
describe "::adjustement_for_arctangent" do
it "returns an Angle" do
adjustement = ... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/util/time_spec.rb | spec/astronoby/util/time_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Util::Time do
describe "::decimal_hour_to_time" do
it "returns a Time object" do
date = Date.new
decimal = 0
expect(described_class.decimal_hour_to_time(date, 0, decimal)).to be_a Time
end
it "converts a decimal time to a Time fo... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/corrections/light_time_delay_spec.rb | spec/astronoby/corrections/light_time_delay_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Correction::LightTimeDelay do
describe "#delay" do
it "returns the light time delay" do
# Geometric position of Earth on date
center = instance_double(
Astronoby::Geometric,
position: Astronoby::Vector[
Astronoby::Dista... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/constellations/repository_spec.rb | spec/astronoby/constellations/repository_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Constellations::Repository do
describe ".get" do
it "returns a constellation object for a valid abbreviation" do
%w[
And Ant Aps Aql Aqr Ara Ari Aur Boo CMa CMi CVn Cae Cam Cap Car Cas Cen
Cep Cet Cha Cir Cnc Col Com CrA CrB Crt Cru Cr... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/constellations/finder_spec.rb | spec/astronoby/constellations/finder_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Constellations::Finder do
describe ".find" do
it "returns the right constellation for a given equatorial coordinates" do
stars = [
# Andromeda (And)
[[0, 8, 23.26], [29, 5, 25.6], "And"], # Alpheratz
[[1, 9, 43.92], [35, 3... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/time/local_sidereal_time_spec.rb | spec/astronoby/time/local_sidereal_time_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::LocalSiderealTime do
describe "::from_gst" do
# Source:
# Title: Practical Astronomy with your Calculator or Spreadsheet
# Authors: Peter Duffett-Smith and Jonathan Zwart
# Edition: Cambridge University Press
# Chapter: 14 - Local sidere... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/time/greenwich_sidereal_time_spec.rb | spec/astronoby/time/greenwich_sidereal_time_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::GreenwichSiderealTime do
describe "::from_utc" do
context "when type is :mean (default)" do
# Source:
# Title: Practical Astronomy with your Calculator or Spreadsheet
# Authors: Peter Duffett-Smith and Jonathan Zwart
# Edition: Ca... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/reference_frames/astrometric_spec.rb | spec/astronoby/reference_frames/astrometric_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Astrometric do
describe "::build_from_geometric" do
it "returns an Astrometric position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: double(x: 1, y: 2, z: 3),
ve... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/reference_frames/mean_of_date_spec.rb | spec/astronoby/reference_frames/mean_of_date_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::MeanOfDate do
describe "::build_from_geometric" do
it "returns a MeanOfDate position" do
time = Time.utc(2025, 2, 7, 12)
instant = Astronoby::Instant.from_time(time)
state = double(
position: double(x: 1, y: 2, z: 3),
veloc... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/events/twilight_calculator_spec.rb | spec/astronoby/events/twilight_calculator_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::TwilightCalculator do
include TestEphemHelper
describe "#morning_civil_twilight_time" do
it "returns a time" do
ephem = test_ephem_sun
observer = Astronoby::Observer.new(
latitude: Astronoby::Angle.zero,
longitude: Astronoby::... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/events/moon_phases_spec.rb | spec/astronoby/events/moon_phases_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Events::MoonPhases do
it "returns a list of Moon phases" do
expect(described_class.phases_for(year: 2024, month: 1))
.to all(be_a(Astronoby::MoonPhase))
end
it "returns the phases for a given year and month: January 2024" do
moon_phases = des... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/events/extremum_calculator_spec.rb | spec/astronoby/events/extremum_calculator_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::ExtremumCalculator do
include TestEphemHelper
describe "Moon apoapsis calculations" do
it "finds all expected Moon apoapsis events in full year 2025" do
ephem = test_ephem_inpop
calculator = described_class.new(
body: Astronoby::Moon,... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/events/rise_transit_set_calculator_spec.rb | spec/astronoby/events/rise_transit_set_calculator_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::RiseTransitSetCalculator do
include TestEphemHelper
# Sunrise, sunset, moonrise and moonset times are compared to the USNO and not
# the IMCCE as Astronoby implements the USNO's definitions of rising and
# setting horizon angles.
# Transit times are co... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/coordinates/equatorial_spec.rb | spec/astronoby/coordinates/equatorial_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Coordinates::Equatorial do
describe "::zero" do
it "returns a new instance with zero angles" do
coordinates = described_class.zero
expect(coordinates.right_ascension).to eq(Astronoby::Angle.zero)
expect(coordinates.declination).to eq(Astr... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/coordinates/ecliptic_spec.rb | spec/astronoby/coordinates/ecliptic_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Coordinates::Ecliptic do
describe "::zero" do
it "returns a new instance with zero angles" do
coordinates = described_class.zero
expect(coordinates.latitude).to eq(Astronoby::Angle.zero)
expect(coordinates.longitude).to eq(Astronoby::Angl... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/angles/hms_spec.rb | spec/astronoby/angles/hms_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Hms do
describe "#format" do
it "formats properly" do
expect(described_class.new(10, 11, 12.5).format).to eq("10h 11m 12.5s")
end
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/spec/astronoby/angles/dms_spec.rb | spec/astronoby/angles/dms_spec.rb | # frozen_string_literal: true
RSpec.describe Astronoby::Dms do
let(:instance) { described_class.new("+", 10, 11, 12.5) }
describe "#format" do
subject { instance.format }
it "formats properly" do
expect(subject).to eq("+10° 11′ 12.5″")
end
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby.rb | lib/astronoby.rb | # frozen_string_literal: true
require "astronoby/cache"
require "astronoby/configuration"
require "astronoby/constants"
require "astronoby/angle"
require "astronoby/angles/dms"
require "astronoby/angles/hms"
require "astronoby/angular_velocity"
require "astronoby/constellation"
require "astronoby/constellations/reposi... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/nutation.rb | lib/astronoby/nutation.rb | # frozen_string_literal: true
module Astronoby
class Nutation
# IAU 2000B model corrections (in microarcseconds)
IAU2000B_DPSI_CORRECTION = -0.000135e7
IAU2000B_DEPS_CORRECTION = 0.000388e7
# Nutation terms from IAU 2000B model:
# 77 most significant terms from the IAU 2000A model
# 0..4: fu... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/moon_phase.rb | lib/astronoby/moon_phase.rb | # frozen_string_literal: true
module Astronoby
class MoonPhase
NEW_MOON = :new_moon
FIRST_QUARTER = :first_quarter
FULL_MOON = :full_moon
LAST_QUARTER = :last_quarter
attr_reader :time, :phase
# @param time [Time] Time of the Moon phase
# @return [Astronoby::MoonPhase] New Moon phase
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/constellation.rb | lib/astronoby/constellation.rb | # frozen_string_literal: true
module Astronoby
class Constellation
attr_reader :name, :abbreviation
def initialize(name, abbreviation)
@name = name
@abbreviation = abbreviation
end
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/deflection.rb | lib/astronoby/deflection.rb | # frozen_string_literal: true
module Astronoby
class Deflection
# Solar gravitational constant (m^3/s^2)
SOLAR_GRAVITATION_CONSTANT = 1.32712440017987e+20
# @param instant [Astronoby::Instant] the instant of the observation
# @param target_astrometric_position [Astronoby::Vector<Distance>] the
#... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/distance.rb | lib/astronoby/distance.rb | # frozen_string_literal: true
module Astronoby
class Distance
include Comparable
class << self
def zero
new(0)
end
def from_meters(meters)
new(meters)
end
alias_method :from_m, :from_meters
def from_kilometers(kilometers)
meters = kilometers * Co... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/version.rb | lib/astronoby/version.rb | # frozen_string_literal: true
module Astronoby
VERSION = "0.9.0"
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/vector.rb | lib/astronoby/vector.rb | # frozen_string_literal: true
require "matrix"
module Astronoby
class Vector < ::Vector
def initialize(...)
super
freeze
end
def x
self[0]
end
def y
self[1]
end
def z
self[2]
end
def magnitude
if all? { _1.is_a?(Astronoby::Distance) }
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/angular_velocity.rb | lib/astronoby/angular_velocity.rb | # frozen_string_literal: true
module Astronoby
class AngularVelocity
include Comparable
class << self
def zero
new(0)
end
def from_radians_per_second(radians_per_second)
new(radians_per_second)
end
def from_milliarcseconds_per_year(mas_per_year)
angle ... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/stellar_propagation.rb | lib/astronoby/stellar_propagation.rb | # frozen_string_literal: true
module Astronoby
class StellarPropagation
# @return [Astronoby::Vector] Propagated position vector of
# Astronoby::Distance components
def self.position_for(**kwargs)
new(**kwargs).position
end
# @return [Astronoby::Vector] Propagated position vector of
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/errors.rb | lib/astronoby/errors.rb | module Astronoby
class IncompatibleArgumentsError < ArgumentError; end
class UnsupportedFormatError < ArgumentError; end
class UnsupportedEventError < ArgumentError; end
class CalculationError < StandardError; end
class EphemerisError < StandardError; end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/velocity.rb | lib/astronoby/velocity.rb | # frozen_string_literal: true
module Astronoby
class Velocity
include Comparable
class << self
def zero
new(0)
end
def from_meters_per_second(meters_per_second)
new(meters_per_second)
end
alias_method :from_mps, :from_meters_per_second
def from_kilometer... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/mean_obliquity.rb | lib/astronoby/mean_obliquity.rb | # frozen_string_literal: true
# TODO: This needs to be improved by receiving an instant instead of an Epoch
# as these coefficients work with TT (Terrestrial Time).
module Astronoby
class MeanObliquity
# Source:
# IAU resolution in 2006 in favor of the P03 astronomical model
# https://syrte.obspm.fr/i... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/angle.rb | lib/astronoby/angle.rb | # frozen_string_literal: true
module Astronoby
class Angle
include Comparable
MIN_PRECISION = 10
FORMATS = %i[dms hms].freeze
class << self
def zero
new(0)
end
def from_radians(radians)
normalized_radians = radians.remainder(Constants::RADIANS_PER_CIRCLE)
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/observer.rb | lib/astronoby/observer.rb | # frozen_string_literal: true
module Astronoby
class Observer
DEFAULT_ELEVATION = Distance.zero
DEFAULT_TEMPERATURE = 283.15
PRESSURE_AT_SEA_LEVEL = 1013.25
PASCAL_PER_MILLIBAR = 0.01
EARTH_GRAVITATIONAL_ACCELERATION = 9.80665
MOLAR_MASS_OF_AIR = 0.0289644
UNIVERSAL_GAS_CONSTANT = 8.31432... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/constants.rb | lib/astronoby/constants.rb | # frozen_string_literal: true
module Astronoby
class Constants
DAYS_PER_JULIAN_YEAR = 365.25
DAYS_PER_JULIAN_CENTURY = DAYS_PER_JULIAN_YEAR * 100
DAYS_PER_JULIAN_MILLENIA = DAYS_PER_JULIAN_CENTURY * 10
TROPICAL_YEAR_AT_B1900 = 365.242198781
HOURS_PER_DAY = 24.0
DEGREES_PER_CIRCLE = 360.0
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/geocentric_parallax.rb | lib/astronoby/geocentric_parallax.rb | # frozen_string_literal: true
module Astronoby
class GeocentricParallax
# Source:
# Title: Practical Astronomy with your Calculator or Spreadsheet
# Authors: Peter Duffett-Smith and Jonathan Zwart
# Edition: Cambridge University Press
# Chapter: 39 - Calculating correction for parallax
#... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/julian_date.rb | lib/astronoby/julian_date.rb | # frozen_string_literal: true
module Astronoby
# @see https://en.wikipedia.org/wiki/Julian_day
# @see https://en.wikipedia.org/wiki/Epoch_(astronomy)
class JulianDate
# Starting year for Besselian epoch calculations
# @return [Integer] 1900
BESSELIAN_EPOCH_STARTING_YEAR = 1900
# Starting year fo... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/configuration.rb | lib/astronoby/configuration.rb | # frozen_string_literal: true
module Astronoby
class Configuration
DEFAULT_PRECISIONS = {
geometric: 9, # 8.64e-5 seconds
nutation: 2, # 864 seconds
precession: 2, # 864 seconds
rise_transit_set: 5 # 0.1 seconds
}.freeze
attr_accessor :cache_enabled
attr... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/equinox_solstice.rb | lib/astronoby/equinox_solstice.rb | # frozen_string_literal: true
module Astronoby
class EquinoxSolstice
# Source:
# Title: Astronomical Algorithms
# Author: Jean Meeus
# Edition: 2nd edition
# Chapter: 27 - Equinoxes and Soltices
EVENTS = [
MARCH_EQUINOX = 0,
JUNE_SOLSTICE = 1,
SEPTEMBER_EQUINOX = 2,
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/instant.rb | lib/astronoby/instant.rb | # frozen_string_literal: true
require "date"
module Astronoby
# Represents a specific instant in time using Terrestrial Time (TT) as its
# internal representation. This class provides conversions between different
# time scales commonly used in astronomy:
# - Terrestrial Time (TT)
# - International Atomic T... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.