tunefind 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 913a4cbbbb93dfe58080abaf99461654c344f6ae
4
+ data.tar.gz: 52a8cdf50bcccaa3b7e393581b1712f071041e06
5
+ SHA512:
6
+ metadata.gz: 899f51ce6a75fad9b850b6031fead6274f8b97f225c8ff12b2a9fbd00dcf98227df1933ced688e98e210ced870fbef6087228c452ba9eb5c803093ad47b363b4
7
+ data.tar.gz: 435b6e67b1f0db0a967fef166533ccae975f9bf630b8d169c1437d71cd324167adf45c5a8b0fc8566389052ba2eca2a8f212962b34fa0933053e9a91adb72123
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ before_install: gem install bundler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tunefind.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Marcus Mansur
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.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Marcus Mansur
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.
@@ -0,0 +1,116 @@
1
+ # Tunefind
2
+
3
+ A simple ruby wrapper for [TuneFind REST API V1](http://www.tunefind.com/api)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tunefind'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tunefind
20
+
21
+ ## Usage
22
+
23
+ Set you API username and password as ENV vars:
24
+
25
+ ```ruby
26
+ ENV['TUNEFIND_USERNAME'] = 'your-api-username'
27
+ ENV['TUNEFIND_PASSWORD'] = 'your-api-password'
28
+ ```
29
+
30
+ ### Show:
31
+
32
+ All shows
33
+
34
+ ```ruby
35
+ Tunefind::Show.search
36
+ ```
37
+
38
+ A single show
39
+
40
+ ```ruby
41
+ Tunefind::Show.find('alias')
42
+ ```
43
+
44
+ ### Season:
45
+
46
+ ```ruby
47
+ Tunefind::Season.find('alias', 1)
48
+ ```
49
+
50
+ ### Episode:
51
+
52
+ ```ruby
53
+ Tunefind::Episode.find('alias', 1, 286)
54
+ ```
55
+
56
+ ### Movie:
57
+
58
+ All movies
59
+
60
+ ```ruby
61
+ Tunefind::Movie.search
62
+ ```
63
+
64
+ A single movie
65
+
66
+ ```ruby
67
+ Tunefind::Movie.find('zombieland-2009')
68
+ ```
69
+
70
+ ### Artist:
71
+
72
+ All artists
73
+
74
+ ```ruby
75
+ Tunefind::Artist.search
76
+ ```
77
+
78
+ A single artist
79
+
80
+ ```ruby
81
+ Tunefind::Artist.find('amazing-baby')
82
+ ```
83
+
84
+ ### Pagination
85
+
86
+ Search methods return a maximum of 1000 resources at a time. To page through results, specify a positive zero-indexed integer offset:
87
+
88
+ ```ruby
89
+ Tunefind::Artist.search(offset: 1000)
90
+ ```
91
+
92
+ ### Filtering
93
+
94
+ Search methods support an optional "updated" parameter. When provided, only results updated after this date will be listed. The date format is [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).
95
+
96
+ ```ruby
97
+ Tunefind::Artist.search(updated: '2010-01-01T00%3A00%3A00%2B00%3A00')
98
+ ```
99
+
100
+ **Disclaimer: By the time of this implementation, filtering was not working.**
101
+
102
+ ## Development
103
+
104
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
105
+
106
+ 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).
107
+
108
+ ## Contributing
109
+
110
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tunefind.
111
+
112
+
113
+ ## License
114
+
115
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
116
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tunefind"
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,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,14 @@
1
+ require "tunefind/version"
2
+ require 'rest-client'
3
+ require 'hashie'
4
+
5
+ require 'tunefind/client'
6
+ require 'tunefind/base'
7
+ require 'tunefind/show'
8
+ require 'tunefind/season'
9
+ require 'tunefind/episode'
10
+ require 'tunefind/movie'
11
+ require 'tunefind/artist'
12
+
13
+ module Tunefind
14
+ end
@@ -0,0 +1,11 @@
1
+ module Tunefind
2
+ class Artist < Base
3
+ def self.search(offset: nil, updated: nil)
4
+ build_collection(get("artist?offset=#{offset}&updated=#{updated}")['artists'])
5
+ end
6
+
7
+ def self.find(id)
8
+ build_object(get("artist/#{id}"))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ require 'forwardable'
2
+
3
+ module Tunefind
4
+ class Base
5
+ extend SingleForwardable
6
+
7
+ def_delegator :client, :get
8
+
9
+ def self.client
10
+ @client ||= Tunefind::Client.new(ENV['TUNEFIND_USERNAME'], ENV['TUNEFIND_PASSWORD'])
11
+ end
12
+
13
+ def self.build_collection(collection)
14
+ collection.map do |object|
15
+ build_object(object)
16
+ end
17
+ end
18
+
19
+ def self.build_object(object)
20
+ Hashie::Mash.new(object)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ module Tunefind
2
+ class Client
3
+ def initialize(username, password)
4
+ @username = username
5
+ @password = password
6
+ end
7
+
8
+ def get(path)
9
+ JSON.load(RestClient::Request.new(
10
+ method: :get,
11
+ url: build_url(path),
12
+ user: @username,
13
+ password: @password,
14
+ headers: { accept: :json, content_type: :json }
15
+ ).execute)
16
+ end
17
+
18
+ private
19
+
20
+ def build_url(path)
21
+ endpoint + path
22
+ end
23
+
24
+ def endpoint
25
+ "https://www.tunefind.com/api/v1/"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module Tunefind
2
+ class Episode < Base
3
+ def self.find(show_id, season_number, episode_id)
4
+ build_object(get("show/#{show_id}/season-#{season_number}/#{episode_id}"))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Tunefind
2
+ class Movie < Base
3
+ def self.search(offset: nil, updated: nil)
4
+ build_collection(get("movie?offset=#{offset}&updated=#{updated}")['movies'])
5
+ end
6
+
7
+ def self.find(id)
8
+ build_object(get("movie/#{id}"))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Tunefind
2
+ class Season < Base
3
+ def self.find(show_id, season_number)
4
+ build_object(get("show/#{show_id}/season-#{season_number}"))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Tunefind
2
+ class Show < Base
3
+ def self.search(offset: nil, updated: nil)
4
+ build_collection(get("show?offset=#{offset}&updated=#{updated}")['shows'])
5
+ end
6
+
7
+ def self.find(id)
8
+ build_object(get("show/#{id}"))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Tunefind
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tunefind/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tunefind"
8
+ spec.version = Tunefind::VERSION
9
+ spec.authors = ["Marcus Mansur"]
10
+ spec.email = ["marcusm@jobready.com.au"]
11
+
12
+ spec.summary = %q{Ruby client for tunefind.com REST API}
13
+ spec.description = %q{Ruby client for tunefind.com REST API}
14
+ spec.homepage = "https://github.com/louman/tunefind"
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.4"
25
+
26
+ spec.add_dependency "rest-client", "~> 1.8"
27
+ spec.add_dependency "hashie", "~> 3.4"
28
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tunefind
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcus Mansur
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-12 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.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashie
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ description: Ruby client for tunefind.com REST API
84
+ email:
85
+ - marcusm@jobready.com.au
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/tunefind.rb
101
+ - lib/tunefind/artist.rb
102
+ - lib/tunefind/base.rb
103
+ - lib/tunefind/client.rb
104
+ - lib/tunefind/episode.rb
105
+ - lib/tunefind/movie.rb
106
+ - lib/tunefind/season.rb
107
+ - lib/tunefind/show.rb
108
+ - lib/tunefind/version.rb
109
+ - tunefind.gemspec
110
+ homepage: https://github.com/louman/tunefind
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.8
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Ruby client for tunefind.com REST API
134
+ test_files: []
135
+ has_rdoc: