tvdb-ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dea6c7065b76f3f4b598cec4607ccaac7075e000
4
+ data.tar.gz: 0bc8804eb33d41fde40a03e68b14a2584482a6fd
5
+ SHA512:
6
+ metadata.gz: f3b77cfdbe89e911d1d6ea6e46f21a530c0d93daa8f7d9bd05339f318135b73437ab66191ddcb574b86cd23b7c072907906bb091b4f8d7c6395e1e7d9c424b94
7
+ data.tar.gz: 8a69d892c784ea5788562bbb1612b66e2e5c94ca72b70c620f3c13d3b4aa425cacc5320065acddd4bdda42d7f50bf9ecf05af2fa8cef06c7d1138ddcee5028ce
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .ideas
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tvdb-ruby.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 theareba
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # Tvdb::Ruby
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tvdb-ruby'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+ $ rails g tvdb
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install tvdb-ruby
19
+
20
+ ## Usage
21
+
22
+ TODO: Write usage instructions here
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it ( http://github.com/<my-github-username>/tvdb-ruby/fork )
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ class ShowsController < ApplicationController
2
+ def index
3
+ @shows = Show.all
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ class Episode < ActiveRecord::Base
2
+ belongs_to :show
3
+ end
@@ -0,0 +1,3 @@
1
+ class Show < ActiveRecord::Base
2
+ has_many :episodes
3
+ end
@@ -0,0 +1,5 @@
1
+ <h2>Home Page</h2>
2
+ <%= @shows.each do |show| %>
3
+ <%= show.name %>
4
+ <%= show.overview %>
5
+ <% end %>
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ root to: 'shows#index'
3
+ end
@@ -0,0 +1,5 @@
1
+ module Tvdb
2
+ class Episode < ActiveRecord::Base
3
+ attr_accessible :seasonNumber, :show_id, :name, :firstAired, :overview
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Tvdb
2
+ class Show < ActiveRecord::Base
3
+ attr_accessible :name, :airsDayOfWeek, :airsTime, :firstAired, :genre, :network,
4
+ :overview, :rating, :ratingCount, :runtime, :status, :poster
5
+ end
6
+ end
@@ -0,0 +1,17 @@
1
+ class CreateEpisodes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :episodes do |t|
4
+ t.string :seasonNumber
5
+ t.references :show, index: true
6
+ t.string :name
7
+ t.string :firstAired
8
+ t.text :overview
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ drop_table :episodes
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ class CreateShows < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :shows do |t|
4
+ t.string :name
5
+ t.string :airsDayOfWeek
6
+ t.string :airsTime
7
+ t.string :firstAired
8
+ t.string :genre
9
+ t.string :network
10
+ t.text :overview
11
+ t.string :rating
12
+ t.string :ratingCount
13
+ t.string :runtime
14
+ t.string :status
15
+ t.string :poster
16
+
17
+ t.timestamps
18
+ end
19
+ end
20
+
21
+ def self.down
22
+ drop_table :shows
23
+ end
24
+ end
25
+
@@ -0,0 +1,24 @@
1
+ # CURRENT FILE :: lib/generators/team_page/team_page_generator.rb
2
+ # Requires
3
+ require 'rails/generators'
4
+ require 'rails/generators/migration'
5
+
6
+ class TvdbGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ def self.source_root
9
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
10
+ end
11
+
12
+ def self.next_migration_number(dirname)
13
+ if ActiveRecord::Base.timestamped_migrations
14
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
15
+ else
16
+ "%.3d" % (current_migration_number(dirname) + 1)
17
+ end
18
+ end
19
+
20
+ def create_migration_file
21
+ migration_template 'show.rb', 'db/migrate/create_show_table.rb'
22
+ migration_template 'episode.rb', 'db/migrate/create_episode_table.rb'
23
+ end
24
+ end
@@ -0,0 +1,50 @@
1
+ require "tvdb/ruby/version"
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+ module Tvdb
6
+ class << self
7
+ def initialize(apiKey, seriesName)
8
+ #apiKey = '9EF1D1E7D28FDA0B'
9
+ #seriesName = 'Breaking+Bad'
10
+ url = "http://thetvdb.com/api/GetSeries.php?seriesname=#{seriesName}"
11
+ doc = Nokogiri::HTML(open(url))
12
+ seriesId = doc.at_css("seriesid").text
13
+
14
+ harvest(apiKey, seriesId)
15
+ end
16
+
17
+ def harvest(apiKey, seriesId)
18
+ url = "http://thetvdb.com/api/#{apiKey}/series/#{seriesId}/all/en.xml"
19
+ doc = Nokogiri::HTML(open(url))
20
+
21
+ show = Show.new(
22
+ id: doc.css("id").text,
23
+ name: doc.css("seriesname").text,
24
+ airsDayOfWeek: doc.css("airs_dayofweek").text,
25
+ airsTime: doc.css("airs_time").text,
26
+ firstAired: doc.css("firstaired").text,
27
+ genre: doc.css("genre").text,
28
+ network: doc.css("network").text,
29
+ overview: doc.css("overview").text,
30
+ rating: doc.css("rating").text,
31
+ ratingCount: doc.css("ratingcount").text,
32
+ runtime: doc.css("runtime").text,
33
+ status: doc.css("status").text,
34
+ poster: doc.css("poster").text
35
+ )
36
+
37
+ doc.css("episode").each do |episode|
38
+ show.epidosodes.new(
39
+ seasonNumber: episode.css("seasonnumber").text,
40
+ id: episode.css("episodenumber").text,
41
+ name: episode.css("episodename").text,
42
+ firstAired: episode.css("firstaired").text,
43
+ overview: episode.css("overview").text
44
+ )
45
+
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ module Tvdb
2
+ module Ruby
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tvdb/ruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tvdb-ruby"
8
+ spec.version = Tvdb::Ruby::VERSION
9
+ spec.authors = ["theareba"]
10
+ spec.email = ["vicgoburg@gmail.com"]
11
+ spec.summary = %q{Simple Gem that consumes TVDb API}
12
+ spec.description = %q{Simple Gem that consumes TVDb API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tvdb-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - theareba
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-04 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Simple Gem that consumes TVDb API
42
+ email:
43
+ - vicgoburg@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/controllers/shows_controller.rb
54
+ - app/models/episode.rb
55
+ - app/models/show.rb
56
+ - app/views/shows/index.html.erb
57
+ - config/routes.rb
58
+ - lib/generators/tvdb/episode.rb
59
+ - lib/generators/tvdb/show.rb
60
+ - lib/generators/tvdb/templates/episode.rb
61
+ - lib/generators/tvdb/templates/show.rb
62
+ - lib/generators/tvdb/tvshow_generator.rb
63
+ - lib/tvdb/ruby.rb
64
+ - lib/tvdb/ruby/version.rb
65
+ - tvdb-ruby.gemspec
66
+ homepage: ''
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.2.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Simple Gem that consumes TVDb API
90
+ test_files: []