This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lib/print_repository_info.rb | |
| module PrintRepositoryInfo | |
| DEFAULT_URL = 'https://api.github.com/repos/MaksimenkoPG/ruby_app_boilerplate'.freeze | |
| extend self | |
| def perform(url:) | |
| response = Downloader.perform url: url || DEFAULT_URL | |
| Printer.perform status: response.status, body: response.body | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lib/downloader.rb | |
| require 'faraday' | |
| module Downloader | |
| extend self | |
| def perform(url:) | |
| Faraday.get(url) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lib/printer.rb | |
| module Printer | |
| extend self | |
| def perform(status:, body:) | |
| puts status | |
| puts body | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lib/tasks/print_repository_info.rake | |
| desc 'Print repo info, usage: rake print_repository_info repository_url=repository_url' | |
| task :print_repository_info do | |
| PrintRepositoryInfo.perform url: ENV['repository_url'] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rake aborted! | |
| NameError: uninitialized constant PrintRepositoryInfo | |
| lib/tasks/print_repository_info.rake:3:in `block in <top (required)>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mkdir config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config/application.rb | |
| require_relative 'boot' | |
| module Application | |
| extend self | |
| def root | |
| @root ||= File.dirname(File.expand_path(__dir__)) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config/boot.rb | |
| ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) | |
| require 'bundler/setup' # Set up gems listed in the Gemfile. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # irb | |
| require_relative 'config/application' | |
| PrintRepositoryInfo.perform(url: 'https://api.github.com/repos/rails/rails') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| desc 'Foo' | |
| task foo: :environment do | |
| ... | |
| end |