tv_maze 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/CODE_OF_CONDUCT.md +13 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +21 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +45 -0
  8. data/Rakefile +10 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/lib/tv_maze/api.rb +27 -0
  12. data/lib/tv_maze/exception.rb +11 -0
  13. data/lib/tv_maze/models/airing_schedule.rb +3 -0
  14. data/lib/tv_maze/models/alternative_name.rb +3 -0
  15. data/lib/tv_maze/models/api_resource.rb +19 -0
  16. data/lib/tv_maze/models/cast.rb +3 -0
  17. data/lib/tv_maze/models/country.rb +3 -0
  18. data/lib/tv_maze/models/episode.rb +3 -0
  19. data/lib/tv_maze/models/external_ids.rb +3 -0
  20. data/lib/tv_maze/models/image.rb +3 -0
  21. data/lib/tv_maze/models/network.rb +3 -0
  22. data/lib/tv_maze/models/person.rb +19 -0
  23. data/lib/tv_maze/models/schedule.rb +13 -0
  24. data/lib/tv_maze/models/season.rb +3 -0
  25. data/lib/tv_maze/models/show.rb +46 -0
  26. data/lib/tv_maze/representers/airing_schedule_representer.rb +6 -0
  27. data/lib/tv_maze/representers/alternative_name_representer.rb +6 -0
  28. data/lib/tv_maze/representers/cast_representer.rb +6 -0
  29. data/lib/tv_maze/representers/country_representer.rb +9 -0
  30. data/lib/tv_maze/representers/episode_representer.rb +16 -0
  31. data/lib/tv_maze/representers/external_ids_representer.rb +7 -0
  32. data/lib/tv_maze/representers/image_representer.rb +6 -0
  33. data/lib/tv_maze/representers/network_representer.rb +7 -0
  34. data/lib/tv_maze/representers/person_representer.rb +7 -0
  35. data/lib/tv_maze/representers/schedule_representer.rb +24 -0
  36. data/lib/tv_maze/representers/season_representer.rb +13 -0
  37. data/lib/tv_maze/representers/show_representer.rb +29 -0
  38. data/lib/tv_maze/requester.rb +41 -0
  39. data/lib/tv_maze/version.rb +3 -0
  40. data/lib/tv_maze.rb +40 -0
  41. data/tv_maze.gemspec +32 -0
  42. metadata +210 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb30001a7431f72765c8d25ef28866362488d830
