DreamTeam 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +12 -0
- data/images/logo1.png +0 -0
- data/images/logo2.png +0 -0
- data/lib/DreamTeam/Films/html_table.rb +79 -0
- data/lib/DreamTeam/Films/parsing_films.rb +64 -0
- data/lib/DreamTeam/Games/html_table.rb +124 -0
- data/lib/DreamTeam/Games/parsing_games.rb +65 -0
- data/lib/DreamTeam/html_main.rb +43 -0
- data/lib/DreamTeam/version.rb +5 -0
- data/lib/DreamTeam.rb +12 -0
- data/sig/DreamTeam.rbs +4 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 44fe4579aca3b8a24360b67ef7460fb30b6e106902eda1a0d57c417e662c825c
|
4
|
+
data.tar.gz: bdb2ecf2275d5dd44a0f0d3a2c92e33474f308254db219a2120a7f090f6827f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f702732d72c19bc91b8d51ec8ff0cf8e3009e3150e14a20331b306ea2b8b473ef120e722dbc9e085059b22f8829fde69e3a5d2c42dd2a9980d8a886689543bfa
|
7
|
+
data.tar.gz: a7f6bb1499b917d25a0580e176f2f4690382cff8232728c618b51cdc892870b0933a0e7982fad7903bb21c89898d25e8c42c5aa38e96c3213aa37912c04c25e0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at viter02@inbox.ru. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Spooky_Loki
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# DreamTeam
|
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/DreamTeam`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
This gem allows you to get information about the steam user's games and the top 250 IMDb movies.
|
6
|
+
Information about steam games includes:
|
7
|
+
-Name
|
8
|
+
-Picture
|
9
|
+
-Price
|
10
|
+
-Developer
|
11
|
+
-Release date
|
12
|
+
-Description
|
13
|
+
-Number of recommendations
|
14
|
+
-Time spent in the game.
|
15
|
+
Information about the films includes:
|
16
|
+
-Place in the rating
|
17
|
+
-Film name
|
18
|
+
-Full name
|
19
|
+
-Release date
|
20
|
+
-Picture
|
21
|
+
-The actors
|
22
|
+
-Rating
|
23
|
+
-Rating Count
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Install the gem and add to the application's Gemfile by executing:
|
28
|
+
|
29
|
+
$ bundle add DreamTeam
|
30
|
+
|
31
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
32
|
+
|
33
|
+
$ gem install DreamTeam
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
TODO: Write usage instructions here
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Spoky-Loki/DreamTeam. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Spoky-Loki/DreamTeam/blob/master/CODE_OF_CONDUCT.md).
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
52
|
+
|
53
|
+
## Code of Conduct
|
54
|
+
|
55
|
+
Everyone interacting in the DreamTeam project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Spoky-Loki/DreamTeam/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/images/logo1.png
ADDED
Binary file
|
data/images/logo2.png
ADDED
Binary file
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative 'parsing_films'
|
2
|
+
|
3
|
+
def create_table_with_film
|
4
|
+
fileHtml = File.new("lib/DreamTeam/Films/table.html", "w+")
|
5
|
+
|
6
|
+
fileHtml.puts "<style>
|
7
|
+
.table_dark {
|
8
|
+
font-family: 'Lucida Sans Unicode', 'Lucida Grande', Sans-Serif;
|
9
|
+
font-size: 14px;
|
10
|
+
width: 90%;
|
11
|
+
text-align: left;
|
12
|
+
border-collapse: collapse;
|
13
|
+
background: #252F48;
|
14
|
+
margin: 10px;
|
15
|
+
}
|
16
|
+
.table_dark th {
|
17
|
+
color: #EDB749;
|
18
|
+
border-bottom: 1px solid #37B5A5;
|
19
|
+
padding: 12px 17px;
|
20
|
+
}
|
21
|
+
.table_dark td {
|
22
|
+
color: #CAD4D6;
|
23
|
+
border-bottom: 1px solid #37B5A5;
|
24
|
+
border-right: 1px solid #37B5A5;
|
25
|
+
padding: 7px 17px;
|
26
|
+
}
|
27
|
+
.table_dark tr:last-child td {
|
28
|
+
border-bottom: none;
|
29
|
+
}
|
30
|
+
.table_dark td:last-child {
|
31
|
+
border-right: none;
|
32
|
+
}
|
33
|
+
.table_dark tr:hover td {
|
34
|
+
text-decoration: underline;
|
35
|
+
} </style>
|
36
|
+
|
37
|
+
<table class='table_dark'>
|
38
|
+
<tr>
|
39
|
+
<th>Rang</th>
|
40
|
+
<th>Film name</th>
|
41
|
+
<th>Full name</th>
|
42
|
+
<th>Year</th>
|
43
|
+
<th>Image</th>
|
44
|
+
<th>The actors</th>
|
45
|
+
<th>Rating</th>
|
46
|
+
<th>Rating Count</th>
|
47
|
+
|
48
|
+
</tr>"
|
49
|
+
|
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}'
|
63
|
+
width = '102'
|
64
|
+
height = '160'>"
|
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>"
|
72
|
+
|
73
|
+
|
74
|
+
fileHtml.puts "</tr>"
|
75
|
+
end
|
76
|
+
|
77
|
+
fileHtml.puts "</table>"
|
78
|
+
fileHtml.close
|
79
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'json'
|
4
|
+
|
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
|
22
|
+
|
23
|
+
def <=>(an_other)
|
24
|
+
an_other.year <=> self.year
|
25
|
+
end
|
26
|
+
|
27
|
+
def help(arr, i)
|
28
|
+
return arr[i][arr[i].index(':"') + 2, arr[i].length - arr[i].index(':"') - 3]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_films_id()
|
33
|
+
uri = 'https://imdb-api.com/en/API/Top250Movies/k_uq4za59n'
|
34
|
+
doc = Nokogiri::HTML(URI.open(uri))
|
35
|
+
|
36
|
+
text = doc.text.gsub('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
37
|
+
"http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>', '')
|
38
|
+
text = text.gsub('{"items":[', '').gsub(']','')
|
39
|
+
|
40
|
+
|
41
|
+
#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"}'
|
42
|
+
#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"}'
|
43
|
+
text.gsub('},','}').gsub('"errorMessage":""}','')
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def get_all_films(text)
|
48
|
+
|
49
|
+
arr_films = []
|
50
|
+
while text.index('}') != nil
|
51
|
+
ind_start = 0
|
52
|
+
ind_finish = text.index('}')
|
53
|
+
dist = ind_finish - ind_start + 1
|
54
|
+
arr_films << text[ind_start, dist].gsub(' "','"')
|
55
|
+
text = text.gsub(text[ind_start, dist], '')
|
56
|
+
end
|
57
|
+
|
58
|
+
rezult = []
|
59
|
+
arr_films.each do|f|
|
60
|
+
rezult << Film.new(f)
|
61
|
+
end
|
62
|
+
|
63
|
+
rezult
|
64
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require_relative 'parsing_games'
|
2
|
+
|
3
|
+
def create_table_with_user_game(user_id)
|
4
|
+
file_html = File.new("lib/DreamTeam/Games/table.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>
|
43
|
+
|
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>"
|
60
|
+
|
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]
|
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>"
|
120
|
+
end
|
121
|
+
file_html.puts "</tbody>
|
122
|
+
</table>"
|
123
|
+
file_html.close
|
124
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
require_relative 'api_key'
|
4
|
+
|
5
|
+
def get_user_information(steam_id)
|
6
|
+
url = Nokogiri::HTML5(URI.open('https://steamcommunity.com/profiles/' + steam_id + '/?xml=1')).to_s
|
7
|
+
username = url[/<steamid><!--\[CDATA\[(?<username>.*)\]\]--><\/steamid>/, 1]
|
8
|
+
avatar = url[/<avataricon><!--\[CDATA\[(?<avatar>.*)\]\]--><\/avataricon>/, 1]
|
9
|
+
{username: username, avatar: avatar}
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_user_games(steam_id)
|
13
|
+
res = []
|
14
|
+
begin
|
15
|
+
url = Nokogiri::HTML5(URI.open('https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?steamid=' +
|
16
|
+
+ steam_id + '&key=' + GetKey())).to_s
|
17
|
+
rescue
|
18
|
+
return res
|
19
|
+
end
|
20
|
+
arr = url.split(',')
|
21
|
+
last_id = ''
|
22
|
+
arr.each do |a|
|
23
|
+
id = a.match(/"appid":(?<id>.*)/)
|
24
|
+
if !id.nil?
|
25
|
+
last_id = id[:id]
|
26
|
+
else
|
27
|
+
time = a.match(/"playtime_forever":(?<time>.*)/)
|
28
|
+
if !time.nil?
|
29
|
+
res.push({id: last_id, time: time[:time]})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
res
|
34
|
+
end
|
35
|
+
|
36
|
+
def information_of_games(games_id)
|
37
|
+
res = []
|
38
|
+
games_id.each do |g|
|
39
|
+
begin
|
40
|
+
url = Nokogiri::HTML5(URI.open('https://store.steampowered.com/api/appdetails/?appids=' + g[:id])).to_s
|
41
|
+
rescue
|
42
|
+
next
|
43
|
+
end
|
44
|
+
name = url[/"name":"(?<name>.*)","steam_/, 1]
|
45
|
+
time = g[:time]
|
46
|
+
date = url[/date":"(?<date>.*)"},"su/, 1]
|
47
|
+
price = url[/nal_formatted":"(?<price>.*) pуб\."},"pac/, 1]
|
48
|
+
if price == nil
|
49
|
+
price = url[/nal_formatted":"(?<price>.*)"},"pac/, 1]
|
50
|
+
else
|
51
|
+
price += ' rub'
|
52
|
+
end
|
53
|
+
developers = url[/"developers":\[(?<developers>.*)\],"publishers"/, 1]
|
54
|
+
if developers != nil
|
55
|
+
developers = developers.delete "\""
|
56
|
+
end
|
57
|
+
recommendations = url[/tions":{"total":(?<recommendations>\d*)/, 1]
|
58
|
+
desc = url[/t_description":"(?<desc>.*)","sup/, 1]
|
59
|
+
img = url[/"header_image":"(?<img>.*)","website"/, 1]
|
60
|
+
|
61
|
+
res.push({name: name, time: time, date: date, price: price, developers: developers,
|
62
|
+
recommendations: recommendations, desc: desc, img: img})
|
63
|
+
end
|
64
|
+
res
|
65
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'DreamTeam/Games/html_table'
|
2
|
+
require 'DreamTeam/Films/html_table'
|
3
|
+
|
4
|
+
module DreamTeam
|
5
|
+
module Html_main
|
6
|
+
class Html_main_page
|
7
|
+
def create_main(steam_id)
|
8
|
+
create_table_with_user_game(steam_id)
|
9
|
+
create_table_with_film
|
10
|
+
file_html = File.new('lib/DreamTeam/main_table.html', 'w+')
|
11
|
+
file_html.puts "<!DOCTYPE html>
|
12
|
+
<html>
|
13
|
+
<head>
|
14
|
+
<title>Заголовок документа</title>
|
15
|
+
<style>
|
16
|
+
div
|
17
|
+
{
|
18
|
+
width: 100%; /* Размеры */
|
19
|
+
outline: '0';
|
20
|
+
border: '0'; /* Белая рамка */
|
21
|
+
}
|
22
|
+
div2
|
23
|
+
{
|
24
|
+
border-radius: 30%;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<div>
|
30
|
+
<p border='0'>
|
31
|
+
<div2>
|
32
|
+
<a href='Games/table.html'><img src='../../images/logo1.png' width=45% border='0' alt=''></a>
|
33
|
+
<a href='Films/table.html'><img src='../../images/logo2.png' width=45% border='0' alt=''></a>
|
34
|
+
</div2>
|
35
|
+
</p>
|
36
|
+
</div>
|
37
|
+
</body>
|
38
|
+
</html>"
|
39
|
+
file_html.close
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/DreamTeam.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "DreamTeam/version"
|
4
|
+
|
5
|
+
module DreamTeam
|
6
|
+
class Error < StandardError; end
|
7
|
+
require_relative "DreamTeam/Games/html_table"
|
8
|
+
require_relative "DreamTeam/Games/parsing_games"
|
9
|
+
require_relative "DreamTeam/Films/html_table"
|
10
|
+
require_relative "DreamTeam/Films/parsing_films"
|
11
|
+
require_relative "DreamTeam/html_main"
|
12
|
+
end
|
data/sig/DreamTeam.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: DreamTeam
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Spooky_Loki
|
8
|
+
- Rogalik
|
9
|
+
- dkozlikina
|
10
|
+
- ekaterina432
|
11
|
+
autorequire:
|
12
|
+
bindir: exe
|
13
|
+
cert_chain: []
|
14
|
+
date: 2022-10-27 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rake
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '13.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '13.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: minitest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5.0'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '5.0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: nokogiri
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
description: |-
|
59
|
+
This gem allows you to get information about the steam user's games and the top 250 IMDb movies.
|
60
|
+
Information about steam games includes:
|
61
|
+
-Name
|
62
|
+
-Picture
|
63
|
+
-Price
|
64
|
+
-Developer
|
65
|
+
-Release date
|
66
|
+
-Description
|
67
|
+
-Number of recommendations
|
68
|
+
-Time spent in the game.
|
69
|
+
Information about the films includes:
|
70
|
+
-Place in the rating
|
71
|
+
-Film name
|
72
|
+
-Full name
|
73
|
+
-Release date
|
74
|
+
-Picture
|
75
|
+
-The actors
|
76
|
+
-Rating
|
77
|
+
-Rating Count
|
78
|
+
email:
|
79
|
+
- viter02@inbox.ru
|
80
|
+
executables: []
|
81
|
+
extensions: []
|
82
|
+
extra_rdoc_files: []
|
83
|
+
files:
|
84
|
+
- CODE_OF_CONDUCT.md
|
85
|
+
- Gemfile
|
86
|
+
- LICENSE.txt
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- images/logo1.png
|
90
|
+
- images/logo2.png
|
91
|
+
- lib/DreamTeam.rb
|
92
|
+
- lib/DreamTeam/Films/html_table.rb
|
93
|
+
- lib/DreamTeam/Films/parsing_films.rb
|
94
|
+
- lib/DreamTeam/Games/html_table.rb
|
95
|
+
- lib/DreamTeam/Games/parsing_games.rb
|
96
|
+
- lib/DreamTeam/html_main.rb
|
97
|
+
- lib/DreamTeam/version.rb
|
98
|
+
- sig/DreamTeam.rbs
|
99
|
+
homepage: https://github.com/Spoky-Loki/DreamTeam
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata:
|
103
|
+
homepage_uri: https://github.com/Spoky-Loki/DreamTeam
|
104
|
+
source_code_uri: https://github.com/Spoky-Loki/DreamTeam.git
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 2.6.0
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubygems_version: 3.3.7
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: The Steam and Films parser is a Ruby library created as an exercise by Mehmat
|
124
|
+
students.
|
125
|
+
test_files: []
|