google-search_rank 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49c61311cf21d35adece24df5779471d7f4283cf
4
- data.tar.gz: 0234e8a8b9ee6fe8db1dd7ff6bb72f893d2e5332
3
+ metadata.gz: b4b08bb265b0647ac44aa5d9300a65db147b47dd
4
+ data.tar.gz: 10ada8bd53bdcb3c7a790676279dbc4cdfbf41e1
5
5
  SHA512:
6
- metadata.gz: cfbc09cd17f4befd38546568a130805dd872eb1263b8e1959019aa0bad370ba98178f7c0133c631eb44b8cf9ac8fb8780aa0934be36d149768660ef525437b3d
7
- data.tar.gz: 571750ae70b2397c2523a396f48659ae8d24b889165cc5798c97d14a88ebadc537ad2e4b80c424ce514a009f8a86a96b4e653645bd108b53c0727f4b97025692
6
+ metadata.gz: 216cf87d4fcd75db299a306effff7bb71e862604cc42be34197ac5bb4e5556bff1e2387caa26b56d659739ab3c66db13d557c39c41619be6fffbb823950d725e
7
+ data.tar.gz: 0898d4a08e235679aac7935809648f5d96bdbbce6bcd92ff234346ae0e330dc7953d46928573fb936a72b93107f5ea84e40bfc216eb39ede7a2e18c388ef4481
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Google::SearchRank
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/google/search_rank`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Easy to get to Google search ranks.
6
4
 
7
5
  ## Installation
8
6
 
@@ -1,5 +1,5 @@
1
1
  module Google
2
2
  class SearchRank
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -48,14 +48,19 @@ module Google
48
48
  'q' => query,
49
49
  'start' => start,
50
50
  )
51
- has_next_page = result.data.queries['nextPage'].count > 0
51
+ queries = result.data.queries
52
+ has_next_page = !queries.nil? && queries['nextPage'].count > 0
52
53
  has_result = result.data.items.count > 0
53
54
 
54
55
  return 0 unless has_result
55
56
 
56
57
  result.data.items.each_with_index do |item, i|
57
58
  puts "start: #{start}, i: #{i} rank: #{start + i}, query: #{query}, link: #{item.link}"
58
- return start + i if item.link == link
59
+ if item.link =~ link
60
+ return start + i
61
+ elsif item.link == link
62
+ return start + i
63
+ end
59
64
  end
60
65
 
61
66
  if has_next_page
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-search_rank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Komagata