-
Notifications
You must be signed in to change notification settings - Fork 43
Create an web-app for comments analysis #301
base: master
Are you sure you want to change the base?
Conversation
2230/3/app/helpers/json_parser.rb
Outdated
end | ||
|
||
#content = JSONParser.new('https://comments.api.onliner.by/news/people.post/570149/comments?limit=5').comments | ||
#p content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/LeadingCommentSpace: Missing space after #.
2230/3/app/helpers/json_parser.rb
Outdated
end | ||
end | ||
|
||
#content = JSONParser.new('https://comments.api.onliner.by/news/people.post/570149/comments?limit=5').comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/LeadingCommentSpace: Missing space after #.
2230/3/app/helpers/json_parser.rb
Outdated
|
||
def filter_response(response) | ||
response.map do |elem| | ||
elem unless (elem.select {|hash,value| hash['marks'] && value['likes'] > 0}) == {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Layout/SpaceAfterComma: Space missing after comma.
Style/NumericPredicate: Use (value['likes']).positive? instead of value['likes'] > 0.
Layout/SpaceInsideBlockBraces: Space missing inside }.
2230/3/app/helpers/json_parser.rb
Outdated
private | ||
|
||
def send_comments_request | ||
json = open(@comments_url).read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security/Open: The use of Kernel#open is a serious security risk.
2230/3/app/helpers/json_parser.rb
Outdated
end | ||
|
||
def comments | ||
#@comments_json = filter_response(send_comments_request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/LeadingCommentSpace: Missing space after #.
config_file '../../config.yml' | ||
|
||
get '/' do | ||
slim :'index' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/SymbolLiteral: Do not use strings for word-like symbol literals.
require 'sinatra/config_file' | ||
|
||
class ApplicationController < Sinatra::Base | ||
set :views, Proc.new { File.join(root, "../views") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/AmbiguousBlockAssociation: Parenthesize the param Proc.new { File.join(root, "../views") } to make sure that the block will be associated with the Proc.new method call.
Style/Proc: Use proc instead of Proc.new.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
2230/3/Gemfile
Outdated
gem 'thin' | ||
gem 'ohm' | ||
gem 'slim' | ||
gem 'pry' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem pry should appear before slim.
2230/3/Gemfile
Outdated
gem 'sinatra-config-file' | ||
gem 'shotgun' | ||
gem 'thin' | ||
gem 'ohm' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem ohm should appear before thin.
2230/3/Gemfile
Outdated
gem 'capybara' | ||
gem 'sinatra' | ||
gem 'sinatra-config-file' | ||
gem 'shotgun' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem shotgun should appear before sinatra-config-file.
2230/3/app/helpers/json_parser.rb
Outdated
end | ||
|
||
def comments | ||
comments = send_comments_request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UselessAssignment: Useless assignment to variable - comments.
@comments_url = comments_url | ||
end | ||
|
||
def comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/DuplicateMethods: Method JSONParser#comments is defined at both 2230/3/app/helpers/json_parser.rb:6 and 2230/3/app/helpers/json_parser.rb:12.
comments = JSONParser.new(comments_url).comments | ||
rating = AzureSender.new(comments, settings.access_key).run | ||
article = Article.create \ | ||
url: params[:article_new], title: html_parser.article_title, rating: rating.sum / rating.size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
2230/3/Gemfile
Outdated
gem 'pry' | ||
gem 'shotgun' | ||
gem 'sinatra-config-file' | ||
gem 'sinatra' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem sinatra should appear before sinatra-config-file.
Номер
2230
Номер задания
3
Ссылка на видео с демо
https://youtu.be/6xwCXowmNr0
Комментарии
Задание было сложное, но интересное. Моё первое веб-приложение на ruby!
Списочек ресурсов, которые поддерживали меня в этом непростом деле: