Class: Gitabu::Scraper
- Inherits:
-
Object
- Object
- Gitabu::Scraper
- Defined in:
- lib/gitabu/scraper.rb
Overview
Scraper that gets link to Github API and returns endpoints as variables.
Instance Attribute Summary collapse
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(link, name, version) ⇒ Scraper
constructor
A new instance of Scraper.
- #scrape ⇒ Object
Constructor Details
#initialize(link, name, version) ⇒ Scraper
Returns a new instance of Scraper.
20 21 22 23 24 |
# File 'lib/gitabu/scraper.rb', line 20 def initialize(link, name, version) @link = link @name = name @version = version end |
Instance Attribute Details
#link ⇒ Object
Returns the value of attribute link.
14 15 16 |
# File 'lib/gitabu/scraper.rb', line 14 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/gitabu/scraper.rb', line 14 def name @name end |
#version ⇒ Object
Returns the value of attribute version.
14 15 16 |
# File 'lib/gitabu/scraper.rb', line 14 def version @version end |
Class Method Details
.scrape(link:, name:, version:) ⇒ Object
16 17 18 |
# File 'lib/gitabu/scraper.rb', line 16 def self.scrape(link:, name:, version:) new(link, name, version).scrape end |
Instance Method Details
#scrape ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/gitabu/scraper.rb', line 26 def scrape hash = { result: list } FileUtils.mkdir_p("lib/gitabu/public/api/v#{version}") FileUtils.touch("lib/gitabu/public/api/v#{version}/#{name}.json") File.open("lib/gitabu/public/api/v#{version}/#{name}.json", "w") do |f| f.write(JSON.pretty_generate(hash)) end end |