latest_tomatoes_cli_gem 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 41558d64363f890bf2a16d6851f8b4322619b378
4
+ data.tar.gz: 8345f908059b5777334d6afde1e270f36bd705b3
5
+ SHA512:
6
+ metadata.gz: 62217609fa7ef84faa5973f92c443990fab4ed6ea0fda2f46f5f1aa567aecf1b6deef59cc1bd2e92af2027ed7f95aa39eff3c0e9fa071971ff7ba1bbb5b1888c
7
+ data.tar.gz: 27305cce100ffcafd2a9c07ede41b23c6f0cf706b4738793b6fb29468bcb538b6874ab66efdac8ba6ccde06c803d0b0d1623a0abcba1680d672f4ce0d09b1ae9
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in latest_tomatoes.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 jenjiyi
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,38 @@
1
+ # LatestTomatoesCLIGem
2
+
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'latest_tomatoes_cli_gem'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install latest-tomatoes-cli-gem
19
+
20
+ ## Usage
21
+
22
+ Coming soon.
23
+
24
+ ## Development
25
+
26
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
+
28
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/latest-tomatoes-cli-gem.
33
+
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
38
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "latest_tomatoes_cli_gem"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+
4
+ require 'latest_tomatoes_cli_gem'
5
+
6
+ LatestTomatoes::CLI.new.call
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'latest_tomatoes_cli_gem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "latest_tomatoes_cli_gem"
8
+ spec.version = LatestTomatoes::VERSION
9
+ spec.authors = ["jenjiyi"]
10
+ spec.email = ["jenny.yamada@gmail.com"]
11
+
12
+ spec.summary = %q{Look up latest dvd and streaming releases.}
13
+ spec.homepage = "http://www.jennyy.com"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ # spec.bindir = "exe"
26
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.executables = ["latest_tomatoes_cli_gem"]
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "pry"
33
+ spec.add_development_dependency "rspec"
34
+
35
+ spec.add_dependency "nokogiri"
36
+ spec.add_dependency "json"
37
+
38
+ end
@@ -0,0 +1,8 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'json'
4
+
5
+ require_relative './latest_tomatoes_cli_gem/version'
6
+ require_relative './latest_tomatoes_cli_gem/movies'
7
+ require_relative './latest_tomatoes_cli_gem/cli'
8
+
@@ -0,0 +1,59 @@
1
+ class LatestTomatoes::CLI
2
+
3
+ def call
4
+ new_movies
5
+ input_1
6
+ adios
7
+ end
8
+
9
+ def new_movies
10
+ puts <<-DOC.gsub /^\s+/, ""
11
+ Lastest DVD and streaming releases with tomato meter ratings.
12
+ DOC
13
+ new_dvds
14
+ end
15
+
16
+ def new_dvds
17
+ puts "New movies on DVD & Streaming:"
18
+ @movies = LatestTomatoes::Movies.latest
19
+
20
+ @movies.each.with_index(1) do |movie, index|
21
+ movie[:tomatoScore] != nil ? tmeter = "#{movie[:tomatoScore]}%\n" : tmeter = "N/A"
22
+ puts "#{index}. #{movie[:title]} - #{tmeter}"
23
+ end
24
+ end
25
+
26
+ def input_1
27
+ input = nil
28
+ while input != "exit"
29
+ puts <<-DOC.gsub /^\s+/, ""
30
+ Type the number of a movie to view more information about it, or back to see the list again, or exit:
31
+ DOC
32
+ input = gets.strip.downcase
33
+ if input.to_i > 0 && input.to_i < 31 # not an integer
34
+ @movies[input.to_i-1][:tomatoScore] != nil ? tmeter = "#{@movies[input.to_i-1][:tomatoScore]}%" : tmeter = "N/A"
35
+ puts <<-DOC.gsub /^\s+/, ""
36
+ -------------
37
+ #{@movies[input.to_i-1][:title]} - tomato meter: #{tmeter}
38
+ Actors: #{@movies[input.to_i-1][:actors].join(", ")}
39
+ MPAA: #{@movies[input.to_i-1][:mpaaRating]}
40
+ #{@movies[input.to_i-1][:synopsis]}
41
+ http://www.rottentomatoes.com#{@movies[input.to_i-1][:url]}
42
+ -------------
43
+ DOC
44
+
45
+ elsif input.to_i > 30
46
+ puts "Oops, there are only 30 movies listed. Enter a number between 1-30."
47
+ elsif input == "back"
48
+ new_dvds
49
+ end
50
+ end
51
+ end
52
+
53
+ def adios
54
+ puts "\nBye! Check back next week for new releases.\n"
55
+ end
56
+
57
+
58
+
59
+ end
@@ -0,0 +1,32 @@
1
+ class LatestTomatoes::Movies
2
+ attr_accessor :title, :tomatoScore, :actors, :mpaaRating, :synopsis, :url
3
+
4
+ def self.latest
5
+ self.scrape_movies
6
+ end
7
+
8
+ def self.scrape_movies
9
+ movies = []
10
+ doc = Nokogiri::HTML(open("http://d3biamo577v4eu.cloudfront.net/api/private/v1.0/m/list/find?page=1&limit=30&type=dvd-new-releases&services=amazon%3Bamazon_prime%3Bflixster%3Bhbo_go%3Bitunes%3Bnetflix_iw%3Bvudu&sortBy=release"))
11
+ jsonstring = doc.search("p").text # gets json string from main html element
12
+ x=JSON.parse(jsonstring) #parsed array/hash of movie data
13
+ x["results"].each do |movie|
14
+
15
+ movies << {
16
+
17
+ :title => movie["title"],
18
+ :tomatoScore => movie["tomatoScore"],
19
+ :actors => movie["actors"],
20
+ :mpaaRating => movie["mpaaRating"],
21
+ :synopsis => movie["synopsis"],
22
+ :url => movie["url"]
23
+
24
+ }
25
+
26
+ end
27
+
28
+ movies
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,3 @@
1
+ module LatestTomatoes
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: latest_tomatoes_cli_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - jenjiyi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - jenny.yamada@gmail.com
100
+ executables:
101
+ - latest_tomatoes_cli_gem
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/latest_tomatoes_cli_gem
112
+ - bin/setup
113
+ - latest_tomatoes_cli_gem.gemspec
114
+ - lib/latest_tomatoes_cli_gem.rb
115
+ - lib/latest_tomatoes_cli_gem/cli.rb
116
+ - lib/latest_tomatoes_cli_gem/movies.rb
117
+ - lib/latest_tomatoes_cli_gem/version.rb
118
+ homepage: http://www.jennyy.com
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.5.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Look up latest dvd and streaming releases.
142
+ test_files: []