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
Showing
12 changed files
with
121 additions
and
19 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$LOAD_PATH.unshift("#{__dir__}/../lib") | ||
|
||
require "ayashige" | ||
|
||
Ayashige::Jobs::WebAnalyzer.new.perform |
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 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$LOAD_PATH.unshift("#{__dir__}/../lib") | ||
|
||
require "ayashige" | ||
|
||
Ayashige::Jobs::WhoisDS.new.perform |
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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Ayashige | ||
module Jobs | ||
class Job | ||
def perform | ||
raise NotImplementedError, "You must implement #{self.class}##{__method__}" | ||
end | ||
|
||
def with_error_handling | ||
yield | ||
rescue StandardError => e | ||
if Ayashige::Rollbar.available? | ||
Rollbar.error e | ||
else | ||
puts e | ||
end | ||
end | ||
end | ||
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Ayashige | ||
module Jobs | ||
class WebAnalyzer < Job | ||
def initialize | ||
@source = Ayashige::Sources::WebAnalyzer.new | ||
end | ||
|
||
def perform | ||
with_error_handling { @source.store_newly_registered_domains } | ||
end | ||
end | ||
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Ayashige | ||
module Jobs | ||
class WhoisDS < Job | ||
def initialize | ||
@source = Ayashige::Sources::WhoisDS.new | ||
end | ||
|
||
def perform | ||
with_error_handling { @source.store_newly_registered_domains } | ||
end | ||
end | ||
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,6 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Ayashige::Jobs::WebAnalyzer, :vcr do | ||
include_context "job context" | ||
subject { Ayashige::Jobs::WebAnalyzer.new } | ||
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,6 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Ayashige::Jobs::WhoisDS, :vcr do | ||
include_context "job context" | ||
subject { Ayashige::Jobs::WhoisDS.new } | ||
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
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,30 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.shared_context "job context", shared_context: :metadata do | ||
describe "#perform" do | ||
context "when no error is raised" do | ||
before do | ||
mock = double | ||
allow(mock).to receive(:store_newly_registered_domains).and_return([]) | ||
subject.instance_variable_set(:@source, mock) | ||
end | ||
|
||
it "should return the latest indexed date as a String" do | ||
output = capture(:stdout){ subject.perform } | ||
expect(output.empty?).to eq(true) | ||
end | ||
end | ||
context "when an error is raised" do | ||
before do | ||
mock = double | ||
allow(mock).to receive(:store_newly_registered_domains).and_raise(ArgumentError, "argument error") | ||
subject.instance_variable_set(:@source, mock) | ||
end | ||
|
||
it "should return the latest indexed date as a String" do | ||
output = capture(:stdout) { subject.perform } | ||
expect(output).to include("argument error") | ||
end | ||
end | ||
end | ||
end |