myanimelist 0.0.3 → 0.0.5

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: 1d8e77f05e3680db2d96f13495dbbc870175a193
4
- data.tar.gz: 05e0f5c18412229addebb096510fcaceb921e3d0
3
+ metadata.gz: daf329d0c0ae0f725d7d1607b1991328bed45bec
4
+ data.tar.gz: 915fa0a214e02db2ec8d67e63e5466dd7e96c492
5
5
  SHA512:
6
- metadata.gz: bc7812a458ecae48e37ee8e4f5eea3465cc3a0c02b196f8b25d99ac2b79357beeb2136e44d6c0aac02a6bc22f97520274a1750d0834173d4e5f5abd8ee94d650
7
- data.tar.gz: 14d83c4cbf80eb1546ccf2f13cf865af985eb1b4d18c4d4a2eeeae966934b9c655540926161c1a06e99978b1edb34a8a914815dcac4b531062702a5cf872b54a
6
+ metadata.gz: 7c5653f7481a3063c2edc219aaf7a0cfdcad7413d8789e8db7ec9052712e8ffb96f8cf27ab4856d4e7ca0546fe3fb925267e6e9314750ce62974b6d9e4ab1ea0
7
+ data.tar.gz: 9df9b5cb74c5e2c16381d897aea94b9cd3a755a91974c7fa2b563f82f1070f98bf859f6a2fce40928b23b5dfe398afbabb8cac681751b9929fbc850ed8587597
@@ -4,6 +4,7 @@ require 'active_support/core_ext/hash'
4
4
  require 'myanimelist/anime'
5
5
  require 'myanimelist/manga'
6
6
  require 'myanimelist/credentials'
7
+ require 'myanimelist/serializer'
7
8
 
8
9
  module MyAnimeList
9
10
  def self.configure(&block)
@@ -22,7 +22,12 @@ module MyAnimeList
22
22
  end
23
23
 
24
24
  def parse_xml(response)
25
- Hash.from_xml response
25
+ serialize Hash.from_xml response
26
+ end
27
+
28
+ def serialize(data)
29
+ result = MyAnimeList::Serializer.new data, 'anime'
30
+ result.fetch
26
31
  end
27
32
 
28
33
  end
@@ -22,7 +22,12 @@ module MyAnimeList
22
22
  end
23
23
 
24
24
  def parse_xml(response)
25
- Hash.from_xml response
25
+ serialize Hash.from_xml response
26
+ end
27
+
28
+ def serialize(data)
29
+ result = MyAnimeList::Serializer.new data, 'manga'
30
+ result.fetch
26
31
  end
27
32
 
28
33
  end
@@ -0,0 +1,29 @@
1
+ module MyAnimeList
2
+ class Serializer
3
+ def initialize(data, type)
4
+ @type = type
5
+ @animes = data || []
6
+ end
7
+
8
+ def fetch
9
+ serialize_data
10
+ end
11
+
12
+ def serialize_data
13
+ return @animes if is_array? @animes
14
+
15
+ collection = []
16
+ data = @animes[@type]['entry']
17
+ if is_array? data
18
+ collection += data
19
+ else
20
+ collection << data
21
+ end
22
+ end
23
+
24
+ def is_array?(data)
25
+ data.is_a? Array
26
+ end
27
+
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Myanimelist
2
- VERSION = "0.0.3"
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myanimelist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvey Ico
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,6 +82,7 @@ files:
82
82
  - lib/myanimelist/anime.rb
83
83
  - lib/myanimelist/credentials.rb
84
84
  - lib/myanimelist/manga.rb
85
+ - lib/myanimelist/serializer.rb
85
86
  - lib/myanimelist/version.rb
86
87
  - myanimelist.gemspec
87
88
  homepage: https://github.com/sanzo12/myanimelist