DreamTeam 1.0.5 → 1.0.6

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
  SHA256:
3
- metadata.gz: ea8a784a181c210965d831f2bffadd7f9661defa8e945513a195ffa96a20c446
4
- data.tar.gz: 950744a84f6b8f69d3d44046ff7e9c7af8485f30a45f250be8f89f8b76115eee
3
+ metadata.gz: '0998c3e35a0c4eec1573745686606a9a590c3e816be83987a162b71e8b8a3460'
4
+ data.tar.gz: 89e15191fe544d8e74b25f6acf32627a7a86592d1e0eea476262b5384bdedd1b
5
5
  SHA512:
6
- metadata.gz: db1467c54c0d32afb099e233817ddc80c156188c4dfb3acda88f819e0ac32d2c69a9740bd0d5e0293efb3c577969dc2209e2a8c50d5c8f60983c31133ad9484b
7
- data.tar.gz: c564993091e2ef75b240409ab49ccbd3b7b7475bfd9ec7eafa1d278c0f670698bc7c37c88ed3952a114c73fd807c5a70868bf37478f44921a66bf7942fd06e8b
6
+ metadata.gz: f1cbdefc59ca978a98f224be2434e48c6d9708c7aa64abfaf4d069273eb223290751342ebacdbe2215806847cb1ad43538b6a5238130385f62f2c7bae00d8f84
7
+ data.tar.gz: 38c683c303225b2a31c1772c90d4fb635769516f03bc23c02838bb574f22df8837cef0a797b24bb2fa4620af24bf1f10a663a8c2e3e0bbb95771f8124f76151c
data/README.md CHANGED
@@ -35,8 +35,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
35
35
  ## Usage
36
36
 
37
37
  usage example:
38
- object = DreamTeam::Html_main::Html_main_page.new
39
- object.create_main('Path to specify the path where the files will be created',"Steam id")
38
+ object = DreamTeam::Html_main::Html_main_page.create_main('Path to specify the path where the files will be created',"Steam id")
40
39
 
41
40
  ## Development
42
41
 
@@ -1,13 +1,9 @@
1
1
  require_relative 'parsing_films'
2
2
 
3
- module DreamTeam
4
- module Table_film
5
- class Table_film_page
3
+ def create_table_with_film(path)
4
+ fileHtml = File.new(path + "/table_film.html", "w+")
6
5
 
