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 |
|---|---|---|---|---|---|---|---|---|
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/ephem.rb | lib/astronoby/ephem.rb | # frozen_string_literal: true
require "ephem"
module Astronoby
class Ephem
# Download an ephemeris file.
#
# @param name [String] Name of the ephemeris file, supported by the Ephem
# gem
# @param target [String] Location where to store the file
# @return [Boolean] true if the download was ... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/refraction.rb | lib/astronoby/refraction.rb | # frozen_string_literal: true
module Astronoby
class Refraction
LOW_ALTITUDE_BODY_ANGLE = Angle.from_degrees(15)
ZENITH = Angle.from_degrees(90)
def self.angle(coordinates:)
new(coordinates).refraction_angle
end
def self.correct_horizontal_coordinates(coordinates:)
new(coordinates).... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/reference_frame.rb | lib/astronoby/reference_frame.rb | # frozen_string_literal: true
module Astronoby
class ReferenceFrame
attr_reader :position,
:velocity,
:instant,
:center_identifier,
:target_body
def initialize(
position:,
velocity:,
instant:,
center_identifier:,
target_body:
)
@position = posi... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/precession.rb | lib/astronoby/precession.rb | # frozen_string_literal: true
module Astronoby
class Precession
def self.matrix_for(instant)
new(instant: instant).matrix
end
def initialize(instant:)
@instant = instant
end
def matrix
# Source:
# IAU resolution in 2006 in favor of the P03 astronomical model
# ht... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/aberration.rb | lib/astronoby/aberration.rb | # frozen_string_literal: true
module Astronoby
# Applies relativistic aberration corrections to an astrometric position based
# on observer velocity.
class Aberration
# Source:
# Title: Explanatory Supplement to the Astronomical Almanac
# Authors: Sean E. Urban and P. Kenneth Seidelmann
# Edit... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/cache.rb | lib/astronoby/cache.rb | # frozen_string_literal: true
require "monitor"
require "singleton"
module Astronoby
class Cache
include Singleton
Entry = Struct.new(:key, :value, :prev, :next)
DEFAULT_MAX_SIZE = 10_000
attr_reader :max_size
# @param max_size [Integer] Maximum number of entries allowed in the cache
# @... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/true_obliquity.rb | lib/astronoby/true_obliquity.rb | # frozen_string_literal: true
module Astronoby
class TrueObliquity
def self.at(instant)
mean_obliquity = MeanObliquity.at(instant)
nutation = Nutation.new(instant: instant).nutation_in_obliquity
mean_obliquity + nutation
end
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/deep_sky_object_position.rb | lib/astronoby/bodies/deep_sky_object_position.rb | # frozen_string_literal: true
module Astronoby
class DeepSkyObjectPosition
DEFAULT_DISTANCE = Distance.from_parsecs(1e9)
attr_reader :instant, :apparent
# @param instant [Astronoby::Instant] Instant of the observation
# @param equatorial_coordinates [Astronoby::Coordinates::Equatorial]
# Equa... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/saturn.rb | lib/astronoby/bodies/saturn.rb | # frozen_string_literal: true
module Astronoby
class Saturn < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(60_268_000)
ABSOLUTE_MAGNITUDE = -8.914
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, SATURN_BARYCENTER]]
end
def self.absolute_magnitude
AB... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/deep_sky_object.rb | lib/astronoby/bodies/deep_sky_object.rb | # frozen_string_literal: true
module Astronoby
class DeepSkyObject
# @param equatorial_coordinates [Astronoby::Coordinates::Equatorial]
# Equatorial coordinates at epoch J2000.0
# @param proper_motion_ra [Astronoby::AngularVelocity, nil] Proper motion in
# right ascension
# @param proper_moti... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/sun.rb | lib/astronoby/bodies/sun.rb | # frozen_string_literal: true
module Astronoby
class Sun < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(695_700_000)
ABSOLUTE_MAGNITUDE = -26.74
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, SUN]]
end
def self.absolute_magnitude
ABSOLUTE_MAGNITUDE... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/mars.rb | lib/astronoby/bodies/mars.rb | # frozen_string_literal: true
module Astronoby
class Mars < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(3_396_200)
ABSOLUTE_MAGNITUDE = -1.601
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, MARS_BARYCENTER]]
end
def self.absolute_magnitude
ABSOLUT... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/mercury.rb | lib/astronoby/bodies/mercury.rb | # frozen_string_literal: true
module Astronoby
class Mercury < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(2_439_700)
ABSOLUTE_MAGNITUDE = -0.613
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, MERCURY_BARYCENTER]]
end
def self.absolute_magnitude
A... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/venus.rb | lib/astronoby/bodies/venus.rb | # frozen_string_literal: true
module Astronoby
class Venus < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(6_051_800)
ABSOLUTE_MAGNITUDE = -4.384
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, VENUS_BARYCENTER]]
end
def self.absolute_magnitude
ABSOL... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/earth.rb | lib/astronoby/bodies/earth.rb | # frozen_string_literal: true
module Astronoby
class Earth < SolarSystemBody
def self.ephemeris_segments(ephem_source)
if ephem_source == ::Ephem::SPK::JPL_DE
[
[SOLAR_SYSTEM_BARYCENTER, EARTH_MOON_BARYCENTER],
[EARTH_MOON_BARYCENTER, EARTH]
]
elsif ephem_source ==... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/jupiter.rb | lib/astronoby/bodies/jupiter.rb | # frozen_string_literal: true
module Astronoby
class Jupiter < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(71_492_000)
ABSOLUTE_MAGNITUDE = -9.395
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, JUPITER_BARYCENTER]]
end
def self.absolute_magnitude
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/moon.rb | lib/astronoby/bodies/moon.rb | # frozen_string_literal: true
module Astronoby
class Moon < SolarSystemBody
SEMIDIAMETER_VARIATION = 0.7275
EQUATORIAL_RADIUS = Distance.from_meters(1_737_400)
ABSOLUTE_MAGNITUDE = 0.28
def self.ephemeris_segments(ephem_source)
if ephem_source == ::Ephem::SPK::JPL_DE
[
[SOLAR... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/uranus.rb | lib/astronoby/bodies/uranus.rb | # frozen_string_literal: true
module Astronoby
class Uranus < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(25_559_000)
ABSOLUTE_MAGNITUDE = -7.11
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, URANUS_BARYCENTER]]
end
def self.absolute_magnitude
ABS... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/neptune.rb | lib/astronoby/bodies/neptune.rb | # frozen_string_literal: true
module Astronoby
class Neptune < SolarSystemBody
EQUATORIAL_RADIUS = Distance.from_meters(24_764_000)
ABSOLUTE_MAGNITUDE = -7.0
def self.ephemeris_segments(_ephem_source)
[[SOLAR_SYSTEM_BARYCENTER, NEPTUNE_BARYCENTER]]
end
def self.absolute_magnitude
AB... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/bodies/solar_system_body.rb | lib/astronoby/bodies/solar_system_body.rb | # frozen_string_literal: true
module Astronoby
class SolarSystemBody
SOLAR_SYSTEM_BARYCENTER = 0
SUN = 10
MERCURY_BARYCENTER = 1
MERCURY = 199
VENUS_BARYCENTER = 2
VENUS = 299
EARTH_MOON_BARYCENTER = 3
EARTH = 399
MOON = 301
MARS_BARYCENTER = 4
JUPITER_BARYCENTER = 5
S... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/util/time.rb | lib/astronoby/util/time.rb | # frozen_string_literal: true
module Astronoby
module Util
module Time
OLD_LEAP_SECONDS = {
2378496.5 => 13.188148343557259, # 1800-01-01T00:00:00+00:00
2378677.5 => 12.977779959648615,
2378861.5 => 12.789307379498496,
2379042.5 => 12.627219619724201,
2379226.5 => 12... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/util/trigonometry.rb | lib/astronoby/util/trigonometry.rb | # frozen_string_literal: true
module Astronoby
module Util
module Trigonometry
class << self
# Source:
# Title: Celestial Calculations
# Author: J. L. Lawrence
# Edition: MIT Press
# Chapter: 4 - Orbits and Coordinate Systems
def adjustement_for_arctangen... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/util/maths.rb | lib/astronoby/util/maths.rb | # frozen_string_literal: true
module Astronoby
module Util
module Maths
module_function
def dot_product(a, b)
a.zip(b).sum { |x, y| x * y }
end
# Find maximum altitude using quadratic interpolation
# @param t1, t2, t3 [Time] Three consecutive times
# @param alt1, alt... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/corrections/light_time_delay.rb | lib/astronoby/corrections/light_time_delay.rb | # frozen_string_literal: true
module Astronoby
module Correction
class LightTimeDelay
LIGHT_SPEED_CORRECTION_MAXIMUM_ITERATIONS = 10
LIGHT_SPEED_CORRECTION_PRECISION = 1e-12
def self.compute(center:, target:, ephem:)
new(center: center, target: target, ephem: ephem).compute
end
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/astronomical_models/moon_phases_periodic_terms.rb | lib/astronoby/astronomical_models/moon_phases_periodic_terms.rb | # frozen_string_literal: true
module Astronoby
class MoonPhasesPeriodicTerms
# Lunar Solution ELP 2000-82B (Chapront-Touze+, 1988)
# Source:
# Title: Astronomical Algorithms
# Author: Jean Meeus
# Edition: 2nd edition
# Chapter: 49 - Phases of the Moon
# @param julian_centuries [Flo... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/constellations/data.rb | lib/astronoby/constellations/data.rb | # frozen_string_literal: true
module Astronoby
module Constellations
class Data
def self.sorted_right_ascensions
@sorted_right_ascensions ||=
read_file("sorted_right_ascensions.dat").map(&:to_f)
end
def self.sorted_declinations
@sorted_declinations ||=
read_... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/constellations/repository.rb | lib/astronoby/constellations/repository.rb | # frozen_string_literal: true
module Astronoby
module Constellations
class Repository
# Returns a constellation object for the given abbreviation.
# @param abbreviation [String] The abbreviation of the constellation.
# @return [Astronoby::Constellation, nil] The constellation object or nil
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/constellations/finder.rb | lib/astronoby/constellations/finder.rb | # frozen_string_literal: true
module Astronoby
module Constellations
class Finder
# Finds the constellation that contains the given B1875 equatorial
# coordinates.
# @param equatorial_coordinates [Astronoby::Coordinates::Equatorial] The
# B1875 coordinates to search for.
# @retu... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/time/local_sidereal_time.rb | lib/astronoby/time/local_sidereal_time.rb | # frozen_string_literal: true
module Astronoby
class LocalSiderealTime < SiderealTime
attr_reader :longitude
def self.from_gst(gst:, longitude:)
case gst.type
when MEAN
LocalMeanSiderealTime.from_gst(gst: gst, longitude: longitude)
when APPARENT
LocalApparentSiderealTime.fr... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/time/local_mean_sidereal_time.rb | lib/astronoby/time/local_mean_sidereal_time.rb | # frozen_string_literal: true
module Astronoby
class LocalMeanSiderealTime < LocalSiderealTime
# Source:
# Title: Practical Astronomy with your Calculator or Spreadsheet
# Authors: Peter Duffett-Smith and Jonathan Zwart
# Edition: Cambridge University Press
# Chapter: 14 - Local sidereal time... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/time/local_apparent_sidereal_time.rb | lib/astronoby/time/local_apparent_sidereal_time.rb | # frozen_string_literal: true
module Astronoby
class LocalApparentSiderealTime < LocalSiderealTime
# Source:
# Title: Practical Astronomy with your Calculator or Spreadsheet
# Authors: Peter Duffett-Smith and Jonathan Zwart
# Edition: Cambridge University Press
# Chapter: 14 - Local sidereal ... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/time/greenwich_apparent_sidereal_time.rb | lib/astronoby/time/greenwich_apparent_sidereal_time.rb | # frozen_string_literal: true
module Astronoby
class GreenwichApparentSiderealTime < GreenwichSiderealTime
def self.from_utc(utc)
gmst = GreenwichMeanSiderealTime.from_utc(utc)
instant = Instant.from_time(utc)
nutation = Nutation.new(instant: instant)
mean_obliquity = MeanObliquity.at(ins... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/time/greenwich_sidereal_time.rb | lib/astronoby/time/greenwich_sidereal_time.rb | # frozen_string_literal: true
module Astronoby
class GreenwichSiderealTime < SiderealTime
def self.from_utc(utc, type: MEAN)
validate_type!(type)
case type
when MEAN
GreenwichMeanSiderealTime.from_utc(utc)
when APPARENT
GreenwichApparentSiderealTime.from_utc(utc)
end... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/time/greenwich_mean_sidereal_time.rb | lib/astronoby/time/greenwich_mean_sidereal_time.rb | # frozen_string_literal: true
module Astronoby
class GreenwichMeanSiderealTime < GreenwichSiderealTime
JULIAN_CENTURIES_EXPONENTS = [
6.697374558,
2400.051336,
0.000025862
].freeze
SIDEREAL_MINUTE_IN_UT_MINUTE = 0.9972695663
# Source:
# Title: Practical Astronomy with your Ca... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/time/sidereal_time.rb | lib/astronoby/time/sidereal_time.rb | # frozen_string_literal: true
module Astronoby
class SiderealTime
TYPES = [
MEAN = :mean,
APPARENT = :apparent
].freeze
attr_reader :date, :time, :type
def self.normalize_time(time)
time += Constants::HOURS_PER_DAY if time.negative?
time -= Constants::HOURS_PER_DAY if time >... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/reference_frames/topocentric.rb | lib/astronoby/reference_frames/topocentric.rb | # frozen_string_literal: true
module Astronoby
class Topocentric < ReferenceFrame
def self.build_from_apparent(
apparent:,
observer:,
instant:,
target_body:
)
matrix = observer.earth_fixed_rotation_matrix_for(instant)
observer_position = Distance.vector_from_meters(
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/reference_frames/mean_of_date.rb | lib/astronoby/reference_frames/mean_of_date.rb | # frozen_string_literal: true
module Astronoby
class MeanOfDate < ReferenceFrame
def self.build_from_geometric(
instant:,
target_geometric:,
earth_geometric:,
target_body:
)
position = target_geometric.position - earth_geometric.position
velocity = target_geometric.velocit... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/reference_frames/geometric.rb | lib/astronoby/reference_frames/geometric.rb | # frozen_string_literal: true
module Astronoby
class Geometric < ReferenceFrame
def initialize(
position:,
velocity:,
instant:,
target_body:
)
super(
position: position,
velocity: velocity,
instant: instant,
center_identifier: SolarSystemBody::SOL... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/reference_frames/apparent.rb | lib/astronoby/reference_frames/apparent.rb | # frozen_string_literal: true
module Astronoby
class Apparent < ReferenceFrame
def self.build_from_astrometric(
instant:,
target_astrometric:,
earth_geometric:,
target_body:
)
position = target_astrometric.position
velocity = target_astrometric.velocity
precession_ma... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/reference_frames/astrometric.rb | lib/astronoby/reference_frames/astrometric.rb | # frozen_string_literal: true
module Astronoby
class Astrometric < ReferenceFrame
def self.build_from_geometric(
instant:,
earth_geometric:,
light_time_corrected_position:,
light_time_corrected_velocity:,
target_body:
)
new(
position: light_time_corrected_position ... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/twilight_event.rb | lib/astronoby/events/twilight_event.rb | # frozen_string_literal: true
module Astronoby
class TwilightEvent
attr_reader :morning_civil_twilight_time,
:evening_civil_twilight_time,
:morning_nautical_twilight_time,
:evening_nautical_twilight_time,
:morning_astronomical_twilight_time,
:evening_astronomical_twilight_time
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/extremum_calculator.rb | lib/astronoby/events/extremum_calculator.rb | # frozen_string_literal: true
module Astronoby
# Calculates extrema (minima and maxima) in the distance between two
# celestial bodies over a given time range using adaptive sampling and golden
# section search refinement.
class ExtremumCalculator
# Mathematical constants
PHI = (1 + Math.sqrt(5)) / 2
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/extremum_event.rb | lib/astronoby/events/extremum_event.rb | # frozen_string_literal: true
module Astronoby
# Represents an extremum event with its timing and value
class ExtremumEvent
attr_reader :instant, :value
# @param instant [Astronoby::Instant] When the event occurs
# @param value [Object] The extreme value
def initialize(instant, value)
@insta... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/rise_transit_set_calculator.rb | lib/astronoby/events/rise_transit_set_calculator.rb | # frozen_string_literal: true
module Astronoby
class RiseTransitSetCalculator
class PotentialEvent
attr_reader :hour_angle, :can_occur
def initialize(hour_angle, can_occur)
@hour_angle = hour_angle
@can_occur = can_occur
end
def negated
self.class.new(-@hour_angl... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/rise_transit_set_events.rb | lib/astronoby/events/rise_transit_set_events.rb | # frozen_string_literal: true
module Astronoby
class RiseTransitSetEvents
attr_reader :rising_times, :transit_times, :setting_times
def initialize(risings, transits, settings)
@rising_times = risings
@transit_times = transits
@setting_times = settings
end
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/twilight_calculator.rb | lib/astronoby/events/twilight_calculator.rb | # frozen_string_literal: true
module Astronoby
class TwilightCalculator
TWILIGHTS = [
CIVIL = :civil,
NAUTICAL = :nautical,
ASTRONOMICAL = :astronomical
].freeze
TWILIGHT_ANGLES = {
CIVIL => Angle.from_degrees(96),
NAUTICAL => Angle.from_degrees(102),
ASTRONOMICAL => ... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/moon_phases.rb | lib/astronoby/events/moon_phases.rb | # frozen_string_literal: true
module Astronoby
module Events
class MoonPhases
BASE_YEAR = 2000
# Source:
# Title: Astronomical Algorithms
# Author: Jean Meeus
# Edition: 2nd edition
# Chapter: 49 - Phases of the Moon
# @param year [Integer] Requested year
# @... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/twilight_events.rb | lib/astronoby/events/twilight_events.rb | # frozen_string_literal: true
module Astronoby
class TwilightEvents
attr_reader :morning_civil_twilight_times,
:evening_civil_twilight_times,
:morning_nautical_twilight_times,
:evening_nautical_twilight_times,
:morning_astronomical_twilight_times,
:evening_astronomical_twilight_time... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/events/rise_transit_set_event.rb | lib/astronoby/events/rise_transit_set_event.rb | # frozen_string_literal: true
module Astronoby
class RiseTransitSetEvent
attr_reader :rising_time, :transit_time, :setting_time
def initialize(rising, transit, setting)
@rising_time = rising
@transit_time = transit
@setting_time = setting
end
end
end
| ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/coordinates/equatorial.rb | lib/astronoby/coordinates/equatorial.rb | # frozen_string_literal: true
module Astronoby
module Coordinates
class Equatorial
attr_reader :declination, :right_ascension, :hour_angle, :epoch
def initialize(
declination:,
right_ascension:,
hour_angle: nil,
epoch: JulianDate::DEFAULT_EPOCH
)
@right_... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/coordinates/horizontal.rb | lib/astronoby/coordinates/horizontal.rb | # frozen_string_literal: true
module Astronoby
module Coordinates
class Horizontal
attr_reader :azimuth, :altitude, :observer
def initialize(
azimuth:,
altitude:,
observer:
)
@azimuth = azimuth
@altitude = altitude
@observer = observer
end
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/coordinates/ecliptic.rb | lib/astronoby/coordinates/ecliptic.rb | # frozen_string_literal: true
module Astronoby
module Coordinates
class Ecliptic
attr_reader :latitude, :longitude
def initialize(latitude:, longitude:)
@latitude = latitude
@longitude = longitude
end
def self.zero
new(latitude: Angle.zero, longitude: Angle.zero)... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/angles/hms.rb | lib/astronoby/angles/hms.rb | # frozen_string_literal: true
module Astronoby
class Hms
attr_reader :hours, :minutes, :seconds
def initialize(hours, minutes, seconds)
@hours = hours
@minutes = minutes
@seconds = seconds
end
def format(precision: 4)
"#{hours}h #{minutes}m #{seconds.floor(precision)}s"
... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
rhannequin/astronoby | https://github.com/rhannequin/astronoby/blob/8d0575dc373ae74b473ec7e0766396810d1fde6c/lib/astronoby/angles/dms.rb | lib/astronoby/angles/dms.rb | # frozen_string_literal: true
module Astronoby
class Dms
attr_reader :sign, :degrees, :minutes, :seconds
def initialize(sign, degrees, minutes, seconds)
@sign = sign
@degrees = degrees
@minutes = minutes
@seconds = seconds
end
def format(precision: 4)
"#{sign}#{degrees... | ruby | MIT | 8d0575dc373ae74b473ec7e0766396810d1fde6c | 2026-01-04T17:42:41.845693Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
begin
require "debug" unless ENV["CI"] == "true"
rescue LoadError
end
ENV["RAILS_ENV"] = "test"
require "bundler"
require "combustion"
require "callback_hell"
begin
Bundler.require :default, :development
# See https://github.com/pat/combustion
Combustion.initialize!(:active_r... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/support/shared_contexts/callbacks.rb | spec/support/shared_contexts/callbacks.rb | # frozen_string_literal: true
RSpec.shared_context "test callbacks" do
let(:model_class) {
Class.new(ApplicationRecord) {
def self.name
"TestModel"
end
}
}
let(:callbacks) do
[
CallbackHell::Callback.new(
model: model_class,
rails_callback: double(
... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/support/shared_contexts/validations.rb | spec/support/shared_contexts/validations.rb | # frozen_string_literal: true
RSpec.shared_context "test validation callbacks" do
let(:model_class) {
Class.new(ApplicationRecord) {
def self.name
"TestModel"
end
}
}
let(:validation_callbacks) do
[
# A presence validator
CallbackHell::Callback.new(
model: mod... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/support/matchers/callback_matchers.rb | spec/support/matchers/callback_matchers.rb | # frozen_string_literal: true
# RSpec.describe "Rails default callbacks" do
# let(:application_record) { ApplicationRecord }
# let(:callbacks) { CallbackHell::Collector.new(application_record).collect }
#
# it "has inherited callbacks from a module" do
# expect(bar).to have_callback(
# callback_name: :... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/support/matchers/validation_matchers.rb | spec/support/matchers/validation_matchers.rb | # frozen_string_literal: true
# RSpec.describe "Validations" do
# let(:callbacks) { CallbackHell::Collector.new(model, kind: :validations).collect }
# it "has presence validation" do
# expect(callbacks).to have_validation(
# type: "presence",
# method_name: "validates_presence_of"
# )
# end
... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/tasks/modelscope_rake_spec.rb | spec/modelscope/tasks/modelscope_rake_spec.rb | # frozen_string_literal: true
require "rake"
RSpec.describe "rake ch:callbacks" do
let(:task_name) { "ch:callbacks" }
before(:all) do
Rake::Task.clear
load "lib/tasks/callback_hell.rake"
end
around do |example|
original_stdout = $stdout
$stdout = StringIO.new
example.run
$stdout = or... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/integration/association_spec.rb | spec/modelscope/integration/association_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell, "with association-caused callbacks" do
subject(:foo) { CallbackHell::Collector.new(Foo, mode: :full).collect }
subject(:bar) { CallbackHell::Collector.new(Bar, mode: :full).collect }
it "has collection saving-related callbacks" do
expect(foo).to hav... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/integration/empty_activerecord_spec.rb | spec/modelscope/integration/empty_activerecord_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell, "with an empty ActiveRecord" do
def normalization_supported?
ActiveRecord::Base.respond_to?(:normalizes)
end
let(:options) { {} }
subject(:ar) { CallbackHell::Collector.new(ApplicationRecord, **options).collect }
it "does not have any own or ra... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/integration/external_callbacks_spec.rb | spec/modelscope/integration/external_callbacks_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell, "with external ('gem') callbacks and validations" do
subject(:bar) { CallbackHell::Collector.new(Bar, mode: :full).collect }
it "has callbacks" do
expect(bar).to have_callback(
callback_name: :after_commit, method_name: :save_tags,
origin:... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/integration/attribute_generated_spec.rb | spec/modelscope/integration/attribute_generated_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell, "with attribute-generated callbacks and validations" do
def normalization_supported?
ActiveRecord::Base.respond_to?(:normalizes)
end
subject(:foo) { CallbackHell::Collector.new(Foo, mode: :full).collect }
subject(:bar) { CallbackHell::Collector.new... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/integration/self_defined_spec.rb | spec/modelscope/integration/self_defined_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell, "with user-defined callbacks and validations" do
subject(:foo) { CallbackHell::Collector.new(Foo, mode: :full).collect }
subject(:bar) { CallbackHell::Collector.new(Bar, kind: :validations, mode: :full).collect }
it "does have manually added callbacks" ... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/integration/inherited_spec.rb | spec/modelscope/integration/inherited_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell, "with inherited callbacks and validations" do
subject(:bar) { CallbackHell.collect_callbacks(Bar) }
subject(:bar_jr) { CallbackHell.collect_callbacks(BarJr) }
specify do
expect(bar_jr.size).to eq(bar.size)
end
it "has inherited callbacks and va... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/integration/modelscope_spec.rb | spec/modelscope/integration/modelscope_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell do
context "with reporting" do
it "supports different formats" do
line = callback_hell("Foo", format: :line)
expect(line).to include("after_validation")
expect(line).to include("after_create")
table = callback_hell("Foo", format: ... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/stats_spec.rb | spec/modelscope/lib/stats_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Stats do
let(:model_class) { Class.new }
let(:callbacks) do
[
double(
"Callback",
model: model_class,
origin: :own,
inherited: false,
conditional: true,
callback_group: "save",
association_g... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/collector_spec.rb | spec/modelscope/lib/collector_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Collector do
let(:test_model) { Class.new(ApplicationRecord) }
before do
stub_const("TestModel", test_model)
allow(ApplicationRecord).to receive(:descendants).and_return([test_model])
end
describe "collecting" do
it "returns array of Call... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/callback_spec.rb | spec/modelscope/lib/callback_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Callback do
let(:base_class) do
Class.new do
def self.name
"TestModel"
end
def callback_method
end
end
end
let(:method) { base_class.instance_method(:callback_method) }
describe "callback origin" do
before... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/runner_spec.rb | spec/modelscope/lib/runner_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Runner do
let(:collector) { instance_double(CallbackHell::Collector) }
let(:report) { instance_double(CallbackHell::Reports::Validations::Table) }
before do
allow(collector).to receive(:collect).and_return([])
allow(report).to receive(:generate)... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/reports/callbacks/table_spec.rb | spec/modelscope/lib/reports/callbacks/table_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Reports::Callbacks::Table do
include_context "test callbacks"
subject(:report) { described_class.new(callbacks, mode: :full) }
subject(:output) { report.generate }
it "includes all columns" do
expect(output).to include("Model")
expect(output).... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/reports/callbacks/github_spec.rb | spec/modelscope/lib/reports/callbacks/github_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Reports::Callbacks::Github do
include_context "test callbacks"
subject(:report) { described_class.new(callbacks) }
subject(:output) { report.generate }
it "shows model totals" do
total_line = output.lines.find { |l| l.include?("kind=all") }
ex... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/reports/callbacks/line_spec.rb | spec/modelscope/lib/reports/callbacks/line_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Reports::Callbacks::Line do
include_context "test callbacks"
subject(:report) { described_class.new(callbacks) }
subject(:output) { report.generate }
it "includes report header" do
expect(output).to include("Callback Hell callbacks report:")
end... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/reports/validations/table_spec.rb | spec/modelscope/lib/reports/validations/table_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Reports::Validations::Table do
include_context "test validation callbacks"
subject(:report) { described_class.new(validation_callbacks, mode: :full) }
subject(:output) { report.generate }
it "includes all columns" do
expect(output).to include("Mod... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/reports/validations/github_spec.rb | spec/modelscope/lib/reports/validations/github_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Reports::Validations::Github do
include_context "test validation callbacks"
subject(:report) { described_class.new(validation_callbacks) }
subject(:output) { report.generate }
it "shows model totals" do
total_line = output.lines.find { |l| l.inclu... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/modelscope/lib/reports/validations/line_spec.rb | spec/modelscope/lib/reports/validations/line_spec.rb | # frozen_string_literal: true
RSpec.describe CallbackHell::Reports::Validations::Line do
include_context "test validation callbacks"
subject(:report) { described_class.new(validation_callbacks) }
subject(:output) { report.generate }
it "includes report header" do
expect(output).to include("Callback Hell v... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/app/models/foo.rb | spec/internal/app/models/foo.rb | # frozen_string_literal: true
class Foo < ApplicationRecord
has_many :bars, dependent: :destroy
validates :name, presence: true, uniqueness: true
validates :title, presence: true, if: :worthy?
before_validation :noop
after_validation :noop
before_create :noop
after_create :noop
around_create :noop,... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/app/models/bar_jr.rb | spec/internal/app/models/bar_jr.rb | # frozen_string_literal: true
class BarJr < Bar
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/app/models/application_record.rb | spec/internal/app/models/application_record.rb | # frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/app/models/bar.rb | spec/internal/app/models/bar.rb | # frozen_string_literal: true
require_relative "../../vendor/gems/acts_as_taggable/acts_as_taggable"
class Bar < ApplicationRecord
include Annoying
include ActsAsTaggable
belongs_to :foo, optional: false # for whatever reason, I had to add the optional option
validates :name, presence: true
after_commit ... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/app/models/concerns/annoying.rb | spec/internal/app/models/concerns/annoying.rb | # frozen_string_literal: true
module Annoying
extend ActiveSupport::Concern
included do
after_commit :be_annoying
validate :be_annoying
end
def be_annoying
true
end
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/app/models/bar/baz.rb | spec/internal/app/models/bar/baz.rb | # frozen_string_literal: true
class Bar::Baz < ApplicationRecord
before_save :noop
def noop
true
end
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/vendor/gems/acts_as_taggable/acts_as_taggable.rb | spec/internal/vendor/gems/acts_as_taggable/acts_as_taggable.rb | # frozen_string_literal: true
module ActsAsTaggable
extend ActiveSupport::Concern
included do
after_commit :save_tags
validate :validate_tags
end
def save_tags = true
def validate_tags = true
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/db/schema.rb | spec/internal/db/schema.rb | # frozen_string_literal: true
ActiveRecord::Schema.define do
create_table :foos, force: true do |t|
t.string :name
t.string :title
end
create_table :bars, force: true do |t|
t.references :foo
t.string :name
end
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/spec/internal/config/routes.rb | spec/internal/config/routes.rb | # frozen_string_literal: true
Rails.application.routes.draw do
# Add your own routes here, or remove this file if you don't have need for it.
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell.rb | lib/callback_hell.rb | # frozen_string_literal: true
require "zeitwerk"
module CallbackHell
class Error < StandardError; end
def self.loader # @private
@loader ||= Zeitwerk::Loader.for_gem.tap do |loader|
loader.ignore("#{__dir__}/tasks")
loader.setup
end
end
def self.collect_callbacks(*models, **options)
... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/callback.rb | lib/callback_hell/callback.rb | # frozen_string_literal: true
module CallbackHell
class Callback
attr_reader :model, :method_name, :conditional, :origin, :inherited, :kind,
:association_generated, :attribute_generated, :callback, :defining_class,
:fingerprint
def initialize(model:, rails_callback:, name:, defining_class:)
... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/version.rb | lib/callback_hell/version.rb | # frozen_string_literal: true
module CallbackHell
VERSION = "0.2.1"
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/collector.rb | lib/callback_hell/collector.rb | # frozen_string_literal: true
require "set"
module CallbackHell
class Collector
attr_reader :models
def initialize(models = nil, paths: nil, kind: :callbacks, mode: :default)
@paths = paths
@kind = kind
@mode = mode
eager_load!
@models = Set.new(models ? [*models] : Applicati... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/stats.rb | lib/callback_hell/stats.rb | # frozen_string_literal: true
module CallbackHell
class Stats
COUNTERS = %i[
total own inherited rails gems conditional
association_generated attribute_generated
].freeze
SORT = %i[size name].freeze
SORT_ORDER = %i[desc asc].freeze
MODE = %i[default full].freeze
attr_reader :ca... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/railtie.rb | lib/callback_hell/railtie.rb | # frozen_string_literal: true
module CallbackHell
class Railtie < ::Rails::Railtie
load "tasks/callback_hell.rake"
end
end
| ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/runner.rb | lib/callback_hell/runner.rb | # frozen_string_literal: true
module CallbackHell
class Runner
DEFAULT_FORMAT = :table
def self.run(format: DEFAULT_FORMAT, model: nil, paths: nil, kind: :callbacks, **opts)
new(format: format, model: model, paths: paths, kind: kind, **opts).run
end
def initialize(format:, model:, paths:, kin... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/analyzers/validation_analyzer.rb | lib/callback_hell/analyzers/validation_analyzer.rb | # frozen_string_literal: true
module CallbackHell
module Analyzers
class ValidationAnalyzer
STANDARD_VALIDATIONS = %w[
presence uniqueness format length inclusion exclusion
numericality acceptance confirmation
].freeze
STANDARD_VALIDATION_PATTERN = /^validates?_(#{STANDARD_VALI... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/analyzers/callback_analyzer.rb | lib/callback_hell/analyzers/callback_analyzer.rb | # frozen_string_literal: true
module CallbackHell
module Analyzers
class CallbackAnalyzer
RAILS_GEMS = %w[
actioncable actionmailbox actionmailer actionpack actiontext
actionview activejob activemodel activerecord activestorage
activesupport railties
].freeze
RAILS_ATTR... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/reports/line_base.rb | lib/callback_hell/reports/line_base.rb | # frozen_string_literal: true
module CallbackHell
module Reports
class LineBase < Base
def generate
output = [report_title]
@stats.by_model.each do |model_name, model_callbacks|
output << "\n#{model_name}:"
model_callbacks.sort_by(&:kind).each do |callback|
... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/reports/github_base.rb | lib/callback_hell/reports/github_base.rb | # frozen_string_literal: true
module CallbackHell
module Reports
class GithubBase < Base
def generate
output = ["::group::#{report_title}"]
@stats.by_model.each_with_index do |(model_name, _), index|
output << "" if index > 0
output << "::group::#{model_name}"
... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/reports/base.rb | lib/callback_hell/reports/base.rb | # frozen_string_literal: true
module CallbackHell
module Reports
class Base
attr_reader :callbacks, :stats
def initialize(callbacks, **opts)
@callbacks = callbacks
@stats = Stats.new(callbacks, **opts)
end
def generate
raise NotImplementedError
end
end
... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/reports/table_base.rb | lib/callback_hell/reports/table_base.rb | # frozen_string_literal: true
require "table_tennis"
module CallbackHell
module Reports
class TableBase < Base
def generate
headers = ["Model", "Kind", "Total", "Own", "Inherited"]
headers << "Rails" if stats.rails?
headers << "Associations" if stats.associations?
headers <... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
evilmartians/callback_hell | https://github.com/evilmartians/callback_hell/blob/558adc85e0de09dd7479336c74add51ddeff0c6c/lib/callback_hell/reports/callbacks/table.rb | lib/callback_hell/reports/callbacks/table.rb | # frozen_string_literal: true
module CallbackHell
module Reports
module Callbacks
class Table < TableBase
private
def report_title
"Callback Hell callbacks report"
end
def format_group_name(callback)
"#{timing_symbol(callback.kind)}/#{callback.callback_... | ruby | MIT | 558adc85e0de09dd7479336c74add51ddeff0c6c | 2026-01-04T17:45:07.140490Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.