Class: RubyGemsOrgDB
- Inherits:
-
Object
- Object
- RubyGemsOrgDB
- Defined in:
- lib/license_auto/website/ruby_gems_org_db.rb
Instance Method Summary collapse
-
#download(url) ⇒ Object
TODO: download function move into misc.rb or others, like launchpad.rb has the same function.
- #find_archive_download_url ⇒ Object
-
#initialize ⇒ RubyGemsOrgDB
constructor
A new instance of RubyGemsOrgDB.
Constructor Details
#initialize ⇒ RubyGemsOrgDB
Returns a new instance of RubyGemsOrgDB.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/license_auto/website/ruby_gems_org_db.rb', line 9 def initialize @download_prefix = 'https://s3-us-west-2.amazonaws.com/rubygems-dumps/' @http_option = {} # TODO: LicenseAuto::Base.config({http_proxy}) http_proxy = Misc.get_http_proxy if http_proxy @http_option[:http_proxyaddr] = http_proxy[:addr] @http_option[:http_proxyport] = http_proxy[:port] end end |
Instance Method Details
#download(url) ⇒ Object
TODO: download function move into misc.rb or others, like launchpad.rb has the same function
43 44 45 46 |
# File 'lib/license_auto/website/ruby_gems_org_db.rb', line 43 def download(url) file_pathname = nil return file_pathname end |
#find_archive_download_url ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/license_auto/website/ruby_gems_org_db.rb', line 21 def find_archive_download_url() api_url = 'https://s3-us-west-2.amazonaws.com/rubygems-dumps/?prefix=production/public_postgresql' download_url = nil response = HTTParty.get(api_url, =@http_option) if response.code == 200 # DOC: http://www.nokogiri.org/tutorials/searching_a_xml_html_document.html#but_i_m_lazy_and_don_t_want_to_deal_with_namespaces_ doc = Nokogiri::XML(response.licenses).remove_namespaces! xpath = "//Contents[last()]/Key/text()" xpath = "//Contents[last()]/Key/text()" text_node = doc.xpath(xpath) relative_url = text_node.text download_url = "#{@download_prefix}#{relative_url}" else raise Exception("http_status: #{response.status}") end download_url end |