gem-status-xxkvl 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/top_gems.rb +75 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1bf5f87856922b545fa14c9680e03b9da11a62f5f8449ad2f6af52c26b56d003
4
+ data.tar.gz: 469608ee39668d1447fa3fea5aea9a3823011e037f04064c2955e9af9c963fac
5
+ SHA512:
6
+ metadata.gz: b9b7cebb343bfaf980d5b51a1a5cd01841736ba3ff2d4e05fae6b67fd6575c63a2e99aea94e530ea2dd92d88ca3cd852047c111e7003c1878fb47bbbdbc277f8
7
+ data.tar.gz: cb67b4af6b46cfbec363897599b49b706f571c3e9232414051d9155e855754c9b87f74fd4c6e1ddc8c63f07cd1a946e0f0572512dde61809cc956302495ee2d8
data/lib/top_gems.rb ADDED
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+ require 'httparty'
6
+
7
+ AUTH_TOKEN = '43a345ee370fdfafc836b3534b4311a3a8ee45df'
8
+
9
+ class GemStatictic
10
+ attr_reader :gem_name
11
+ def initialize(gem_name)
12
+ @gem_name = gem_name[0]
13
+ end
14
+
15
+ def create_stat
16
+ parse = {
17
+ gem_name: gem_name,
18
+ used_by: find_used_by,
19
+ watch_by: find_wath_by,
20
+ stars: find_stars,
21
+ forks: find_forks,
22
+ contributors: find_contributors,
23
+ open_issues: find_issues
24
+ }
25
+ p parse
26
+ end
27
+
28
+ private
29
+
30
+ # def gem?
31
+ # url = "https://rubygems.org/api/v1/gems/#{gem_name}.json"
32
+ # HTTParty.get(url).parsed_response['name'].nil?
33
+ # end
34
+
35
+ def find_repo
36
+ # raise StandardError if gem?
37
+ url = "https://#{AUTH_TOKEN}@api.github.com/search/repositories?q=#{gem_name}&per_page=1"
38
+ HTTParty.get(url).parsed_response['items'][0]['html_url'].to_s
39
+ # rescue StandardError => e
40
+ # puts "ERR: [#{gem_name}] gem could not be found."
41
+ end
42
+
43
+ def downgload_html
44
+ @downgload_html ||= Nokogiri.HTML(::Kernel.open(find_repo))
45
+ end
46
+
47
+ def downgload_used_html
48
+ @downgload_used_html ||= Nokogiri.HTML(::Kernel.open("#{find_repo}/network/dependents"))
49
+ end
50
+
51
+ def find_used_by
52
+ downgload_used_html.css('.btn-link').css('.selected').text.tr('^0-9', '').to_i
53
+ end
54
+
55
+ def find_wath_by
56
+ downgload_html.css("a[class='social-count']")[0].text.tr('^0-9', '').to_i
57
+ end
58
+
59
+ def find_stars
60
+ downgload_html.css("a[class='social-count js-social-count']").text.tr('^0-9', '').to_i
61
+ end
62
+
63
+ def find_forks
64
+ downgload_html.css("a[class='social-count']")[1].text.tr('^0-9', '').to_i
65
+ end
66
+
67
+ def find_contributors
68
+ downgload_html.css("span[class='num text-emphasized']")[-1].text.tr('^0-9', '').to_i
69
+ end
70
+
71
+ def find_issues
72
+ downgload_html.css("span[class='Counter']")[0].text.tr('^0-9', '').to_i
73
+ end
74
+ end
75
+ n = GemStatictic.new(ARGV).create_stat
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-status-xxkvl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Quaranto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2010-04-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple hello world gem
14
+ email: xxkvl@yandex.ru
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/top_gems.rb
20
+ homepage: https://rubygems.org/gems/hola
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.0.4
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Hola!
43
+ test_files: []