myprecious_python 0.0.5 → 0.0.6

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 +4 -4
  2. data/lib/myprecious_python.rb +85 -75
  3. metadata +42 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 355cc9fed098f33fe79f5d717a43bb6972b48d1afbf75aa3923e12bc41f140ca
4
- data.tar.gz: 77a1a57c9345d561c443621c317a4b8e450ae432ccf7f6988ee267cc0d382aad
3
+ metadata.gz: 3976b784b6d2a5e5d7e439d493ad4b5a2c010242b21a1fefce45d9e5f92da63e
4
+ data.tar.gz: 9f48110bc9b390764acb5793bf3c400234a5a378f713d12d677019bd44381edc
5
5
  SHA512:
6
- metadata.gz: a4391ab5f970b6c13bac4778d907ebc4bcc1e8381c04bffd34564ced4880e4bcbb6102ee82af71126a5234e4fca104f1cb4f6c191fe50c724e464fdb6af0a30b
7
- data.tar.gz: 39c9db479f71b4e40b265b1a0feba6f0e514a02bf21e421853ab0ecacf6cedb31d683cc043116795abc84d1cb2038779b52ad9f4063b377d37ae0441c9290dcb
6
+ metadata.gz: 758c698b022bc280d193ded3cc03492918e2a2ed3d3ee22646f06eea72b783e59360c926aa6b5d01f0dee9f613bf73c8081eff1c71e724451fa319061e60ba40
7
+ data.tar.gz: def233c565fdab60ebbc107e870c427e41612af3c6c4c3ee83d4f78bdfc52257b06a347748581cf81a3b10c869119cad78fa789a78a5d8a376e00c292db76dec
@@ -1,7 +1,8 @@
1
- require 'nokogiri'
2
- require 'httparty'
3
1
  require 'date'
4
2
  require 'byebug'
3
+ require 'httparty'
4
+ require 'json'
5
+ require 'rest-client'
5
6
 
6
7
  class MyPreciousPython
7
8
  def self.update
@@ -14,6 +15,7 @@ class MyPreciousPython
14
15
  gem_change_pos = 5
15
16
  default_length = 6
16
17
  if File.file?('dependency-tracking.md')
18
+ puts "reading the dependency file...."
17
19
  File.open("dependency-tracking.md", "r").each_with_index do |line, line_number|
18
20
  #puts line + " dds " + line_number.to_s
19
21
  word_array = line.split('|')
@@ -45,7 +47,7 @@ class MyPreciousPython
45
47
  end
46
48
  #puts gem_lines
47
49
  else
48
- puts "creating the file"
50
+ puts "creating the dependency file...."
49
51
  File.open('dependency-tracking.md', 'w') { |write_file|
50
52
  write_file.puts "Dependency | Our Version | Latest Version | Date available | Age (in days) | Change Log"
51
53
  write_file.puts "--- | --- | --- | --- | --- | ---"
@@ -58,89 +60,97 @@ class MyPreciousPython
58
60
 
59
61
  while (line = file.gets)
60
62
  gem_line = line.strip
63
+
61
64
  if !gem_line.start_with?('#') && !gem_line.start_with?("https://")
62
-
63
- if gem_line.include? "=="
64
- name = gem_line.split('==')[0]
65
- current_version = gem_line.split('==')[1]
66
- elsif gem_line.include? ">="
67
- name = gem_line.split('>=')[0]
68
- current_version = gem_line.split('>=')[1]
69
- elsif gem_line.include? "<="
70
- name = gem_line.split('<=')[0]
71
- current_version = gem_line.split('<=')[1]
72
- end
73
- if !current_version.index(';').nil?
74
- current_version = current_version.split(';')[0]
75
- end
76
- latest_version_string = %x(yolk -U #{name})
77
- begin
78
- latest_version = latest_version_string.split(' ')[2].split("(")[1].split(")")[0]
79
- rescue
80
- latest_version = current_version
81
- end
82
- scrape_url = "https://pypi.org/project/" + name.to_s + "/" + current_version.to_s
83
65
  begin
84
- doc = Nokogiri::HTML(httparty.get(scrape_url))
85
- doc_data = doc.css('tr.odd td')
86
- if !doc_data.nil?
87
- current_build_date = doc_data[3].content
88
- else
66
+ if gem_line.include? "=="
67
+ name = gem_line.split('==')[0]
68
+ current_version = gem_line.split('==')[1]
69
+ elsif gem_line.include? ">="
70
+ name = gem_line.split('>=')[0]
71
+ current_version = gem_line.split('>=')[1]
72
+ elsif gem_line.include? "<="
73
+ name = gem_line.split('<=')[0]
74
+ current_version = gem_line.split('<=')[1]
75
+ end
76
+ if !current_version.index(';').nil?
77
+ current_version = current_version.split(';')[0]
78
+ end
79
+
80
+ api_url = "https://pypi.python.org/pypi/" + name + "/" + "json"
81
+ response = RestClient.get(api_url)
82
+ puts name.to_s + ": gathering info @ " + api_url
83
+ begin
84
+ current_build_date = JSON.parse(response)['releases'][current_version][0]['upload_time']
85
+ if !current_build_date.nil?
86
+ current_build_date = current_build_date
87
+ else
88
+ current_build_date = ""
89
+ end
90
+ rescue Exception => e
91
+ puts e
89
92
  current_build_date = ""
90
93
  end
91
- rescue Exception => e
92
- current_build_date = ""
93
- end
94
- puts name.to_s + " gathering info @" + scrape_url = "https://pypi.org/project/" + name.to_s + "/" + latest_version
95
- puts scrape_url
96
- doc = Nokogiri::HTML(httparty.get(scrape_url))
97
- begin
98
- doc_data = doc.css('tr.odd td')
99
- if !doc_data.nil?
100
- latest_build_date = doc_data[3].content
101
- else
94
+
95
+ begin
96
+ latest_version = JSON.parse(response)['info']['version']
97
+ rescue
98
+ puts e
99
+ latest_version = ""
100
+ end
101
+
102
+ begin
103
+ latest_build_date = JSON.parse(response)['releases'][latest_version][0]['upload_time']
104
+ if !latest_build_date.nil?
105
+ latest_build_date = latest_build_date
106
+ else
107
+ latest_build_date = ""
108
+ end
109
+ rescue Exception => e
110
+ puts e
102
111
  latest_build_date = ""
103
112
  end
104
- rescue Exception => e
105
- latest_build_date = ""
106
- end
107
113
 
108
- begin
109
- documentation = doc.at('li:contains("Documentation:")').css('a').map { |link| link['href'] }[0]
110
- rescue Exception => e
111
- documentation = ""
112
- end
114
+ begin
115
+ documentation = JSON.parse(response)['info']['project_url']
116
+ rescue Exception => e
117
+ puts e
118
+ documentation = ""
119
+ end
113
120
 
114
- begin
115
- homepage_uri = doc.at('li:contains("Home Page")').text.strip.split("\n").last.strip
116
- rescue Exception => e
117
- homepage_uri = ""
118
- end
121
+ begin
122
+ homepage_uri = JSON.parse(response)['info']['home_page']
123
+ rescue Exception => e
124
+ puts e
125
+ homepage_uri = ""
126
+ end
119
127
 
120
- begin
121
- days_complete = Date.parse(latest_build_date) - Date.parse(current_build_date)
122
- rescue Exception => e
123
- days_complete = 0
124
- end
125
-
126
- if gem_lines[name].nil?
127
- array_to_write = Array.new(default_length) { |i| "" }
128
- else
129
- array_to_write = final_write[gem_lines[name]].split('|')
130
- end
131
- array_to_write[gem_name_pos] = "[" + name + "]" + "(" + homepage_uri.to_s + ")"
132
- array_to_write[gem_version_pos] = current_version.to_s
133
- array_to_write[gem_latest_pos] = latest_version.to_s
134
- array_to_write[gem_date_pos] = (latest_build_date).to_s
135
- array_to_write[gem_age_pos] = days_complete.to_i.to_s
128
+ begin
129
+ days_complete = Date.parse(latest_build_date) - Date.parse(current_build_date)
130
+ rescue Exception => e
131
+ days_complete = 0
132
+ end
133
+
134
+ if gem_lines[name].nil?
135
+ array_to_write = Array.new(default_length) { |i| "" }
136
+ else
137
+ array_to_write = final_write[gem_lines[name]].split('|')
138
+ end
139
+ array_to_write[gem_name_pos] = "[" + name + "]" + "(" + homepage_uri.to_s + ")"
140
+ array_to_write[gem_version_pos] = current_version.to_s
141
+ array_to_write[gem_latest_pos] = latest_version.to_s
142
+ array_to_write[gem_date_pos] = (latest_build_date).to_s
143
+ array_to_write[gem_age_pos] = days_complete.to_i.to_s
136
144
 
137
- array_to_write[gem_change_pos] = documentation.to_s.to_s + "\n"
138
- if !gem_lines[name].nil?
139
- final_write[gem_lines[name]] = array_to_write.join("|")
140
- else
141
- final_write << array_to_write.join("|")
145
+ array_to_write[gem_change_pos] = documentation.to_s.to_s + "\n"
146
+ if !gem_lines[name].nil?
147
+ final_write[gem_lines[name]] = array_to_write.join("|")
148
+ else
149
+ final_write << array_to_write.join("|")
150
+ end
151
+ rescue Exception => e
152
+ puts e
142
153
  end
143
-
144
154
  end
145
155
  end
146
156
  File.open('dependency-tracking.md', 'w') { |f| f.write(final_write.join) }
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myprecious_python
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Balki Kodarapu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-11 00:00:00.000000000 Z
11
+ date: 2019-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: nokogiri
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.10.0
20
- - - "~>"
21
- - !ruby/object:Gem::Version
22
- version: '1.10'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 1.10.0
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: '1.10'
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: byebug
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -70,6 +50,46 @@ dependencies:
70
50
  - - ">="
71
51
  - !ruby/object:Gem::Version
72
52
  version: 0.16.4
53
+ - !ruby/object:Gem::Dependency
54
+ name: json
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '2.1'
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 2.1.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '2.1'
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: 2.1.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: rest-client
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '2.0'
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.2
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: 2.0.2
73
93
  description: A simple, markdown generated with information about your python dependencies
74
94
  email: balki.kodarapu@gmail.com
75
95
  executables: