-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8782ca4
commit e1caf3f
Showing
16 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# rails g model currency_rate | ||
# from:string | ||
# to:string | ||
# rate:float | ||
|
||
# rails runner CurrencyRate.get | ||
# rails runner 'CurrencyRate.get("KGS", "USD")' | ||
# rails runner "CurrencyRate.get('USD', 'EUR')" | ||
|
||
class CurrencyRate < ApplicationRecord | ||
API = "https://api.exchangerate.host/latest" | ||
|
||
def self.get(from = "USD", to = "EUR") | ||
uri = URI(CurrencyRate::API + "?base=#{from}&symbols=#{to}") | ||
|
||
response = Net::HTTP.get(uri) | ||
response_obj = JSON.parse(response) | ||
|
||
create!( | ||
from: from, to: to, | ||
rate: response_obj['rates'][to] | ||
) | ||
|
||
puts "[#{DateTime.now.strftime('%d.%m.%Y %H.%M.%S')}]: " + \ | ||
"#{from}:#{to} currency rate: " + response_obj['rates'][to].to_s | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
require_relative "./helpers.rb" | ||
|
||
to_exec = (ARGV[0] || 'containers_information').strip | ||
eval to_exec |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
#!/usr/bin/env ruby | ||
require_relative "./helpers.rb" | ||
|
||
start_all_containers | ||
rails_install_gems | ||
rails_db_migrate | ||
|
||
puma_start | ||
sidekiq_start | ||
|
||
cron_start | ||
chewy_index | ||
|
||
containers_information | ||
sidekiq_start | ||
puma_start |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
require_relative "./helpers.rb" | ||
|
||
start_all_containers | ||
system('bin/start') | ||
containers_information |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ | |
require_relative "./helpers.rb" | ||
|
||
puma_stop | ||
cron_stop | ||
sidekiq_stop | ||
|
||
containers_information |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
require_relative "./helpers.rb" | ||
stop_all_containers | ||
containers_information |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Learn more: http://github.com/javan/whenever | ||
# | ||
# How to initialize whenever | ||
# `bundle exec wheneverize .` | ||
# | ||
# How to start cron service | ||
# as ROOT: /etc/init.d/cron start | ||
# | ||
# How to start whenever | ||
# whenever --update-crontab --load-file config/_SCHEDULE.rb -i lucky | ||
# | ||
# How to see current crontab | ||
# crontab -l | ||
|
||
env :GEM_HOME, ENV['GEM_HOME'] | ||
set :environment, ENV.fetch("RAILS_ENV") { 'development' } | ||
|
||
set :output, { | ||
standard: '/home/lucky/app/log/cron.log', | ||
error: '/home/lucky/app/log/cron.error.log' | ||
} | ||
|
||
job_type :rails, "cd :path && :environment_variable=:environment bundle exec rails :task :output" | ||
|
||
every 1.minute do | ||
rails "runner \"CurrencyRate.get('USD', 'EUR')\"" | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateCurrencyRates < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :currency_rates do |t| | ||
t.string :from | ||
t.string :to | ||
t.float :rate | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
from: MyString | ||
to: MyString | ||
rate: 1.5 | ||
|
||
two: | ||
from: MyString | ||
to: MyString | ||
rate: 1.5 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "test_helper" | ||
|
||
class CurrencyRateTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |