Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Create an web-app for comments analysis #301

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

simonovich
Copy link
Contributor

Номер

2230

Номер задания

3

Ссылка на видео с демо

https://youtu.be/6xwCXowmNr0

Комментарии

Задание было сложное, но интересное. Моё первое веб-приложение на ruby!

Списочек ресурсов, которые поддерживали меня в этом непростом деле:

  1. An Introduction to Slim Templates
  2. Ruby Templating With Slim: Part 2
  3. https://stackoverflow.com
  4. http://engineering.continuity.net/using-ruby-and-capybara-to-scrape/
  5. Sinatra on SlideShare
  6. Sinatra Documentation
  7. Sinatra: Up and Running by Konstantin Haase, Alan Harris
  8. Quickstart for Text Analytics API with Ruby

end

#content = JSONParser.new('https://comments.api.onliner.by/news/people.post/570149/comments?limit=5').comments
#p content

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 #.

end
end

#content = JSONParser.new('https://comments.api.onliner.by/news/people.post/570149/comments?limit=5').comments

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 #.


def filter_response(response)
response.map do |elem|
elem unless (elem.select {|hash,value| hash['marks'] && value['likes'] > 0}) == {}

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 }.

private

def send_comments_request
json = open(@comments_url).read

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.

end

def comments
#@comments_json = filter_response(send_comments_request)

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'

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") }

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'

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'

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'

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.

end

def comments
comments = send_comments_request

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

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

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'

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants