trendious 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +21 -0
- data/README.md +81 -0
- data/bin/trendious +5 -0
- data/lib/trendious.rb +1 -0
- data/lib/trendious/all.rb +3 -0
- data/lib/trendious/application.rb +56 -0
- data/lib/trendious/client.rb +31 -0
- data/lib/trendious/collection.rb +15 -0
- data/lib/trendious/entry.rb +33 -0
- data/lib/trendious/post.rb +4 -0
- data/lib/trendious/search.rb +17 -0
- data/lib/trendious/tag.rb +21 -0
- data/lib/trendious/tags.rb +17 -0
- data/lib/trendious/version.rb +3 -0
- data/trendious.gemspec +17 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2906af90658cc85c3b8b5921ebf229d95da9e5ff
|
4
|
+
data.tar.gz: 4ba8017325c6d46564380ff40b88a9a5104fdf85
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 028c5e7e5c733deba674e3b4bbaf690a2b2bff829b581ba3a4b4cdc78e4c318344fc021d842c377b6563e95d522e5a332d86be35e826d7c0bea93e1327e0bd9a
|
7
|
+
data.tar.gz: cd88683046a2d0c6f07dd729670b32eb4971fb781ffec541a9705655d9f125fcb0b9c119366b33e4f270f147a34af5ad91c1cfcb9f074a4cb9433239149febdb
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.2.4)
|
5
|
+
i18n (~> 0.7)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
i18n (0.7.0)
|
11
|
+
json (1.8.3)
|
12
|
+
minitest (5.8.1)
|
13
|
+
thread_safe (0.3.5)
|
14
|
+
tzinfo (1.2.2)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
activesupport
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
## About Trendious
|
2
|
+
|
3
|
+
Trendious helps you to get world best reviews from the fans about movies.
|
4
|
+
|
5
|
+
With the following request
|
6
|
+
```
|
7
|
+
trendious -q "Forrest Gump"
|
8
|
+
```
|
9
|
+
You should be able to get something similar to this
|
10
|
+
|
11
|
+
```
|
12
|
+
[0] Forrest Gump!
|
13
|
+
[1] Forrest Gump by Cutestreak Designs, 2012.
|
14
|
+
[2] 8-Bit Cinema Presents: Forrest Gump
|
15
|
+
[3] Forrest Gump Vs The Shawshank Redemption
|
16
|
+
[4] Forrest Gump 2: The Maze Runner
|
17
|
+
[5] Forrest Gump (1994) movie memories by MovieManCHAD
|
18
|
+
[6] Forrest Gump : After credit scene
|
19
|
+
[7] 12 Life Lessons Forrest Gump Taught Us
|
20
|
+
[8] Celebrate Forrest Gump's 20th Anniversary with an Honest Trailer
|
21
|
+
[9] Forrest Gump Gets Another Run With IMAX Release
|
22
|
+
```
|
23
|
+
|
24
|
+
To read the desired post you can easily access it by the index
|
25
|
+
|
26
|
+
```
|
27
|
+
trendious -q "Shawshank" -r 0
|
28
|
+
```
|
29
|
+
|
30
|
+
```
|
31
|
+
The Shawshank Redemption: An emotional masterpiece
|
32
|
+
Website link: http://moviepilot.com/reviews/2855793
|
33
|
+
|
34
|
+
Today I watched The Shawshank Redemption for the first time and I know that this film is considered one of the best films of all time, so my expectations were high to say the least. I wasn't disappointed at all this film is outstanding, so now I'm going to explain that in more detail. There are a ton of positives to this film, which include: a fantastic story, great story progression, great acting and there is a lot of emotion felt for the characters. To expand, the story in this film is fantastic and I was hooked from start to finish; with its 2 and a half hour run time I was afraid it could be slow, however the film had excellent story progression and I wasn't bored for a second. Any film with Morgan Freeman narrating is always good and makes this film even better, finally there is a lot of emotion in this film and in certain moments they are genuinely sad; the emotion in the film is not to the extent of 12 years a slave but it is still great not all films can truly move me. On the side of negatives there aren't any, it is a perfect film. Overall this film is a masterpiece and as I can't find any negatives at all I have to rate this film: 10/10
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
To change page of search result you can do it by adding key `-p`
|
39
|
+
|
40
|
+
```
|
41
|
+
trendious -q "Marvel" -p 3
|
42
|
+
```
|
43
|
+
|
44
|
+
Other killer feature with this application is to accessing trending, that's from where this application took his name.
|
45
|
+
|
46
|
+
```
|
47
|
+
trendious -T
|
48
|
+
```
|
49
|
+
```
|
50
|
+
[0] Great Directors
|
51
|
+
[1] Superheroes
|
52
|
+
[2] Oscars
|
53
|
+
[3] Pixar Movies
|
54
|
+
[4] Hidden Gems
|
55
|
+
[5] Sci-Fi Movies
|
56
|
+
[6] Comedy Movies
|
57
|
+
[7] Zombies
|
58
|
+
[8] Action Movies
|
59
|
+
...
|
60
|
+
```
|
61
|
+
|
62
|
+
To check the trending for the following tag add `-t`
|
63
|
+
|
64
|
+
```
|
65
|
+
trendious -T -t 2
|
66
|
+
```
|
67
|
+
|
68
|
+
Here you as well can change the page and read the relevant post with `-r [index]`
|
69
|
+
|
70
|
+
```
|
71
|
+
[0] The Revenant: The Stage Is Set For Leo's Crowning Glory
|
72
|
+
[1] 'The Revenant' Poster and its Sheer Beauty
|
73
|
+
[2] August: Osage County: Julia Roberts Gets Meryl Streep to Eat Her Bitchin' Fish
|
74
|
+
[3] Why can't Leonardo DiCaprio win an Oscar?
|
75
|
+
[4] LEGO Movie Snubbed. Budapest Leading. This Years Oscars Is Full Of Surprises!
|
76
|
+
[5] Will This Awesome 'How to Train Your Dragon 2' Making-Of Documentary Ensure The Movie Wins The Oscar?
|
77
|
+
[6] "Everything Is Awesome" Was Pretty Awesome Performed Live at the Oscars
|
78
|
+
[7] 12 Years a Slave (2013) - Non-Spoiler Review
|
79
|
+
[8] Two Jews On The Oscars
|
80
|
+
[9] New York Film Festival 2014: Whiplash Movie Review
|
81
|
+
```
|
data/bin/trendious
ADDED
data/lib/trendious.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative './trendious/all'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Trendious
|
4
|
+
class Application
|
5
|
+
def initialize
|
6
|
+
@client = Trendious::Client.new
|
7
|
+
@options = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: trendious [options]"
|
13
|
+
opts.on("-q", "--query [String]", String, "Search by name") {|o| @options[:query] = o }
|
14
|
+
opts.on("-R", "--read [Integer]", Integer, "Read entry with index") {|o| @options[:read] = o }
|
15
|
+
opts.on("-p", "--page [Integer]", Integer, "Select N page") {|o| @options[:page] = o }
|
16
|
+
opts.on("-T", "--tags", "Show tags") {|o| @options[:tags] = o }
|
17
|
+
opts.on("-t", "--trending [Integer]", Integer, "Select trending by index") {|o| @options[:trending] = o}
|
18
|
+
opts.on("-v", "--version", "Display current Trendious version") {|o| @options[:version] = o }
|
19
|
+
end.parse!
|
20
|
+
|
21
|
+
puts output
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def tags
|
27
|
+
@client.tags.entries
|
28
|
+
end
|
29
|
+
|
30
|
+
def posts
|
31
|
+
@client.posts_by_name(@options[:query], @options[:page]).entries
|
32
|
+
end
|
33
|
+
|
34
|
+
def read_entry(entry_by_idx)
|
35
|
+
entry = entry_by_idx.read
|
36
|
+
|
37
|
+
body = entry["body"] || entry["html_body"]
|
38
|
+
|
39
|
+
entry["title"] + "\n" +
|
40
|
+
"Website link: #{entry_by_idx.link}\n\n" +
|
41
|
+
body.gsub!(/<.*?>/, " ")
|
42
|
+
end
|
43
|
+
|
44
|
+
def output
|
45
|
+
return Trendious::VERSION if @options[:version]
|
46
|
+
if @options[:tags]
|
47
|
+
return read_entry(tags[@options[:trending]].trending(@options[:page]).entries[@options[:read]]) if @options[:read]
|
48
|
+
return tags[@options[:trending]].trending(@options[:page]).entries.each_with_index.map{|p,idx| "[#{idx}] #{p.title}" } if @options[:trending]
|
49
|
+
tags.each_with_index.map{|tag, idx| "[#{idx}] #{tag.name}" }
|
50
|
+
elsif @options[:query]
|
51
|
+
return read_entry(posts[@options[:read]]) if @options[:read]
|
52
|
+
posts.each_with_index.map{|p,idx| "[#{idx}] #{p.name}" }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Trendious
|
6
|
+
class Client
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
def search(hash = {})
|
11
|
+
query = {q: "marvel"}.merge!(hash)
|
12
|
+
query = query.map {|k,v| "#{k}=#{v}" }.join("&")
|
13
|
+
uri = URI("http://api.moviepilot.com/v3/search?#{query}")
|
14
|
+
puts "Request URI: #{uri}"
|
15
|
+
Trendious::Search.new Net::HTTP.get(uri)
|
16
|
+
end
|
17
|
+
|
18
|
+
def tags
|
19
|
+
Trendious::Tags.new Net::HTTP.get(URI('http://api.moviepilot.com/v4/tags'))
|
20
|
+
end
|
21
|
+
|
22
|
+
def posts_by_name(name, page = 0)
|
23
|
+
form_name = name.gsub!(' ', '%20')
|
24
|
+
search({q: name, without_type: "user,tag", page: page})
|
25
|
+
end
|
26
|
+
|
27
|
+
def tags_by_name(name, page = 0)
|
28
|
+
search({q: name, with_type: "tag", page: page})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
3
|
+
module Trendious
|
4
|
+
class Entry
|
5
|
+
attr_reader :entry
|
6
|
+
|
7
|
+
def initialize hash
|
8
|
+
@entry = hash
|
9
|
+
|
10
|
+
@entry.keys.each do |k|
|
11
|
+
self.class.instance_eval do
|
12
|
+
define_method(k) do
|
13
|
+
@entry[k]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def link
|
20
|
+
URI.join "http://moviepilot.com", type_path, id.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def type_path
|
24
|
+
"#{type.pluralize}/"
|
25
|
+
end
|
26
|
+
|
27
|
+
def read
|
28
|
+
uri = URI.join "http://api.moviepilot.com", "/v4/", type_path, id.to_s
|
29
|
+
|
30
|
+
JSON.parse(Net::HTTP.get(uri))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Trendious
|
2
|
+
class Search < Collection
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def initialize(res)
|
6
|
+
@response = JSON.parse(res)
|
7
|
+
end
|
8
|
+
|
9
|
+
def entries
|
10
|
+
@response['search'].map {|h| Post.new h }
|
11
|
+
end
|
12
|
+
|
13
|
+
def total
|
14
|
+
@response['total']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Trendious
|
2
|
+
class Tag < Entry
|
3
|
+
def trending(page = 0)
|
4
|
+
@page = page
|
5
|
+
fetch('trending')
|
6
|
+
end
|
7
|
+
|
8
|
+
def recent(page = 0)
|
9
|
+
@page = page
|
10
|
+
fetch('recent')
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def fetch(name)
|
16
|
+
uri = URI("http://api.moviepilot.com/v4/tags/#{slug}/recent?page=#{@page}")
|
17
|
+
puts "Request URI: #{uri}"
|
18
|
+
Trendious::Tags.new Net::HTTP.get(uri)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Trendious
|
2
|
+
class Tags < Collection
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def initialize(res)
|
6
|
+
@response = JSON.parse(res)
|
7
|
+
end
|
8
|
+
|
9
|
+
def entries
|
10
|
+
@response['collection'].map {|h| Tag.new h }
|
11
|
+
end
|
12
|
+
|
13
|
+
def find(name)
|
14
|
+
entries.select {|tag| tag.name.downcase.include? name.downcase }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/trendious.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'trendious/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'trendious'
|
7
|
+
s.version = Trendious::VERSION
|
8
|
+
s.date = '2015-10-25'
|
9
|
+
s.summary = "trendious"
|
10
|
+
s.description = "Trendious helps you to get world best reviews from the fans about movies."
|
11
|
+
s.authors = ["Viacheslav Rudkovskyi"]
|
12
|
+
s.email = 'rrubyist@gmail.com'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.executables = ['trendious']
|
15
|
+
s.homepage = 'http://github.com/rubyruby15/trendious'
|
16
|
+
s.license = 'MIT'
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trendious
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Viacheslav Rudkovskyi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Trendious helps you to get world best reviews from the fans about movies.
|
14
|
+
email: rrubyist@gmail.com
|
15
|
+
executables:
|
16
|
+
- trendious
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- Gemfile
|
21
|
+
- Gemfile.lock
|
22
|
+
- README.md
|
23
|
+
- bin/trendious
|
24
|
+
- lib/trendious.rb
|
25
|
+
- lib/trendious/all.rb
|
26
|
+
- lib/trendious/application.rb
|
27
|
+
- lib/trendious/client.rb
|
28
|
+
- lib/trendious/collection.rb
|
29
|
+
- lib/trendious/entry.rb
|
30
|
+
- lib/trendious/post.rb
|
31
|
+
- lib/trendious/search.rb
|
32
|
+
- lib/trendious/tag.rb
|
33
|
+
- lib/trendious/tags.rb
|
34
|
+
- lib/trendious/version.rb
|
35
|
+
- trendious.gemspec
|
36
|
+
homepage: http://github.com/rubyruby15/trendious
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.2.2
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: trendious
|
60
|
+
test_files: []
|