7
- def create_table_with_film(path)
8
- fileHtml = File.new(path + "/table_film.html", "w+")
9
-
10
- fileHtml.puts "<style>
6
+ fileHtml.puts "<style>
11
7
  .table_dark {
12
8
  font-family: 'Lucida Sans Unicode', 'Lucida Grande', Sans-Serif;
13
9
  font-size: 14px;
@@ -51,38 +47,32 @@ module DreamTeam
51
47
 
52
48
  </tr>"
53
49
 
54
- filmsInformation = get_all_films(get_films_id())
55
- filmsInformation.each do |elem|
56
- fileHtml.puts "<tr>"
57
- fileHtml.puts "<th>"
58
- fileHtml.puts elem.rank
59
- fileHtml.puts "<th>"
60
- fileHtml.puts elem.title
61
- fileHtml.puts "<th>"
62
- fileHtml.puts elem.title_full
63
- fileHtml.puts "<th>"
64
- fileHtml.puts elem.year
65
- fileHtml.puts "<th>"
66
- fileHtml.puts "<img src = '#{elem.image}'
50
+ filmsInformation = get_all_films(get_films_id())
51
+ filmsInformation.each do |elem|
52
+ fileHtml.puts "<tr>"
53
+ fileHtml.puts "<th>"
54
+ fileHtml.puts elem.rank
55
+ fileHtml.puts "<th>"
56
+ fileHtml.puts elem.title
57
+ fileHtml.puts "<th>"
58
+ fileHtml.puts elem.title_full
59
+ fileHtml.puts "<th>"
60
+ fileHtml.puts elem.year
61
+ fileHtml.puts "<th>"
62
+ fileHtml.puts "<img src = '#{elem.image}'
67
63
  width = '102'
68
64
  height = '160'>"
69
- fileHtml.puts "<th>"
70
- fileHtml.puts elem.crew
71
- fileHtml.puts "<th>"
72
- fileHtml.puts elem.imDbRating
73
- fileHtml.puts "<th>"
74
- fileHtml.puts elem.imDbRatingCount
75
- fileHtml.puts "<th>"
76
-
77
-
78
- fileHtml.puts "</tr>"
79
- end
65
+ fileHtml.puts "<th>"
66
+ fileHtml.puts elem.crew
67
+ fileHtml.puts "<th>"
68
+ fileHtml.puts elem.imDbRating
69
+ fileHtml.puts "<th>"
70
+ fileHtml.puts elem.imDbRatingCount
71
+ fileHtml.puts "<th>"
80
72
 
81
- fileHtml.puts "</table>"
82
- fileHtml.close
83
- end
84
-
85
-
86
- end
73
+ fileHtml.puts "</tr>"
87
74
  end
75
+
76
+ fileHtml.puts "</table>"
77
+ fileHtml.close
88
78
  end
@@ -2,69 +2,61 @@ require 'open-uri'
2
2
  require 'nokogiri'
3
3
  require 'json'
4
4
 
5
- module DreamTeam
6
- module Parsing_film
7
-
8
- class Film
9
- include Comparable
10
- attr_reader :id, :rank, :title, :title_full, :year, :image, :crew, :imDbRating, :imDbRatingCount
11
-
12
- #конструктор класса. из строки вытаскивает функцией help нужные данные для полей
13
- def initialize (arr_film)
14
- arr = arr_film.to_s.gsub('{','').gsub('}','').gsub('",','"^^^').split('^^^')
15
- @id = help(arr, 0)
16
- @rank = help(arr, 1).to_i
17
- @title = help(arr, 2)
18
- @title_full = help(arr, 3)
19
- @year = help(arr, 4).to_i
20
- @image = help(arr, 5)
21
- @crew = help(arr, 6)
22
- @imDbRating = help(arr, 7).to_f
23
- @imDbRatingCount = help(arr, 8).to_i
24
- end
5
+ class Film
6
+ include Comparable
7
+ attr_reader :id, :rank, :title, :title_full, :year, :image, :crew, :imDbRating, :imDbRatingCount
8
+
9
+ #конструктор класса. из строки вытаскивает функцией help нужные данные для полей
10
+ def initialize (arr_film)
11
+ arr = arr_film.to_s.gsub('{', '').gsub('}', '').gsub('",', '"^^^').split('^^^')
12
+ @id = help(arr, 0)
13
+ @rank = help(arr, 1).to_i
14
+ @title = help(arr, 2)
15
+ @title_full = help(arr, 3)
16
+ @year = help(arr, 4).to_i
17
+ @image = help(arr, 5)
18
+ @crew = help(arr, 6)
19
+ @imDbRating = help(arr, 7).to_f
20
+ @imDbRatingCount = help(arr, 8).to_i
21
+ end
25
22
 
26
- def <=>(an_other)
27
- an_other.year <=> self.year
28
- end
23
+ def <=>(an_other)
24
+ an_other.year <=> self.year
25
+ end
29
26
 
30
- def help(arr, i)
31
- return arr[i][arr[i].index(':"') + 2, arr[i].length - arr[i].index(':"') - 3]
32
- end
33
- end
27
+ def help(arr, i)
28
+ return arr[i][arr[i].index(':"') + 2, arr[i].length - arr[i].index(':"') - 3]
29
+ end
30
+ end
34
31
 
35
- def get_films_id()
36
- uri = 'https://imdb-api.com/en/API/Top250Movies/k_uq4za59n'
37
- doc = Nokogiri::HTML(URI.open(uri))
32
+ def get_films_id()
33
+ uri = 'https://imdb-api.com/en/API/Top250Movies/k_uq4za59n'
34
+ doc = Nokogiri::HTML(URI.open(uri))
38
35
 
39
- text = doc.text.gsub('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
36
+ text = doc.text.gsub('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
40
37
  "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>', '')
41
- text = text.gsub('{"items":[', '').gsub(']','')
42
-
38
+ text = text.gsub('{"items":[', '').gsub(']', '')
43
39
 
44
- #text = '{"id":"1424411", ":rank":"1", ":title":"title 1", ":year":"1990", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"},{"id":"9352791", ":rank":"2", ":title":"title 2", ":year":"2006", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"},{"id":"1908543", ":rank":"3", ":title":"title 3", ":year":"2012", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"}'
45
- #text = '{"id":"tt0111161","rank":"1","title":"The Shawshank Redemption","fullTitle":"The Shawshank Redemption (1994)","year":"1994","image":"https://m.media-amazon.com/images/M/MV5BMDFkYTc0MGEtZmNhMC00ZDIzLWFmNTEtODM1ZmRlYWMwMWFmXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Frank Darabont (dir.), Tim Robbins, Morgan Freeman","imDbRating":"9.2","imDbRatingCount":"2650504"},{"id":"tt0068646","rank":"2","title":"The Godfather","fullTitle":"The Godfather (1972)","year":"1972","image":"https://m.media-amazon.com/images/M/MV5BM2MyNjYxNmUtYTAwNi00MTYxLWJmNWYtYzZlODY3ZTk3OTFlXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Francis Ford Coppola (dir.), Marlon Brando, Al Pacino","imDbRating":"9.2","imDbRatingCount":"1837317"},{"id":"tt0468569","rank":"3","title":"The Dark Knight","fullTitle":"The Dark Knight (2008)","year":"2008","image":"https://m.media-amazon.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Christopher Nolan (dir.), Christian Bale, Heath Ledger","imDbRating":"9.0","imDbRatingCount":"2622617"},{"id":"tt0071562","rank":"4","title":"The Godfather Part II","fullTitle":"The Godfather Part II (1974)","year":"1974","image":"https://m.media-amazon.com/images/M/MV5BMWMwMGQzZTItY2JlNC00OWZiLWIyMDctNDk2ZDQ2YjRjMWQ0XkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Francis Ford Coppola (dir.), Al Pacino, Robert De Niro","imDbRating":"9.0","imDbRatingCount":"1259016"},{"id":"tt0050083","rank":"5","title":"12 Angry Men","fullTitle":"12 Angry Men (1957)","year":"1957","image":"https://m.media-amazon.com/images/M/MV5BMWU4N2FjNzYtNTVkNC00NzQ0LTg0MjAtYTJlMjFhNGUxZDFmXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Sidney Lumet (dir.), Henry Fonda, Lee J. Cobb","imDbRating":"9.0","imDbRatingCount":"782597"}'
46
- text.gsub('},','}').gsub('"errorMessage":""}','')
47
- end
48
-
49
-
50
- def get_all_films(text)
40
+ #text = '{"id":"1424411", ":rank":"1", ":title":"title 1", ":year":"1990", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"},{"id":"9352791", ":rank":"2", ":title":"title 2", ":year":"2006", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"},{"id":"1908543", ":rank":"3", ":title":"title 3", ":year":"2012", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"}'
41
+ #text = '{"id":"tt0111161","rank":"1","title":"The Shawshank Redemption","fullTitle":"The Shawshank Redemption (1994)","year":"1994","image":"https://m.media-amazon.com/images/M/MV5BMDFkYTc0MGEtZmNhMC00ZDIzLWFmNTEtODM1ZmRlYWMwMWFmXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Frank Darabont (dir.), Tim Robbins, Morgan Freeman","imDbRating":"9.2","imDbRatingCount":"2650504"},{"id":"tt0068646","rank":"2","title":"The Godfather","fullTitle":"The Godfather (1972)","year":"1972","image":"https://m.media-amazon.com/images/M/MV5BM2MyNjYxNmUtYTAwNi00MTYxLWJmNWYtYzZlODY3ZTk3OTFlXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Francis Ford Coppola (dir.), Marlon Brando, Al Pacino","imDbRating":"9.2","imDbRatingCount":"1837317"},{"id":"tt0468569","rank":"3","title":"The Dark Knight","fullTitle":"The Dark Knight (2008)","year":"2008","image":"https://m.media-amazon.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Christopher Nolan (dir.), Christian Bale, Heath Ledger","imDbRating":"9.0","imDbRatingCount":"2622617"},{"id":"tt0071562","rank":"4","title":"The Godfather Part II","fullTitle":"The Godfather Part II (1974)","year":"1974","image":"https://m.media-amazon.com/images/M/MV5BMWMwMGQzZTItY2JlNC00OWZiLWIyMDctNDk2ZDQ2YjRjMWQ0XkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Francis Ford Coppola (dir.), Al Pacino, Robert De Niro","imDbRating":"9.0","imDbRatingCount":"1259016"},{"id":"tt0050083","rank":"5","title":"12 Angry Men","fullTitle":"12 Angry Men (1957)","year":"1957","image":"https://m.media-amazon.com/images/M/MV5BMWU4N2FjNzYtNTVkNC00NzQ0LTg0MjAtYTJlMjFhNGUxZDFmXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Sidney Lumet (dir.), Henry Fonda, Lee J. Cobb","imDbRating":"9.0","imDbRatingCount":"782597"}'
42
+ text.gsub('},', '}').gsub('"errorMessage":""}', '')
43
+ end
51
44
 
52
- arr_films = []
53
- while text.index('}') != nil
54
- ind_start = 0
55
- ind_finish = text.index('}')
56
- dist = ind_finish - ind_start + 1
57
- arr_films << text[ind_start, dist].gsub(' "','"')
58
- text = text.gsub(text[ind_start, dist], '')
59
- end
45
+ def get_all_films(text)
60
46
 
61
- rezult = []
62
- arr_films.each do|f|
63
- rezult << Film.new(f)
64
- end
47
+ arr_films = []
48
+ while text.index('}') != nil
49
+ ind_start = 0
50
+ ind_finish = text.index('}')
51
+ dist = ind_finish - ind_start + 1
52
+ arr_films << text[ind_start, dist].gsub(' "', '"')
53
+ text = text.gsub(text[ind_start, dist], '')
54
+ end
65
55
 
66
- rezult
67
- end
56
+ rezult = []
57
+ arr_films.each do |f|
58
+ rezult << Film.new(f)
68
59
  end
69
- end
70
60
 
61
+ rezult
62
+ end
@@ -1,130 +1,124 @@
1
1
  require_relative 'parsing_games'
2
2
 
3
- module DreamTeam
4
- module Table_game
5
- class Table_game_page
6
- def create_table_with_user_game(path, user_id)
7
- file_html = File.new(path + "/table_game.html", "w+")
8
- user_info = get_user_information(user_id)
9
- file_html.puts "<style type='text/css'>
10
- .table {
11
- width: 100%;
12
- border: none;
13
- margin-bottom: 20px;
14
- }
15
- .table thead th {
16
- font-weight: bold;
17
- text-align: left;
18
- border: none;
19
- padding: 10px 15px;
20
- background: #d8d8d8;
21
- font-size: 14px;
22
- }
23
- .table thead tr th:first-child {
24
- border-radius: 8px 0 0 8px;
25
- }
26
- .table thead tr th:last-child {
27
- border-radius: 0 8px 8px 0;
28
- }
29
- .table tbody td {
30
- text-align: left;
31
- border: none;
32
- padding: 10px 15px;
33
- font-size: 14px;
34
- vertical-align: top;
35
- }
36
- .table tbody tr:nth-child(even){
37
- background: #f3f3f3;
38
- }
39
- .table tbody tr td:first-child {
40
- border-radius: 8px 0 0 8px;
41
- }
42
- .table tbody tr td:last-child {
43
- border-radius: 0 8px 8px 0;
44
- }
45
- </style>
3
+ def create_table_with_user_game(path, user_id)
4
+ file_html = File.new(path + "/table_game.html", "w+")
5
+ user_info = get_user_information(user_id)
6
+ file_html.puts "<style type='text/css'>
7
+ .table {
8
+ width: 100%;
9
+ border: none;
10
+ margin-bottom: 20px;
11
+ }
12
+ .table thead th {
13
+ font-weight: bold;
14
+ text-align: left;
15
+ border: none;
16
+ padding: 10px 15px;
17
+ background: #d8d8d8;
18
+ font-size: 14px;
19
+ }
20
+ .table thead tr th:first-child {
21
+ border-radius: 8px 0 0 8px;
22
+ }
23
+ .table thead tr th:last-child {
24
+ border-radius: 0 8px 8px 0;
25
+ }
26
+ .table tbody td {
27
+ text-align: left;
28
+ border: none;
29
+ padding: 10px 15px;
30
+ font-size: 14px;
31
+ vertical-align: top;
32
+ }
33
+ .table tbody tr:nth-child(even){
34
+ background: #f3f3f3;
35
+ }
36
+ .table tbody tr td:first-child {
37
+ border-radius: 8px 0 0 8px;
38
+ }
39
+ .table tbody tr td:last-child {
40
+ border-radius: 0 8px 8px 0;
41
+ }
42
+ </style>
46
43
 
47
- <table class='table'>
48
- <thead>
49
- <img src = '#{user_info[:avatar]}'>
50
- #{user_info[:username]}
51
- <tr>
52
- <th>Game</th>
53
- <th>Image</th>
54
- <th>Price</th>
55
- <th>Developers</th>
56
- <th>Date</th>
57
- <th>Description</th>
58
- <th>Recommendation</th>
59
- <th>Time In The Game</th>
60
- </tr>
61
- </thead>
62
- <tbody>"
44
+ <table class='table'>
45
+ <thead>
46
+ <img src = '#{user_info[:avatar]}'>
47
+ #{user_info[:username]}
48
+ <tr>
49
+ <th>Game</th>
50
+ <th>Image</th>
51
+ <th>Price</th>
52
+ <th>Developers</th>
53
+ <th>Date</th>
54
+ <th>Description</th>
55
+ <th>Recommendation</th>
56
+ <th>Time In The Game</th>
57
+ </tr>
58
+ </thead>
59
+ <tbody>"
63
60
 
64
- games_information = information_of_games(get_user_games(user_id))
65
- games_information.each do |elem|
66
- file_html.puts "<tr>"
67
- file_html.puts "<th>"
68
- if elem[:name].nil?
69
- file_html.puts "<span style = 'font-size:20pt'> - </span>"
70
- else
71
- file_html.puts elem[:name]
72
- end
73
- file_html.puts "</th>"
74
- file_html.puts "<th>"
75
- file_html.puts "<img src = '#{elem[:img]}'
76
- width = '220'
77
- height = '102'
78
- alt = 'Picture of the game'>"
79
- file_html.puts "</th>"
80
- file_html.puts "<th>"
81
- if elem[:price].nil?
82
- file_html.puts "<span style = 'font-size:20pt'> - </span>"
83
- else
84
- file_html.puts elem[:price]
85
- end
86
- file_html.puts "</th>"
87
- file_html.puts "<th>"
88
- if elem[:developers].nil?
89
- file_html.puts "<span style = 'font-size:20pt'> - </span>"
90
- else
91
- file_html.puts elem[:developers]
92
- end
93
- file_html.puts "</th>"
94
- file_html.puts "<th>"
95
- if elem[:date].nil?
96
- file_html.puts "<span style = 'font-size:20pt'> - </span>"
97
- else
98
- file_html.puts elem[:date]
99
- end
100
- file_html.puts "</th>"
101
- file_html.puts "<th>"
102
- if elem[:desc].nil?
103
- file_html.puts "<span style = 'font-size:20pt'> - </span>"
104
- else
105
- file_html.puts elem[:desc]
106
- end
107
- file_html.puts "</th>"
108
- file_html.puts "<th>"
109
- if elem[:recommendations].nil?
110
- file_html.puts "<span style = 'font-size:20pt'> - </span>"
111
- else
112
- file_html.puts elem[:recommendations]
113
- end
114
- file_html.puts "</th>"
115
- file_html.puts "<th>"
116
- if elem[:time] == 0
117
- file_html.puts "0"
118
- else
119
- file_html.puts "#{elem[:time].to_i/60}h #{-(elem[:time].to_i/60*60 - elem[:time].to_i)}min"
120
- end
121
- file_html.puts "</th>"
122
- file_html.puts "</tr>"
123
- end
124
- file_html.puts "</tbody>
125
- </table>"
126
- file_html.close
127
- end
61
+ games_information = information_of_games(get_user_games(user_id))
62
+ games_information.each do |elem|
63
+ file_html.puts "<tr>"
64
+ file_html.puts "<th>"
65
+ if elem[:name].nil?
66
+ file_html.puts "<span style = 'font-size:20pt'> - </span>"
67
+ else
68
+ file_html.puts elem[:name]
128
69
  end
70
+ file_html.puts "</th>"
71
+ file_html.puts "<th>"
72
+ file_html.puts "<img src = '#{elem[:img]}'
73
+ width = '220'
74
+ height = '102'
75
+ alt = 'Picture of the game'>"
76
+ file_html.puts "</th>"
77
+ file_html.puts "<th>"
78
+ if elem[:price].nil?
79
+ file_html.puts "<span style = 'font-size:20pt'> - </span>"
80
+ else
81
+ file_html.puts elem[:price]
82
+ end
83
+ file_html.puts "</th>"
84
+ file_html.puts "<th>"
85
+ if elem[:developers].nil?
86
+ file_html.puts "<span style = 'font-size:20pt'> - </span>"
87
+ else
88
+ file_html.puts elem[:developers]
89
+ end
90
+ file_html.puts "</th>"
91
+ file_html.puts "<th>"
92
+ if elem[:date].nil?
93
+ file_html.puts "<span style = 'font-size:20pt'> - </span>"
94
+ else
95
+ file_html.puts elem[:date]
96
+ end
97
+ file_html.puts "</th>"
98
+ file_html.puts "<th>"
99
+ if elem[:desc].nil?
100
+ file_html.puts "<span style = 'font-size:20pt'> - </span>"
101
+ else
102
+ file_html.puts elem[:desc]
103
+ end
104
+ file_html.puts "</th>"
105
+ file_html.puts "<th>"
106
+ if elem[:recommendations].nil?
107
+ file_html.puts "<span style = 'font-size:20pt'> - </span>"
108
+ else
109
+ file_html.puts elem[:recommendations]
110
+ end
111
+ file_html.puts "</th>"
112
+ file_html.puts "<th>"
113
+ if elem[:time] == 0
114
+ file_html.puts "0"
115
+ else
116
+ file_html.puts "#{elem[:time].to_i / 60}h #{-(elem[:time].to_i / 60 * 60 - elem[:time].to_i)}min"
117
+ end
118
+ file_html.puts "</th>"
119
+ file_html.puts "</tr>"
129
120
  end
130
- end
121
+ file_html.puts "</tbody>
122
+ </table>"
123
+ file_html.close
124
+ end
@@ -1,70 +1,64 @@
1
1
  require 'open-uri'
2
2
  require 'nokogiri'
3
3
 
4
- module DreamTeam
5
- module Parsing_game
6
- class Parsing_steam_game
7
- def get_user_information(steam_id)
8
- url = Nokogiri::HTML5(URI.open('https://steamcommunity.com/profiles/' + steam_id + '/?xml=1')).to_s
9
- username = url[/<steamid><!--\[CDATA\[(?<username>.*)\]\]--><\/steamid>/, 1]
10
- avatar = url[/<avataricon><!--\[CDATA\[(?<avatar>.*)\]\]--><\/avataricon>/, 1]
11
- {username: username, avatar: avatar}
12
- end
4
+ def get_user_information(steam_id)
5
+ url = Nokogiri::HTML5(URI.open('https://steamcommunity.com/profiles/' + steam_id + '/?xml=1')).to_s
6
+ username = url[/<steamid><!--\[CDATA\[(?<username>.*)\]\]--><\/steamid>/, 1]
7
+ avatar = url[/<avataricon><!--\[CDATA\[(?<avatar>.*)\]\]--><\/avataricon>/, 1]
8
+ { username: username, avatar: avatar }
9
+ end
13
10
 
14
- def get_user_games(steam_id)
15
- res = []
16
- begin
17
- url = Nokogiri::HTML5(URI.open('https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?steamid=' +
18
- + steam_id + '&key=' + 'FB8E10E3C18DFD06F605ACF4D049866A')).to_s
19
- rescue
20
- return res
21
- end
22
- arr = url.split(',')
23
- last_id = ''
24
- arr.each do |a|
25
- id = a.match(/"appid":(?<id>.*)/)
26
- if !id.nil?
27
- last_id = id[:id]
28
- else
29
- time = a.match(/"playtime_forever":(?<time>.*)/)
30
- if !time.nil?
31
- res.push({id: last_id, time: time[:time]})
32
- end
33
- end
34
- end
35
- res
11
+ def get_user_games(steam_id)
12
+ res = []
13
+ begin
14
+ url = Nokogiri::HTML5(URI.open('https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?steamid=' +
15
+ +steam_id + '&key=' + 'FB8E10E3C18DFD06F605ACF4D049866A')).to_s
16
+ rescue
17
+ return res
18
+ end
19
+ arr = url.split(',')
20
+ last_id = ''
21
+ arr.each do |a|
22
+ id = a.match(/"appid":(?<id>.*)/)
23
+ if !id.nil?
24
+ last_id = id[:id]
25
+ else
26
+ time = a.match(/"playtime_forever":(?<time>.*)/)
27
+ if !time.nil?
28
+ res.push({ id: last_id, time: time[:time] })
36
29
  end
30
+ end
31
+ end
32
+ res
33
+ end
37
34
 
38
- def information_of_games(games_id)
39
- res = []
40
- games_id.each do |g|
41
- begin
42
- url = Nokogiri::HTML5(URI.open('https://store.steampowered.com/api/appdetails/?appids=' + g[:id])).to_s
43
- rescue
44
- next
45
- end
46
- name = url[/"name":"(?<name>.*)","steam_/, 1]
47
- time = g[:time]
48
- date = url[/date":"(?<date>.*)"},"su/, 1]
49
- price = url[/nal_formatted":"(?<price>.*) pуб\."},"pac/, 1]
50
- if price == nil
51
- price = url[/nal_formatted":"(?<price>.*)"},"pac/, 1]
52
- else
53
- price += ' rub'
54
- end
55
- developers = url[/"developers":\[(?<developers>.*)\],"publishers"/, 1]
56
- if developers != nil
57
- developers = developers.delete "\""
58
- end
59
- recommendations = url[/tions":{"total":(?<recommendations>\d*)/, 1]
60
- desc = url[/t_description":"(?<desc>.*)","sup/, 1]
61
- img = url[/"header_image":"(?<img>.*)","website"/, 1]
62
-
63
- res.push({name: name, time: time, date: date, price: price, developers: developers,
64
- recommendations: recommendations, desc: desc, img: img})
65
- end
66
- res
67
- end
35
+ def information_of_games(games_id)
36
+ res = []
37
+ games_id.each do |g|
38
+ begin
39
+ url = Nokogiri::HTML5(URI.open('https://store.steampowered.com/api/appdetails/?appids=' + g[:id])).to_s
40
+ rescue
41
+ next
42
+ end
43
+ name = url[/"name":"(?<name>.*)","steam_/, 1]
44
+ time = g[:time]
45
+ date = url[/date":"(?<date>.*)"},"su/, 1]
46
+ price = url[/nal_formatted":"(?<price>.*) pуб\."},"pac/, 1]
47
+ if price == nil
48
+ price = url[/nal_formatted":"(?<price>.*)"},"pac/, 1]
49
+ else
50
+ price += ' rub'
68
51
  end
52
+ developers = url[/"developers":\[(?<developers>.*)\],"publishers"/, 1]
53
+ if developers != nil
54
+ developers = developers.delete "\""
55
+ end
56
+ recommendations = url[/tions":{"total":(?<recommendations>\d*)/, 1]
57
+ desc = url[/t_description":"(?<desc>.*)","sup/, 1]
58
+ img = url[/"header_image":"(?<img>.*)","website"/, 1]
59
+
60
+ res.push({ name: name, time: time, date: date, price: price, developers: developers,
61
+ recommendations: recommendations, desc: desc, img: img })
69
62
  end
63
+ res
70
64
  end
@@ -4,7 +4,7 @@ require 'DreamTeam/Films/html_films_table'
4
4
  module DreamTeam
5
5
  module Html_main
6
6
  class Html_main_page
7
- def create_main(path, steam_id)
7
+ def self.create_main(path, steam_id)
8
8
  create_table_with_user_game(path, steam_id)
9
9
  create_table_with_film(path)
10
10
  file_html = File.new(path + '/main_table.html', 'w+')
@@ -41,3 +41,5 @@ module DreamTeam
41
41
  end
42
42
  end
43
43
  end
44
+
45
+ DreamTeam::Html_main::Html_main_page.create_main("C:/ЮФУ", "76561198271666506")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DreamTeam
4
- VERSION = "1.0.5"
4
+ VERSION = "1.0.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: DreamTeam
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spooky_Loki