Class: API::GoogleSourceCom
- Inherits:
-
Object
- Object
- API::GoogleSourceCom
- Defined in:
- lib/api/google_source_com.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#repo_url ⇒ Object
readonly
Returns the value of attribute repo_url.
Instance Method Summary collapse
-
#initialize(repo_url, db_ref = nil) ⇒ GoogleSourceCom
constructor
repo_url: go.googlesource.com/crypto.
-
#last_commits ⇒ Object
URL.
Constructor Details
#initialize(repo_url, db_ref = nil) ⇒ GoogleSourceCom
repo_url: go.googlesource.com/crypto
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/api/google_source_com.rb', line 11 def initialize(repo_url, db_ref=nil) @repo_url = repo_url repo_url_pattern = API::SOURCE_URL_PATTERN[:google_source_com] regex_group = repo_url_pattern.match(repo_url) @protocol = regex_group[:protocol] @host = regex_group[:host] @owner = regex_group[:owner] @repo = regex_group[:repo] @http_option = {} http_proxy = Misc.get_http_proxy if http_proxy @http_option[:proxy_host] = http_proxy[:addr] @http_option[:proxy_port] = http_proxy[:port] end @ref = db_ref end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/api/google_source_com.rb', line 8 def host @host end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
8 9 10 |
# File 'lib/api/google_source_com.rb', line 8 def owner @owner end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
8 9 10 |
# File 'lib/api/google_source_com.rb', line 8 def protocol @protocol end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
8 9 10 |
# File 'lib/api/google_source_com.rb', line 8 def ref @ref end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
8 9 10 |
# File 'lib/api/google_source_com.rb', line 8 def repo @repo end |
#repo_url ⇒ Object (readonly)
Returns the value of attribute repo_url.
8 9 10 |
# File 'lib/api/google_source_com.rb', line 8 def repo_url @repo_url end |
Instance Method Details
#last_commits ⇒ Object
URL.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/api/google_source_com.rb', line 32 def last_commits last_commit = nil opts = {:discard_page_bodies => true, :depth_limit => 0}.merge(@http_option) commit_page = "#{@repo_url}" Anemone.crawl(commit_page, opts) do |anemone| anemone.on_every_page do |page| xpath = "//ol[@class='CommitLog']/li[1]/a[1]" target_link = page.doc.xpath(xpath) # p target_link if target_link.size == 0 raise "last_commit error: #{self}, #{@repo_url}" else # full_href = text.attr('href') short_sha = target_link.text() full_sha = target_link.attr('href').value last_commit = { 'sha' => full_sha.split('/+/').last } end end end last_commit end |