goggle-box 0.1.0 → 0.1.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.
data/Readme.md CHANGED
@@ -21,13 +21,13 @@ It allows you to search and retrieve Shows and Episodes from the TVRage API. Obj
21
21
  >> show = GoggleBox::TVRage::Show.new(shows.first.showid, :lazy => true)
22
22
 
23
23
  - If one season only
24
- >> show.episodelist.season => Only season or array of seasons
25
- >> show.episodelist.season.episode => Episodes in this season
24
+ >> show.episode_list.seasons => Only season or array of seasons
25
+ >> show.episode_list.seasons.episodes => Episodes in this season
26
26
 
27
27
  - If more than one season
28
- >> show.episodelist.season.first => First season
29
- >> show.episodelist.season.second => Second season etc
30
- >> show.episodelist.season.first.episode => Array of episodes in season etc
28
+ >> show.episode_list.seasons.first => First season
29
+ >> show.episode_list.seasons.second => Second season etc
30
+ >> show.episode_list.seasons.first.episodes => Array of episodes in season etc
31
31
 
32
32
  #### Episode Information
33
33
  >> GoggleBox::TVRage::Episode.listings_by_show(show.showid)
@@ -1,11 +1,23 @@
1
1
  require 'ostruct'
2
2
 
3
3
  module Objectify
4
+
5
+ DICTIONARY = {
6
+ 'season' => 'seasons',
7
+ 'episodelist' => 'episode_list',
8
+ 'episode' => 'episodes'
9
+ }
10
+
11
+ def swap_words(word)
12
+ return word unless DICTIONARY[word]
13
+ DICTIONARY[word]
14
+ end
15
+
4
16
  def objectify(object = self)
5
17
  return case object
6
18
  when Hash
7
19
  obj = {}
8
- object.each { |k,v| obj[k.downcase] = objectify(v) }
20
+ object.each { |k,v| obj[swap_words(k.downcase)] = objectify(v) }
9
21
  OpenStruct.new(obj)
10
22
  when Array
11
23
  object = object.clone
@@ -1,3 +1,3 @@
1
1
  module GoggleBox
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -70,20 +70,20 @@ module GoggleBox::TVRage
70
70
  end
71
71
 
72
72
  it "Show should respond to episodelist" do
73
- subject.episodelist.class.should be(OpenStruct)
73
+ subject.episode_list.class.should be(OpenStruct)
74
74
  end
75
75
 
76
76
  describe "Shows with just one season" do
77
77
  it "Episodelist should have an OpenStruct of a season if just one" do
78
- subject.episodelist.season.class.should be(OpenStruct)
78
+ subject.episode_list.seasons.class.should be(OpenStruct)
79
79
  end
80
80
 
81
81
  it "Season should have an array of episodes if more than one" do
82
- subject.episodelist.season.episode.class.should be(Array)
82
+ subject.episode_list.seasons.episodes.class.should be(Array)
83
83
  end
84
84
 
85
85
  it "Season should more than one episode to constitute an array" do
86
- subject.episodelist.season.episode.size.should have_at_least(2).items
86
+ subject.episode_list.seasons.episodes.size.should have_at_least(2).items
87
87
  end
88
88
  end
89
89
 
@@ -94,15 +94,15 @@ module GoggleBox::TVRage
94
94
  end
95
95
 
96
96
  it "Episodelist should have an Array of seasons" do
97
- subject.episodelist.season.class.should be(Array)
97
+ subject.episode_list.seasons.class.should be(Array)
98
98
  end
99
99
 
100
100
  it "Array of Seasons shouldn't be equal to one" do
101
- subject.episodelist.season.size.should have_at_least(2).items
101
+ subject.episode_list.seasons.size.should have_at_least(2).items
102
102
  end
103
103
 
104
104
  it "Episode should have an OpenStruct if only one episode" do
105
- subject.episodelist.season[1].episode.class.should be(OpenStruct)
105
+ subject.episode_list.seasons[1].episodes.class.should be(OpenStruct)
106
106
  end
107
107
 
108
108
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goggle-box
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Ingham