4
+ data.tar.gz: b3d8cc283ffe4074f3ad1230b1af1def32413be5
5
+ SHA512:
6
+ metadata.gz: c806d75281c80afdb8aef3e2f449c25355e2a9972506cebd51aa420c953ff2e9e09ac316be96bff92a8cf9beae808aa57f9c0de18685518d64ff58bcd1419061
7
+ data.tar.gz: 3e95f73afc01318558102ea90290a500cf36d7e2ed2cb8ac98df7e222e035150bb213c1c2efe1ba058203a732d7f9e9e81fd58bd5ad35576663014160f1f6933
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /Gemfile.lock
3
+ /pkg/
4
+ /spec/reports/
5
+ /tmp/
6
+ *.gem
7
+ *.rbc
8
+ .idea/*
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers 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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tv_maze.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Naveed Ahmad
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Naveed Ahmad
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,45 @@
1
+ # TvMaze
2
+
3
+ Thin Ruby wrapper around tvmaze.com API. http://www.tvmaze.com/api
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tv_maze'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tv_maze
20
+
21
+ ## Usage
22
+ ```ruby
23
+ #Get basic detail of a show
24
+
25
+ > show = TvMaze::Show.find 1
26
+ => {"moji"=>"❤", "unicode"=>"2764", "unicode_alternates"=>["2764-FE0F"], "name"=>"heart", "shortname"=>":heart:", "category"=>"symbols", "aliases"=>[], "aliases_ascii"=>["<3"], "keywords"=>["like", "love", "red", "pink", "black", "heart", "love", "passion", "romance", "intense", "desire", "death", "evil", "cold", "valentines"], "description"=>"heavy black heart"}
27
+
28
+
29
+ ## Search
30
+ ```
31
+
32
+ ## Development
33
+
34
+ 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.
35
+
36
+ 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).
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/naveed-ahmad/tv_maze. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
41
+
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tv_maze"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ require 'singleton'
2
+
3
+ module TvMaze
4
+ class Api
5
+ include Singleton
6
+
7
+ attr_reader :base_url
8
+
9
+ def initialize
10
+ self.base_url = "http://api.tvmaze.com/".freeze
11
+ end
12
+
13
+ def url_for(action, params={})
14
+ url = URI.join(base_url, action)
15
+
16
+ if params['embed']
17
+ params['embed[]'] = params.delete('embed')
18
+ end
19
+
20
+ url.query = URI.encode_www_form(params) if params
21
+ url.to_s
22
+ end
23
+
24
+ private
25
+ attr_writer :base_url
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ module TvMaze::Exception
2
+ class Base < ::Exception
3
+ def initialize(message)
4
+ super(message)
5
+ end
6
+ end
7
+
8
+ class Api < Base; end
9
+ class ArgumentError < Base; end
10
+ class JsonParseError < Base; end
11
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::AiringSchedule < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::AlternativeName < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,19 @@
1
+ require 'representable/json'
2
+
3
+ class TvMaze::ApiResource < OpenStruct
4
+
5
+ private
6
+ def self.build_single_resource(response, representer)
7
+ self.new.extend(representer).from_hash(response)
8
+ end
9
+
10
+ def self.build_collection(response, representer)
11
+ response.reduce([]) do |resources, response|
12
+ resources << self.new.extend(representer).from_hash(response)
13
+ end
14
+ end
15
+
16
+ def build_for_collection(response, representer)
17
+ [].extend(representer.for_collection).from_hash(response)
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::Cast < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::Country < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::Episode < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::ExternalIds < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::Image < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::Network < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,19 @@
1
+ class TvMaze::Person < TvMaze::ApiResource
2
+
3
+ def self.find(id, embed: [])
4
+ build_single_resource(TvMaze::Requester.get("people/#{id}", {embed: embed}), TvMaze::PersonRepresenter)
5
+ end
6
+
7
+ def cast_credits(id, embed: [])
8
+ #"people/#{id}/castcredits"
9
+ end
10
+
11
+ def crew_credits(id)
12
+
13
+ end
14
+
15
+ def self.search(query)
16
+ result = TvMaze::Requester.get("search/people", {q: query})
17
+ build_collection(result.map{|show| show['person'] }, TvMaze::PersonRepresenter)
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ class TvMaze::Schedule < TvMaze::ApiResource
2
+ #The schedule is a complete list of episodes that air in a given country on a given date. Episodes are returned in the order in which they are aired, and full information about the episode and the corresponding show is included.
3
+ def self.fetch(date: Date.today, country: 'US')
4
+ params = {country: country, date: date.to_date.strftime}
5
+
6
+ build_collection(TvMaze::Requester.get("schedule", params), TvMaze::ScheduleRepresenter)
7
+ end
8
+
9
+ #The full schedule is a list of all future episodes known to TVmaze
10
+ def self.full
11
+ build_collection(TvMaze::Requester.get("schedule/full"), TvMaze::ScheduleRepresenter)
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ class TvMaze::Season < TvMaze::ApiResource
2
+
3
+ end
@@ -0,0 +1,46 @@
1
+ class TvMaze::Show < TvMaze::ApiResource
2
+ def self.find(id, embed: [])
3
+ build_single_resource(TvMaze::Requester.get("shows/#{id}", {embed: embed}), TvMaze::ShowRepresenter)
4
+ end
5
+
6
+ #A list of main cast for a show. Each cast item is a combination of a person and a character. Items are ordered by importance, which is determined by the total number of appearances of the given character in this show.
7
+ def self.cast(id)
8
+ TvMaze::Cast.build_collection(TvMaze::Requester.get("shows/#{id}/cast"), TvMaze::CastRepresenter)
9
+ end
10
+
11
+ #A list of AKA's (aliases) for a show. An AKA with its country set to null indicates an AKA in the show's original country. Otherwise, it's the AKA for that show in the given foreign country.
12
+ def self.alternative_names(id)
13
+ TvMaze::AlternativeName.build_collection(TvMaze::Requester.get("shows/#{id}/akas"), TvMaze::AlternativeNameRepresenter)
14
+ end
15
+
16
+ #A complete list of seasons for the given show. Seasons are returned in ascending order and contain the full information that's known about them.
17
+ def self.seasons(id)
18
+ TvMaze::Season.build_collection(TvMaze::Requester.get("shows/#{id}/seasons"), TvMaze::SeasonRepresenter)
19
+ end
20
+
21
+ def self.episodes(id, special: false)
22
+ params = {specials: special ? 1 : 0}
23
+ TvMaze::Episode.build_collection(TvMaze::Requester.get("shows/#{id}/episodes", params), TvMaze::EpisodeRepresenter)
24
+ end
25
+
26
+ def self.find_by_imdb_id(imdb)
27
+ build_single_resource(TvMaze::Requester.get("lookup/shows", {imdb: imdb}), TvMaze::ShowRepresenter)
28
+ end
29
+
30
+ def self.find_by_tvrage_id(tvrage)
31
+ build_single_resource(TvMaze::Requester.get("lookup/shows", {tvrage: tvrage}), TvMaze::ShowRepresenter)
32
+ end
33
+
34
+ def self.find_by_tvdb_id(tvdb)
35
+ build_single_resource(TvMaze::Requester.get("lookup/shows", {thetvdb: tvdb}), TvMaze::ShowRepresenter)
36
+ end
37
+
38
+ def self.all(page = 1)
39
+ build_collection(TvMaze::Requester.get("/shows", {page: page}), TvMaze::ShowRepresenter)
40
+ end
41
+
42
+ def self.search(q)
43
+ result = TvMaze::Requester.get("search/shows", {q: q})
44
+ build_collection(result.map{|show| show['show'] }, TvMaze::ShowRepresenter)
45
+ end
46
+ end
@@ -0,0 +1,6 @@
1
+ module TvMaze::AiringScheduleRepresenter
2
+ include Representable::JSON
3
+
4
+ property :time
5
+ property :days
6
+ end
@@ -0,0 +1,6 @@
1
+ module TvMaze::AlternativeNameRepresenter
2
+ include Representable::JSON
3
+
4
+ property :name
5
+ property :country, extend: TvMaze::CountryRepresenter, class: TvMaze::Country
6
+ end
@@ -0,0 +1,6 @@
1
+ module TvMaze::CastRepresenter
2
+ include Representable::JSON
3
+
4
+ property :person,extend: TvMaze::PersonRepresenter, class: TvMaze::Person
5
+ property :character, extend: TvMaze::PersonRepresenter, class: TvMaze::Person
6
+ end
@@ -0,0 +1,9 @@
1
+ module TvMaze::CountryRepresenter
2
+ include Representable::JSON
3
+
4
+ property :name
5
+ property :code
6
+ property :timezone
7
+ end
8
+
9
+
@@ -0,0 +1,16 @@
1
+ module TvMaze::EpisodeRepresenter
2
+ include Representable::JSON
3
+
4
+ property :id
5
+ property :name
6
+ property :summary
7
+ property :season_number, as: :season
8
+ property :episode_number, as: :number
9
+ property :air_date, as: :airdate
10
+ property :air_time, as: :airtime
11
+ property :air_stamp, as: :airstamp
12
+ property :run_time, as: :runtime
13
+ property :image, extend: TvMaze::ImageRepresenter, class: TvMaze::Image
14
+ end
15
+
16
+
@@ -0,0 +1,7 @@
1
+ module TvMaze::ExternalIdsRepresenter
2
+ include Representable::JSON
3
+
4
+ property :tvrage
5
+ property :thetvdb
6
+ property :imdb
7
+ end
@@ -0,0 +1,6 @@
1
+ module TvMaze::ImageRepresenter
2
+ include Representable::JSON
3
+
4
+ property :original
5
+ property :medium
6
+ end
@@ -0,0 +1,7 @@
1
+ module TvMaze::NetworkRepresenter
2
+ include Representable::JSON
3
+
4
+ property :id
5
+ property :name
6
+ property :country, extend: TvMaze::CountryRepresenter, class: TvMaze::Country
7
+ end
@@ -0,0 +1,7 @@
1
+ module TvMaze::PersonRepresenter
2
+ include Representable::JSON
3
+
4
+ property :id
5
+ property :name
6
+ property :image, extend: TvMaze::ImageRepresenter, class: TvMaze::Image
7
+ end
@@ -0,0 +1,24 @@
1
+ module TvMaze::ScheduleRepresenter
2
+ include Representable::JSON
3
+
4
+ property :id
5
+ property :episode_name, as: :name
6
+ property :summary
7
+ property :url
8
+ property :season_number, as: :season
9
+ property :episode_number, as: :number
10
+ property :air_date, as: :airdate
11
+ property :air_time, as: :airtime
12
+ property :air_stamp, as: :airstamp
13
+ property :run_time, as: :runtime
14
+ property :image, extend: TvMaze::ImageRepresenter, class: TvMaze::Image
15
+ property :related_show, as: :show, class: TvMaze::Show, extend: TvMaze::ShowRepresenter
16
+
17
+ nested :_embedded do
18
+ property :embeded_show, as: :show, class: TvMaze::Show, extend: TvMaze::ShowRepresenter
19
+ end
20
+
21
+ def show
22
+ related_show || embeded_show
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ module TvMaze::SeasonRepresenter
2
+ include Representable::JSON
3
+
4
+ property :number
5
+ property :name
6
+ property :episode_order, as: :episodeOrder
7
+ property :premiere_date, as: :premiereDate
8
+ property :end_date, as: :endDate
9
+ property :web_channel, as: :webChannel
10
+ property :summary
11
+ property :network, extend: TvMaze::NetworkRepresenter, class: TvMaze::Network
12
+ property :image, extend: TvMaze::ImageRepresenter, class: TvMaze::Image
13
+ end
@@ -0,0 +1,29 @@
1
+ module TvMaze::ShowRepresenter
2
+ include Representable::JSON
3
+
4
+ property :id
5
+ property :name
6
+ property :type
7
+ property :language
8
+ property :status
9
+ property :runtime
10
+ property :premiered
11
+ property :rating
12
+ property :web_channel, as: :webChannel
13
+ property :summary
14
+ property :genres
15
+ property :updated
16
+ property :airing_schedule, as: :schedule, extend: TvMaze::AiringScheduleRepresenter, class: TvMaze::AiringSchedule
17
+ property :previous_episode, as: :previousepisode
18
+ property :network, extend: TvMaze::NetworkRepresenter, class: TvMaze::Network
19
+ property :image, extend: TvMaze::ImageRepresenter, class: TvMaze::Image
20
+ property :external_ids, as: :externals, extend: TvMaze::ExternalIdsRepresenter, class: TvMaze::ExternalIds
21
+
22
+ nested :_embedded do
23
+ collection :cast, class: TvMaze::Cast, extend: TvMaze::CastRepresenter
24
+ collection :episodes, class: TvMaze::Episode, extend: TvMaze::EpisodeRepresenter
25
+ end
26
+
27
+ #end
28
+ #collection :schedule, extend: Igdb::GameThemeRepresenter, class: Igdb::GameTheme # Not documented in v1 API
29
+ end
@@ -0,0 +1,41 @@
1
+ require 'rest_client'
2
+
3
+ class TvMaze::Requester
4
+ class << self
5
+
6
+ def get(action, params={})
7
+ url = api.url_for(action, params)
8
+ perform_request do
9
+ parse_response(RestClient.get(url, request_headers))
10
+ end
11
+ end
12
+
13
+ private
14
+ def api
15
+ TvMaze::Api.instance
16
+ end
17
+
18
+ def perform_request(&block)
19
+ begin
20
+ block.call
21
+ rescue RestClient::Exception => e
22
+ raise TvMaze::Exception::Api.new(e.message)
23
+ end
24
+ end
25
+
26
+ def request_headers
27
+ Hash.new.tap do |headers|
28
+ headers['Accept'] = 'application/json'
29
+ headers['Content-Type'] = 'application/json'
30
+ end
31
+ end
32
+
33
+ def parse_response(response_body)
34
+ begin
35
+ JSON.parse(response_body)
36
+ rescue JSON::ParserError => e
37
+ raise TvMaze::Exception::JsonParseError.new("Response body could not be parsed: #{e.message}")
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module TvMaze
2
+ VERSION = "0.1.0"
3
+ end
data/lib/tv_maze.rb ADDED
@@ -0,0 +1,40 @@
1
+ require "tv_maze/version"
2
+ require 'representable'
3
+ require 'representable/json'
4
+
5
+ module TvMaze
6
+ #Utilities
7
+ autoload :Requester, 'tv_maze/requester'
8
+ autoload :Exception, 'tv_maze/exception'
9
+ autoload :Api, 'tv_maze/api'
10
+
11
+ #Models
12
+ autoload :ApiResource, 'tv_maze/models/api_resource'
13
+ autoload :Show, 'tv_maze/models/show'
14
+ autoload :Network, 'tv_maze/models/network'
15
+ autoload :Image, 'tv_maze/models/image'
16
+ autoload :ExternalIds, 'tv_maze/models/external_ids'
17
+ autoload :Cast, 'tv_maze/models/cast'
18
+ autoload :Episode, 'tv_maze/models/episode'
19
+ autoload :Person, 'tv_maze/models/person'
20
+ autoload :Country, 'tv_maze/models/country'
21
+ autoload :Schedule, 'tv_maze/models/schedule'
22
+ autoload :Season, 'tv_maze/models/season'
23
+ autoload :AiringSchedule, 'tv_maze/models/airing_schedule'
24
+ autoload :AlternativeName, 'tv_maze/models/alternative_name'
25
+
26
+
27
+ #Presenters
28
+ autoload :ShowRepresenter, 'tv_maze/representers/show_representer'
29
+ autoload :NetworkRepresenter, 'tv_maze/representers/network_representer'
30
+ autoload :ImageRepresenter, 'tv_maze/representers/image_representer'
31
+ autoload :ExternalIdsRepresenter, 'tv_maze/representers/external_ids_representer'
32
+ autoload :CastRepresenter, 'tv_maze/representers/cast_representer'
33
+ autoload :EpisodeRepresenter, 'tv_maze/representers/episode_representer'
34
+ autoload :PersonRepresenter, 'tv_maze/representers/person_representer'
35
+ autoload :CountryRepresenter, 'tv_maze/representers/country_representer'
36
+ autoload :SeasonRepresenter, 'tv_maze/representers/season_representer'
37
+ autoload :ScheduleRepresenter, 'tv_maze/representers/schedule_representer'
38
+ autoload :AiringScheduleRepresenter, 'tv_maze/representers/airing_schedule_representer'
39
+ autoload :AlternativeNameRepresenter, 'tv_maze/representers/alternative_name_representer'
40
+ end
data/tv_maze.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tv_maze/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tv_maze"
8
+ spec.version = TvMaze::VERSION
9
+ spec.authors = ["Naveed Ahmad"]
10
+ spec.email = ["naveedahmada036@gmail.com"]
11
+
12
+ spec.summary = %q{A Ruby wrapper for the TvMaze api: http://www.tvmaze.com/api API}
13
+ spec.description = ''
14
+ spec.homepage = "https://github.com/naveed-ahmad/tv_maze"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency 'rspec', '~> 3.3.0'
25
+ spec.add_development_dependency 'vcr', '~> 2.9.3'
26
+ spec.add_development_dependency 'webmock', '~> 1.21.0'
27
+ spec.add_development_dependency 'codeclimate-test-reporter'
28
+
29
+ spec.add_runtime_dependency 'representable'
30
+ spec.add_runtime_dependency 'multi_json'
31
+ spec.add_runtime_dependency 'rest-client'
32
+ end
metadata ADDED
@@ -0,0 +1,210 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tv_maze
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Naveed Ahmad
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-27 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.9.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.9.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.21.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.21.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: representable
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: multi_json
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rest-client
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: ''
140
+ email:
141
+ - naveedahmada036@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - CODE_OF_CONDUCT.md
148
+ - Gemfile
149
+ - LICENSE
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - bin/console
154
+ - bin/setup
155
+ - lib/tv_maze.rb
156
+ - lib/tv_maze/api.rb
157
+ - lib/tv_maze/exception.rb
158
+ - lib/tv_maze/models/airing_schedule.rb
159
+ - lib/tv_maze/models/alternative_name.rb
160
+ - lib/tv_maze/models/api_resource.rb
161
+ - lib/tv_maze/models/cast.rb
162
+ - lib/tv_maze/models/country.rb
163
+ - lib/tv_maze/models/episode.rb
164
+ - lib/tv_maze/models/external_ids.rb
165
+ - lib/tv_maze/models/image.rb
166
+ - lib/tv_maze/models/network.rb
167
+ - lib/tv_maze/models/person.rb
168
+ - lib/tv_maze/models/schedule.rb
169
+ - lib/tv_maze/models/season.rb
170
+ - lib/tv_maze/models/show.rb
171
+ - lib/tv_maze/representers/airing_schedule_representer.rb
172
+ - lib/tv_maze/representers/alternative_name_representer.rb
173
+ - lib/tv_maze/representers/cast_representer.rb
174
+ - lib/tv_maze/representers/country_representer.rb
175
+ - lib/tv_maze/representers/episode_representer.rb
176
+ - lib/tv_maze/representers/external_ids_representer.rb
177
+ - lib/tv_maze/representers/image_representer.rb
178
+ - lib/tv_maze/representers/network_representer.rb
179
+ - lib/tv_maze/representers/person_representer.rb
180
+ - lib/tv_maze/representers/schedule_representer.rb
181
+ - lib/tv_maze/representers/season_representer.rb
182
+ - lib/tv_maze/representers/show_representer.rb
183
+ - lib/tv_maze/requester.rb
184
+ - lib/tv_maze/version.rb
185
+ - tv_maze.gemspec
186
+ homepage: https://github.com/naveed-ahmad/tv_maze
187
+ licenses:
188
+ - MIT
189
+ metadata: {}
190
+ post_install_message:
191
+ rdoc_options: []
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubyforge_project:
206
+ rubygems_version: 2.2.2
207
+ signing_key:
208
+ specification_version: 4
209
+ summary: 'A Ruby wrapper for the TvMaze api: http://www.tvmaze.com/api API'
210
+ test_files: []