zeebox 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: 882ea1b95120a04d956c03f6fb5f1d83ae0e277e
4
+ data.tar.gz: 656ffb782be990dee6bc2889c4746f08b5be2a7e
5
+ SHA512:
6
+ metadata.gz: 093f55f955ab07031d745e6a02163074be8b9a76b927041a0177dad8f2b4687cb545e4441670170185cb6a07fe85719b8cb74d45942ba97dc311e126d6a90a3c
7
+ data.tar.gz: 82629a49290df8e58c7fa8dc4e3f030acab0e2369e390c9ac5e8fa013c8be770b3bcdc09fae251e5b79c75eec3b2a38a5bb46cae18a0c5a46b2cf60e4b93c693
@@ -0,0 +1,53 @@
1
+ # Zeebox Gem
2
+
3
+ Create an account on the zeebox developers website to get your api keys.
4
+
5
+ https://develop.zeebox.com/admin/applications
6
+
7
+ ## Still in early development
8
+
9
+ This gem is still in development and will most likely change dramatically. Keep this in mind if you plan to use this in a production environment as its not recommended.
10
+
11
+ The gem is only tested against the AU region currently.
12
+
13
+ ## Installation
14
+
15
+ Add the following to your `Gemfile`:
16
+
17
+ ```ruby
18
+ gem "zeebox"
19
+ ```
20
+
21
+ Add a file `config/initializers/zeebox.rb`` containing:
22
+
23
+ ```
24
+ Zeebox.configure do |config|
25
+ config.id = 'akdwad'
26
+ config.key = '24144de132cb2d622bzxz60a90ggasffcc6c5c'
27
+ config.region = 'AU'
28
+ end
29
+ ```
30
+
31
+ ## Methods
32
+
33
+ Here are the methods supported so far and a quick description.
34
+
35
+ ``Zeebox::Epg.regions`` returns an array of all of the regions.
36
+
37
+ ``Zeebox::Epg.providers`` returns an array of all of the regions.
38
+
39
+ ``Zeebox::Epg.catalogues(region, provider)`` returns an array of all of the catalogues. Provide a region id and provider id.
40
+
41
+ ``Zeebox::Epg.epg(id)`` returns an array of the epg. Id is from the catalogues reguest.
42
+
43
+ ``Zeebox::Epg.schedule(id,date)`` returns an array of the schedules. Provide a service id from the epg request and a date in the format YYYY/MM/DD
44
+
45
+ ``Zeebox::Epg.broadcast_event(id)`` returns an hash of a broadcast event. Provide an id from the schedule request
46
+
47
+ ``Zeebox::Epg.episode(id)`` returns an hash of a episode event. Provide an id from the schedule request
48
+
49
+ ## Tests
50
+
51
+ Include your api id and key as environment variables when running the tests
52
+
53
+ ``ZEEBOX_TEST_ID=xxx ZEEBOX_TEST_KEY=xxx bundle exec rspec``
@@ -0,0 +1,36 @@
1
+ require 'zeebox/client'
2
+ require 'zeebox/epg'
3
+ require 'zeebox/configuration'
4
+ require 'curb'
5
+ require 'hashie'
6
+
7
+ # Ruby toolkit for the Zeebox API
8
+ module Zeebox
9
+
10
+ US = 'api'
11
+ UK = 'api-uk'
12
+ AU = 'api-au'
13
+
14
+ class << self
15
+
16
+ attr_writer :configuration
17
+
18
+ def configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+
22
+ def configure
23
+ yield configuration
24
+ end
25
+ alias_method :config, :configuration
26
+
27
+ def base_uri
28
+ if ['US','UK','AU'].include? @configuration.region
29
+ region = self.const_get(@configuration.region)
30
+ end
31
+ "https://#{region}.zeebox.com"
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,22 @@
1
+ module Zeebox
2
+ class Client
3
+ EPG_URI = "/epg/1/"
4
+ def self.get(url)
5
+ response = Curl.get(Zeebox.base_uri + EPG_URI + url) do |http|
6
+ http.headers['zeebox-app-id'] = Zeebox.configuration.id
7
+ http.headers['zeebox-app-key'] = Zeebox.configuration.key
8
+ http.headers["Accept-Encoding"] = "gzip,deflate"
9
+ http.follow_location = true
10
+ end
11
+ return "" if response.body_str.empty?
12
+ gz = Zlib::GzipReader.new(StringIO.new(response.body_str))
13
+ json = gz.read
14
+ result = JSON.parse json
15
+ if result.is_a? Array
16
+ result.collect! { |x| x.is_a?(Hash) ? Hashie::Mash.new(x) : x }
17
+ else
18
+ result = Hashie::Mash.new(result)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ module Zeebox
2
+ class Configuration
3
+
4
+ attr_accessor :id, :key, :region
5
+
6
+ def [](option)
7
+ send(option)
8
+ end
9
+
10
+ def region
11
+ @region || 'AU'
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ require 'json'
2
+
3
+ module Zeebox
4
+ class Epg
5
+
6
+ class << self
7
+ def get(url)
8
+ Zeebox::Client.get(url)
9
+ end
10
+ end
11
+
12
+ def regions
13
+ self.class.get('au/regions')
14
+ end
15
+
16
+ def providers
17
+ self.class.get('au/providers')
18
+ end
19
+
20
+ def catalogues(region, provider)
21
+ url = Curl::urlalize("which-catalogue?", {:country => 'au', :region => region, :provider => provider})
22
+ self.class.get("#{url}")
23
+ end
24
+
25
+ def epg(id)
26
+ self.class.get("epg/#{id}")
27
+ end
28
+
29
+ def schedule(id,date)
30
+ self.class.get("service/#{id}/#{date}")
31
+ end
32
+
33
+ def broadcast_event(id)
34
+ self.class.get("broadcastevent/#{id}")
35
+ end
36
+
37
+ def episode(id)
38
+ self.class.get("episode/#{id}")
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ module Zeebox
2
+ class Railtie < ::Rails::Railtie
3
+
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Zeebox
2
+
3
+ # Current version
4
+ # @return [String]
5
+ VERSION = "0.0.1".freeze
6
+
7
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zeebox/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.add_development_dependency 'bundler', '~> 1.0'
8
+ spec.add_dependency "curb"
9
+ spec.add_dependency "hashie"
10
+ spec.add_development_dependency "rake"
11
+ spec.authors = ["Kieran Anddrews"]
12
+ spec.description = %q{Simple wrapper for the Zeebox API}
13
+ spec.email = ['hiddentiger@gmail.com']
14
+ spec.files = %w(Readme.md zeebox.gemspec)
15
+ spec.files += Dir.glob("lib/**/*.rb")
16
+ spec.homepage = 'https://github.com/TigerWolf/zeebox'
17
+ spec.licenses = ['MIT']
18
+ spec.name = 'zeebox'
19
+ spec.require_paths = ['lib']
20
+ spec.required_ruby_version = '>= 1.9.2'
21
+ spec.required_rubygems_version = '>= 1.3.5'
22
+ spec.summary = "Ruby toolkit for working with the Zeebox API"
23
+ spec.version = Zeebox::VERSION.dup
24
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zeebox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kieran Anddrews
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-29 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.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: curb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: rake
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
+ description: Simple wrapper for the Zeebox API
70
+ email:
71
+ - hiddentiger@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - Readme.md
77
+ - lib/zeebox.rb
78
+ - lib/zeebox/client.rb
79
+ - lib/zeebox/configuration.rb
80
+ - lib/zeebox/epg.rb
81
+ - lib/zeebox/railtie.rb
82
+ - lib/zeebox/version.rb
83
+ - zeebox.gemspec
84
+ homepage: https://github.com/TigerWolf/zeebox
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.9.2
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 1.3.5
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.2.2
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Ruby toolkit for working with the Zeebox API
108
+ test_files: []
109
+ has_rdoc: