ann_wrapper 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20fb6fdc088155e3d21d55bdd957fe895863f6ea
4
- data.tar.gz: e7e94ec1418f697cdc0764495fdcd31a0ad962e7
3
+ metadata.gz: 8527b835977682de747e937629083821269c86f3
4
+ data.tar.gz: 37915e0c85143251ea32954ee34be0236002a10a
5
5
  SHA512:
6
- metadata.gz: 32aac6ddb361a0dc399cc1cb3df6e28be891c42d08e5f5447bddec6ee27877641f1288205869073de2fbfdc4853c1cd81135b7928ad8fc40703c8142655f1b05
7
- data.tar.gz: ba760c4c2e2e4c7ffd9c784c3fdca0cc3581aef517a4e99b2ce536736df3c53fdfe3ccb5948eede7d3c812ac8f7ea1ef210a44dcab317f5f46638902860045e2
6
+ metadata.gz: a039e4b0a25587dbc4ead543fa1512788ad7990e8b271b88367d7312b90aec131d3927caf388cb7184c7fe20ede10740631b92ddc8287d0f08caa621c75c6fee
7
+ data.tar.gz: 871b0a8e7033996ecf74afb762c2cfab678bcca359311cf519ff9a03ff273e1fb759397cf98765a558b256510fbbb0e6a5db6a07af0cd874e284e5d4f368fe45
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ann_wrapper.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 shawntoffel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # ann_wrapper
2
+
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/ann_wrapper.png)](http://badge.fury.io/rb/ann_wrapper)
5
+ [![Build Status](https://travis-ci.org/Getkura/ann_wrapper.png?branch=dev)](https://travis-ci.org/Getkura/ann_wrapper)
6
+
7
+
8
+ A simple ruby wrapper/abstraction for the [Anime News Network API](http://www.animenewsnetwork.com/encyclopedia/api.php)
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'ann_wrapper'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install ann_wrapper
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -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 'ann_wrapper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ann_wrapper"
8
+ spec.version = AnnWrapper::VERSION
9
+ spec.authors = ["shawntoffel"]
10
+ spec.email = ["getkura+ann_wrapper@gmail.com"]
11
+ spec.description = 'A simple wrapper for the Anime News Network API'
12
+ spec.summary = 'Anime News Network API wrapper'
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = ">= 1.9"
22
+
23
+ spec.add_runtime_dependency "nokogiri"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ end
@@ -2,9 +2,11 @@
2
2
  # ANN_Objects
3
3
  ##################################################
4
4
 
5
+
5
6
  # parent with helper methods
6
7
  class ANN
7
8
  private
9
+ ##
8
10
  # define method with supplied name and block
9
11
  def create_method(name, &block)
10
12
  self.class.send(:define_method, name, &block)
@@ -22,6 +24,7 @@ class ANN_Anime < ANN
22
24
  # ann_anime Nokogiri object
23
25
  attr_writer :ann_anime
24
26
 
27
+
25
28
  # initialize and create info methods
26
29
  def initialize(ann_anime)
27
30
  @ann_anime = ann_anime
@@ -50,7 +53,7 @@ class ANN_Anime < ANN
50
53
 
51
54
  end
52
55
 
53
- # return all info with provided key
56
+ # @return [Nokogiri::XML::NodeSet] return all info with provided key
54
57
  def find_info(key)
55
58
  begin
56
59
  @ann_anime.search("info[@type=\"#{key}\"]")
@@ -59,7 +62,27 @@ class ANN_Anime < ANN
59
62
  end
60
63
  end
61
64
 
62
- # returns array of titles grouped by language abbreviation
65
+ ##
66
+ # These methods are created via create_method in the constructor
67
+
68
+ # @return [[String]] returns title(s)
69
+ def title; end
70
+ # @return [[String]] returns synopsis
71
+ def synopsis; end
72
+ # @return [[String]] returns number of episodes
73
+ def num_episodes; end
74
+ # @return [[String]] returns array of genres
75
+ def genres; end
76
+ # @return [[String]] returns array of themes
77
+ def themes; end
78
+ # @return [[String]] returns array of vintage(s)
79
+ def vintage; end
80
+ # @return [[String]] returns op theme(s)
81
+ def op_theme; end
82
+ # @return [[String]] returns ed theme(s)
83
+ def ed_theme; end
84
+
85
+ # @return [Hash] returns hash of titles grouped by language abbreviation
63
86
  def alt_titles
64
87
  begin
65
88
  titles = find_info("Alternative title").group_by {|title| title['lang']}
@@ -74,11 +97,12 @@ class ANN_Anime < ANN
74
97
  end
75
98
  end
76
99
 
100
+ # @return [String] returns anime type
77
101
  def type
78
102
  @type ||= @ann_anime['type']
79
103
  end
80
104
 
81
- # returns array of ANN_Image
105
+ # @return [[ANN_Image]] returns array of ANN_Image
82
106
  def images
83
107
  begin
84
108
  @images ||= find_info("Picture").map do |i|
@@ -89,7 +113,7 @@ class ANN_Anime < ANN
89
113
  end
90
114
  end
91
115
 
92
- # returns array of ANN_Episode
116
+ # @return [[ANN_Episode]] returns array of ANN_Episode
93
117
  def episodes
94
118
  begin
95
119
  @episodes ||= @ann_anime.xpath("//episode").map do |e|
@@ -101,7 +125,7 @@ class ANN_Anime < ANN
101
125
  end
102
126
  end
103
127
 
104
- # returns array of ANN_Staff
128
+ # @return [[ANN_Staff]] returns array of ANN_Staff
105
129
  def staff
106
130
  begin
107
131
  @staff ||= @ann_anime.xpath("//staff").map do |s|
@@ -114,7 +138,7 @@ class ANN_Anime < ANN
114
138
  end
115
139
  end
116
140
 
117
- # returns array of ANN_Cast
141
+ # @return [[ANN_Cast]] returns array of ANN_Cast
118
142
  def cast
119
143
  begin
120
144
  @cast ||= @ann_anime.xpath("//cast").map do |s|
@@ -0,0 +1,3 @@
1
+ module AnnWrapper
2
+ VERSION = "1.1.2"
3
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe "fetch_ann_anime" do
4
+
5
+ context "a valid id is provided" do
6
+ it "should return data for an ann anime" do
7
+ anime = ANN_Wrapper.instance.fetch_ann_anime(11770)
8
+ anime.should_not be_nil
9
+ anime.title.first.should eql "Steins;Gate"
10
+ end
11
+ end
12
+
13
+ context "an invalid id is provided" do
14
+ it "should return an ANN_Error" do
15
+ anime = ANN_Wrapper.instance.fetch_ann_anime(117700)
16
+ anime.should_not be_nil
17
+ anime.should be_kind_of(ANN_Error)
18
+ anime.message.should_not be_nil
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,12 @@
1
+ require 'ann_wrapper'
2
+
3
+ RSpec.configure do |config|
4
+ # Use color in STDOUT
5
+ config.color_enabled = true
6
+
7
+ # Use color not only in STDOUT but also in pagers and files
8
+ config.tty = true
9
+
10
+ # Use the specified formatter
11
+ config.formatter = :documentation # :progress, :html, :textmate
12
+ end
metadata CHANGED
@@ -1,26 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ann_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
- - getkura
7
+ - shawntoffel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-01-07 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rspec
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'
13
69
  description: A simple wrapper for the Anime News Network API
14
- email: getkura+ann_wrapper@gmail.com
15
- executables:
16
- - example
70
+ email:
71
+ - getkura+ann_wrapper@gmail.com
72
+ executables: []
17
73
  extensions: []
18
74
  extra_rdoc_files: []
19
75
  files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - ann_wrapper.gemspec
20
83
  - lib/ann_wrapper.rb
21
84
  - lib/ann_wrapper/ann_objects.rb
22
- - bin/example
23
- homepage: http://rubygems.org/gems/ann_wrapper
85
+ - lib/ann_wrapper/version.rb
86
+ - spec/ann_wrapper_spec.rb
87
+ - spec/spec_helper.rb
88
+ homepage: ''
24
89
  licenses:
25
90
  - MIT
26
91
  metadata: {}
@@ -32,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
32
97
  requirements:
33
98
  - - ">="
34
99
  - !ruby/object:Gem::Version
35
- version: '0'
100
+ version: '1.9'
36
101
  required_rubygems_version: !ruby/object:Gem::Requirement
37
102
  requirements:
38
103
  - - ">="
@@ -44,4 +109,7 @@ rubygems_version: 2.0.3
44
109
  signing_key:
45
110
  specification_version: 4
46
111
  summary: Anime News Network API wrapper
47
- test_files: []
112
+ test_files:
113
+ - spec/ann_wrapper_spec.rb
114
+ - spec/spec_helper.rb
115
+ has_rdoc:
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ##########################################
4
- #
5
- # Example usage of ANN wrapper and methods
6
- #
7
- ##########################################
8
-
9
- require 'ann_wrapper'
10
-
11
- if ARGV.size < 1
12
- puts "Usage: example <ann anime id>"
13
- exit
14
- end
15
-
16
- def show(obj, method)
17
- puts "#{method}: #{obj.send(method).to_s}"
18
- end
19
-
20
- begin
21
- # create ANN API Wrapper instance
22
- anime = ANN_Wrapper.instance.fetch_ann_anime(ARGV[0])
23
-
24
- if anime.is_a?(ANN_Error)
25
- puts anime.message
26
- exit(1)
27
- end
28
-
29
- #demo
30
- show anime, :title
31
- show anime, :alt_titles
32
- show anime, :type
33
- # show anime, :synopsis
34
- show anime, :num_episodes
35
- show anime, :genres
36
- show anime, :themes
37
- # show anime, :op_theme
38
- # show anime, :ed_theme
39
- # show anime, :episodes
40
- # show anime, :staff
41
- # show anime, :cast
42
- # show anime, :images
43
-
44
- #titles = ANN_Wrapper.instance.fetch_titles("anime", 0, 5)
45
- #if titles.is_a?(ANN_Error)
46
- # puts titles.message
47
- # exit(1)
48
- #end
49
- #
50
- #titles.each do |title|
51
- # puts title.id
52
- #end
53
- #
54
- rescue
55
- puts "oops"
56
-
57
- # print last exception and backtrace
58
- puts $!.inspect, $@
59
- end