tvrage_api 0.2.1 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f915d2a0d1255f5d8185be941412f209d833f95
4
- data.tar.gz: 1d5ee554e1768a81e3dadae6832ec055ed6192b2
3
+ metadata.gz: 94940bd48b406bc923d98a10f40bf37e3b88eb41
4
+ data.tar.gz: a874fa0a2f8b0624ff74e6ff591db98753e63155
5
5
  SHA512:
6
- metadata.gz: f1c24dd87ee9f99d00668ed53ef11fd64bdf175e43d89d289123121d8a7bcd1f459ff5dc3ad145e97f51f9c717b50ad432462342c7c833a8cb363a5db24408a7
7
- data.tar.gz: e78253e1311d7f92f3f951910912abb5b88fd618a26bbbe68b84d0d77f620df26e21bd0107a4f2755317bcc869c1377ccca6a4452c04b0c491fe72637d3c4a31
6
+ metadata.gz: 97c7a32f883b7be3ea42c0a9145e543e1ab1277add7492ec6e90b86704a4c6b7d91e8d0e2520e43f540e06070095221d7b82ccbd1b457e6f1ada3848da2cbed9
7
+ data.tar.gz: 58bc4b8aba59140e3d758ebd0d393eda81478d20b5d5e6ae33849c3f00a19882e889998dbe5d5f0b0bd1b6ba41a45dc2d610d172f58b64d0ad3ce56145c73e1a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -3,4 +3,5 @@ script: 'bundle exec rspec spec/functionals'
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.0
6
+ - 2.1.5
7
+ - 2.2.0
@@ -0,0 +1,32 @@
1
+ ## 0.3.0 (January 25, 2015)
2
+
3
+ - use ov gem for multimethod
4
+ - use hashie for normalize params key names
5
+
6
+ ## 0.2.1 (August 31, 2014)
7
+
8
+ - update dependencies
9
+ - fill documentations
10
+
11
+ ## 0.2.0 (June 25, 2014)
12
+
13
+ - replaced HTTParty by Faraday
14
+ - refactored Mapper classes
15
+
16
+ ## 0.1.1 (December 14, 2013)
17
+
18
+ - refactored
19
+
20
+ ## 0.1.0 (December 10, 2013)
21
+
22
+ - removed monkey patches for Ruby Core Date Types
23
+ - removed mapping response to objects
24
+ - little performance improvement
25
+
26
+ ## 0.0.2 (December 7, 2013)
27
+
28
+ - corrected README
29
+
30
+ ## 0.0.1 (December 7, 2013)
31
+
32
+ First release with HTTParty
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- [![Build Status](https://travis-ci.org/wafcio/tvrage_api.png?branch=master)](https://travis-ci.org/wafcio/tvrage_api)
2
- [![Dependency Status](https://gemnasium.com/wafcio/tvrage_api.png)](https://gemnasium.com/wafcio/tvrage_api)
3
- [![Code Climate](https://codeclimate.com/github/wafcio/tvrage_api.png)](https://codeclimate.com/github/wafcio/tvrage_api)
4
- [![Coverage Status](https://coveralls.io/repos/wafcio/tvrage_api/badge.png)](https://coveralls.io/r/wafcio/tvrage_api)
1
+ [![Build Status](https://travis-ci.org/tvapi/tvrage_api.png?branch=master)](https://travis-ci.org/tvapi/tvrage_api)
2
+ [![Dependency Status](https://gemnasium.com/tvapi/tvrage_api.png)](https://gemnasium.com/tvapi/tvrage_api)
3
+ [![Code Climate](https://codeclimate.com/github/tvapi/tvrage_api.png)](https://codeclimate.com/github/tvapi/tvrage_api)
4
+ [![Coverage Status](https://coveralls.io/repos/tvapi/tvrage_api/badge.png)](https://coveralls.io/r/tvapi/tvrage_api)
5
5
  [![Gem Version](https://badge.fury.io/rb/tvrage_api.png)](http://badge.fury.io/rb/tvrage_api)
6
6
 
7
7
  # TvrageApi
@@ -23,105 +23,89 @@ You have two way for access to api:
23
23
 
24
24
  * I way (create client class, one entry point)
25
25
 
26
- * II way (direct access to api class, many entry points)
27
-
28
- Search show by name:
29
-
30
26
  ```ruby
31
27
  client = TvrageApi::Client.new
32
- client.search.by_name(show: 'buffy')
33
- client.search.full_by_name(show: 'buffy')
28
+ client.info # => #<TvrageApi::Info>
29
+ client.recap # => #<TvrageApi::Recap>
30
+ client.schedule # => #<TvrageApi::Schedule>
31
+ client.search # => #<TvrageApi::Search>
32
+ client.show # => #<TvrageApi::Show>
33
+ client.update # => #<TvrageApi::Update>
34
34
  ```
35
35
 
36
+ * II way (direct access to api class, many entry points)
37
+
36
38
  ```ruby
37
- search = TvrageApi::Search.new
38
- search.by_name(show: 'buffy')
39
- search.full_by_name(show: 'buffy')
39
+ TvrageApi::Info.new
40
+ TvrageApi::Recap.new
41
+ TvrageApi::Schedule.new
42
+ TvrageApi::Search.new
43
+ TvrageApi::Show.new
44
+ TvrageApi::Update.new
40
45
  ```
41
46
 
42
- Search show by id:
47
+ ## Methods
43
48
 
44
- ```ruby
45
- client = TvrageApi::Client.new
46
- client.show.find(sid: '123')
47
- client.show.find_full(sid: '123')
48
- client.show.episodes(sid: '123') # show with all episodes
49
- client.show.episode(sid: '123', ep: 'SEASONxEPISODE') # show with specific episode
50
- client.show.all
51
- ```
49
+ For almost all method you can pass hash attributes or multiple attributes specified in method comment.
52
50
 
53
- ```ruby
54
- show = TvrageApi::Show.new
55
- show.find(sid: '123')
56
- show.find_full(sid: '123')
57
- show.episodes(sid: '123') # show with all episodes
58
- show.episode(sid: '123', ep: 'SEASONxEPISODE') # show with specific episode
59
- show.all
60
- ```
51
+ ### Info (QuickInfo) methods
61
52
 
62
- QuickInfo (it return plain text, not parsed)
53
+ For method attributes read https://github.com/tvapi/tvrage_api/blob/master/lib/tvrage_api/info.rb
63
54
 
64
- ```ruby
65
- client = TvrageApi::Client.new
66
- client.info.find(show: 'Alias') # main information
67
- client.info.find(show: 'Alias', ep: '2x04') # episode information
68
- client.info.find(show: 'Alias', exact: 1) # exact information
69
- ```
55
+ * find
56
+ * find_url
70
57
 
71
- ```ruby
72
- info = TvrageApi::Info.new
73
- info.find(show: 'Alias') # main information
74
- info.find(show: 'Alias', ep: '2x04') # episode information
75
- info.find(show: 'Alias', exact: 1) # exact information
76
- ```
58
+ ### Recap methods
77
59
 
78
- Schedule (quick method return plain text)
60
+ For method attributes read https://github.com/tvapi/tvrage_api/blob/master/lib/tvrage_api/recap.rb
79
61
 
80
- ```ruby
81
- client = TvrageApi::Client.new
82
- client.schedule.quick
83
- client.schedule.full(country: 'US')
84
- ```
62
+ * all
63
+ * all_url
64
+ * show
65
+ * show_url
66
+ * last
67
+ * last_url
85
68
 
86
- ```ruby
87
- schedule = TvrageApi::Schedule.new
88
- schedule.quick
89
- schedule.full(country: 'US')
90
- ```
69
+ ### Schedule methods
91
70
 
92
- Recaps
71
+ For method attributes read https://github.com/tvapi/tvrage_api/blob/master/lib/tvrage_api/schedule.rb
93
72
 
94
- ```ruby
95
- client = TvrageApi::Client.new
96
- client.recap.all
97
- client.recap.show(show: 5410)
98
- client.recap.last(days: 100)
99
- ```
73
+ * quick
74
+ * quick_url
75
+ * full
76
+ * full_url
100
77
 
101
- ```ruby
102
- recaps = TvrageApi::Recaps.new
103
- recap.all
104
- recap.show(show: 5410)
105
- recap.last(days: 100)
106
- ```
78
+ ### Search methods
107
79
 
108
- Updates:
80
+ For method attributes read https://github.com/tvapi/tvrage_api/blob/master/lib/tvrage_api/search.rb
109
81
 
110
- ```ruby
111
- client = TvrageApi::Client.new
112
- client.update.last # last 24 hours
113
- client.update.last(hours: 48) # set timeline (default: 48)
114
- client.update.last(sort: 'episodes') # only shows where episodes have changed
115
- client.update.last(since: 1403668430) # updates since last visit
116
- ```
82
+ * by_name
83
+ * by_name_url
84
+ * full_by_name
85
+ * full_by_name_url
117
86
 
118
- ```ruby
119
- update = TvrageApi::Update.new
120
- update.last # last 24 hours
121
- update.last(hours: 48) # set timeline (default: 48)
122
- update.last(sort: 'episodes') # only shows where episodes have changed
123
- update.last(since: 1403668430) # updates since last visit
124
- ```
87
+ ### Show (search show) methods
88
+
89
+ For method attributes read https://github.com/tvapi/tvrage_api/blob/master/lib/tvrage_api/show.rb
90
+
91
+ * find
92
+ * find_url
93
+ * find_full
94
+ * find_full_url
95
+ * episodes
96
+ * episodes_url
97
+ * episode
98
+ * episode_url
99
+ * all
100
+ * all_url
101
+
102
+
103
+ ### Update methods
104
+
105
+ For method attributes read https://github.com/tvapi/tvrage_api/blob/master/lib/tvrage_api/update.rb
106
+
107
+ * last
108
+ * last_url
125
109
 
126
110
  ## Contributing
127
111
 
@@ -1,7 +1,17 @@
1
+ require 'ov'
2
+
1
3
  module TvrageApi
2
- module Request; end
4
+ module AttributesMapping
5
+ module Recap; end
6
+ module Search; end
7
+ module Show; end
8
+ end
3
9
  end
4
10
 
11
+ require 'tvrage_api/attributes_mapping/recap/show'
12
+ require 'tvrage_api/attributes_mapping/search/by_name'
13
+ require 'tvrage_api/attributes_mapping/show/episode'
14
+ require 'tvrage_api/attributes_mapping/show/find'
5
15
  require 'tvrage_api/version'
6
16
  require 'tvrage_api/client'
7
17
  require 'tvrage_api/base'
@@ -0,0 +1,5 @@
1
+ require 'hashie'
2
+
3
+ class TvrageApi::AttributesMapping::Recap::Show < Hashie::Trash
4
+ property :show, from: :id
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'hashie'
2
+
3
+ class TvrageApi::AttributesMapping::Search::ByName < Hashie::Trash
4
+ property :show, from: :name
5
+ end
@@ -0,0 +1,6 @@
1
+ require 'hashie'
2
+
3
+ class TvrageApi::AttributesMapping::Show::Episode < Hashie::Trash
4
+ property :sid, from: :show_id
5
+ property :ep, from: :episode
6
+ end
@@ -0,0 +1,5 @@
1
+ require 'hashie'
2
+
3
+ class TvrageApi::AttributesMapping::Show::Find < Hashie::Trash
4
+ property :sid, from: :id
5
+ end
@@ -1,25 +1,65 @@
1
1
  class TvrageApi::Info < TvrageApi::Base
2
+ include Ov
3
+
4
+ # Quick information about tv show
5
+ #
6
+ # access: FREE
7
+ # param:
8
+ # find('buffy')
9
+ # output: Faraday::Response instance with string
10
+ let :find, String do |show|
11
+ find(show: show)
12
+ end
13
+
14
+ # Quick information about tv show
15
+ #
16
+ # access: FREE
17
+ # param:
18
+ # find('buffy', episode: '1x01')
19
+ # find('buffy', exact: 1)
20
+ # output: Faraday::Response instance with string
21
+ let :find, String, Hash do |show, optional_options|
22
+ find(optional_options.merge(show: show))
23
+ end
24
+
2
25
  # Quick information about tv show
3
26
  #
4
27
  # access: FREE
5
- # param: options hash
6
- # show: TV show name
7
- # ep: episode name, format [Season Number]x[Episode Number, with zero at the beginning for 1-9] (optional)
8
- # exact: 1, Only shows that match exactly will be given.
28
+ # param:
29
+ # find(show: 'buffy')
9
30
  # output: Faraday::Response instance with string
10
- def find(options = {})
31
+ let :find, Hash do |options|
11
32
  find_path_with_params(options).get
12
33
  end
13
34
 
14
35
  # Quick information about tv show - return only url
15
36
  #
16
37
  # access: FREE
17
- # param: options hash
18
- # show: TV show name
19
- # ep: episode name, format [Season Number]x[Episode Number, with zero at the beginning for 1-9] (optional)
20
- # exact: 1, Only shows that match exactly will be given.
38
+ # param:
39
+ # find_url('buffy')
40
+ # output: url string
41
+ let :find_url, String do |show|
42
+ find_url(show: show)
43
+ end
44
+
45
+ # Quick information about tv show - return only url
46
+ #
47
+ # access: FREE
48
+ # param:
49
+ # find_url('buffy', episode: '1x01')
50
+ # find_url('buffy', exact: 1)
51
+ # output: url string
52
+ let :find_url, String, Hash do |show, optional_options|
53
+ find_url(optional_options.merge(show: show))
54
+ end
55
+
56
+ # Quick information about tv show - return only url
57
+ #
58
+ # access: FREE
59
+ # param:
60
+ # find_url(show: 'buffy')
21
61
  # output: url string
22
- def find_url(options = {})
62
+ let :find_url, Hash do |options|
23
63
  find_path_with_params(options).url
24
64
  end
25
65
 
@@ -1,4 +1,6 @@
1
1
  class TvrageApi::Recap < TvrageApi::Base
2
+ include Ov
3
+
2
4
  # All recaps
3
5
  #
4
6
  # access: FREE
@@ -18,40 +20,80 @@ class TvrageApi::Recap < TvrageApi::Base
18
20
  # Recaps From Selected Show
19
21
  #
20
22
  # access: FREE
21
- # param: options hash
22
- # show: TV show ID
23
+ # param:
24
+ # show('1234')
25
+ # output: Faraday::Response instance with parsed XML string
26
+ let :show, Any do |id|
27
+ show(id: id)
28
+ end
29
+
30
+ # Recaps From Selected Show
31
+ #
32
+ # access: FREE
33
+ # param:
34
+ # show(id: '1234')
23
35
  # output: Faraday::Response instance with parsed XML string
24
- def show(options = {})
36
+ let :show, Hash do |options|
25
37
  show_path_with_params(options).get
26
38
  end
27
39
 
28
40
  # Recaps From Selected Show - return only url
29
41
  #
30
42
  # access: FREE
31
- # param: options hash
32
- # show: TV show ID
43
+ # param:
44
+ # show_url(1234)
33
45
  # output: url string
34
- def show_url(options = {})
46
+ let :show_url, Any do |id|
47
+ show_url(id: id)
48
+ end
49
+
50
+ # Recaps From Selected Show - return only url
51
+ #
52
+ # access: FREE
53
+ # param:
54
+ # show_url(id: 1234)
55
+ # output: url string
56
+ let :show_url, Hash do |options|
35
57
  show_path_with_params(options).url
36
58
  end
37
59
 
38
60
  # Latest Recaps
39
61
  #
40
62
  # access: FREE
41
- # param: options hash
42
- # days: last x days (default 30)
63
+ # param:
64
+ # last(30)
43
65
  # output: Faraday::Response instance with parsed XML string
44
- def last(options = {})
66
+ let :last, Any do |days|
67
+ last(days: days)
68
+ end
69
+
70
+ # Latest Recaps
71
+ #
72
+ # access: FREE
73
+ # param:
74
+ # last(days: 30)
75
+ # output: Faraday::Response instance with parsed XML string
76
+ let :last, Hash do |options|
45
77
  last_path_with_params(options).get
46
78
  end
47
79
 
48
80
  # Latest Recaps - return only url
49
81
  #
50
82
  # access: FREE
51
- # param: options hash
52
- # days: last x days (default 30)
83
+ # param:
84
+ # last_url(30)
53
85
  # output: url string
54
- def last_url(options = {})
86
+ let :last_url, Any do |days|
87
+ last_url(days: days)
88
+ end
89
+
90
+ # Latest Recaps - return only url
91
+ #
92
+ # access: FREE
93
+ # param:
94
+ # last_url(days: 30)
95
+ # output: url string
96
+ let :last_url, Hash do |options|
55
97
  last_path_with_params(options).url
56
98
  end
57
99
 
@@ -62,7 +104,11 @@ class TvrageApi::Recap < TvrageApi::Base
62
104
  end
63
105
 
64
106
  def show_path_with_params(options)
65
- path(show_path).params(options)
107
+ path(show_path).params(show_mapped_options(options))
108
+ end
109
+
110
+ def show_mapped_options(options)
111
+ TvrageApi::AttributesMapping::Recap::Show.new(options).to_hash
66
112
  end
67
113
 
68
114
  def show_path