How frinsdev/ruby-semaphore-sms works
Main components
• Consumer Application: any Ruby/Rails app or script that uses the gem.
• Configuration Layer: initializer (Semaphore.configure) that holds API key & sender name.
• Core Gem Modules (in lib/semaphore/):
• Semaphore::Client – public API methods (messages, otp).
• Semaphore::HTTP – builds and sends HTTP requests.
• Semaphore::Compatibility – backwards-compat layer if needed.
• Semaphore::Railtie – Rails integration (initializer hooks).
• External Service: Semaphore REST API endpoints.
Relationships & data flow
• Consumer App → invokes → Semaphore::Client.new (with config)
• Semaphore::Client.method (e.g., messages) → delegates to → Semaphore::HTTP
• Semaphore::HTTP → makes HTTPS calls → Semaphore.co API → receives JSON response
• Response travels back: HTTP → Client → Consumer App
• If in Rails environment, Railtie wires up the initializer at boot.
Architectural patterns & principles
• Separation of concerns:
• Client (business-level API) vs. HTTP (transport) vs. Configuration.
• Dependency injection: API key & sender name passed into Client or globally via configure.
• Extension points:
• Compatibility module for legacy behaviors.
• Railtie for seamless Rails hookup.
Technologies & libraries
• Ruby
• Faraday or Net::HTTP (depending on implementation in HTTP module)
• Bundler (Gemfile)
• Rails (optional integration via Railtie)
• Rake (tasks in Rakefile)
• Bin scripts for console/setup