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
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
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
# 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
# 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/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/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
rake -T | |
=> rake print_repository_info # Print repo info, usage: rake print_repository_info repository_url=repository_url |
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 | |
require 'faraday' | |
desc 'Print repo info, usage: rake print_repository_info repository_url=repository_url' | |
task :print_repository_info do | |
default_url = 'https://api.github.com/repos/MaksimenkoPG/ruby_app_boilerplate' | |
url = ENV['repository_url'] || default_url | |
response = Faraday.get(url) | |
puts response.status |
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 -p lib/tasks |