Skip to content

Commit

Permalink
WIP some alma events stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Oct 11, 2024
1 parent 3cf66d2 commit daa38cf
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ sftp/ssh/*
.irb_history
.local/*
.cache/
.solargraph.yml
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gem "faraday"
gem "rackup"

gem "sftp", github: "mlibrary/sftp"
gem "canister"

group :development, :test do
gem "pry"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GEM
base64 (0.2.0)
bigdecimal (3.1.6)
byebug (11.1.3)
canister (0.9.2)
climate_control (1.2.0)
coderay (1.1.3)
concurrent-ruby (1.2.3)
Expand Down Expand Up @@ -146,6 +147,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
canister
climate_control
faraday
pry
Expand Down
1 change: 1 addition & 0 deletions alma_webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "faraday"
require "byebug" if settings.environment == :development

require "./lib/services"
require "./lib/message_validator"
require "./lib/indexing_action"
require "./lib/indexing_jobs_generator"
Expand Down
17 changes: 17 additions & 0 deletions lib/services.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "canister"
require "byebug"

Services = Canister.new
S = Services

S.register(:push_locations) do
ENV.fetch("PUSH_LOCATIONS", "").split("||")
end

S.register(:push_locations?) do
!S.push_locations.empty?
end

S.register(:project_root) do
File.absolute_path(File.join(__dir__, ".."))
end
15 changes: 15 additions & 0 deletions spec/lib/services_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe "Services" do
context ".push_locations" do
it "returns an array when there are items separated by ||" do
with_modified_env PUSH_LOCATIONS: "http://pushlocation:12000/example||http://pushlocation:12000/other_example" do
expect(S.push_locations).to contain_exactly("http://pushlocation:12000/example", "http://pushlocation:12000/other_example")
end
end
it "returns empty array if empty" do
with_modified_env PUSH_LOCATIONS: nil do
load(File.join(S.project_root, "lib", "services.rb"))
expect(S.push_locations).to eq([])
end
end
end
end

0 comments on commit daa38cf

Please sign in to comment.