yahoo-japan-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --drb
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ruby-head
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ # gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.8.3"
13
+ gem "simplecov", "~> 0.5.4"
14
+ gem "spork", "~> 0.9.0"
15
+ end
16
+
17
+ group :test do
18
+ gem "mocha", "~> 0.10.4"
19
+ end
20
+
21
+ gem "rest-client", "~> 1.6.7"
22
+ gem 'nokogiri', "~> 1.5.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Makoto Ishida
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ Yahoo Japan API
2
+ ==========
3
+
4
+ ![travis status](https://secure.travis-ci.org/ishidamakot/yahoo-japan-api.png)
5
+
6
+
7
+ Yahoo! JapanのWeb API
8
+ ----------
9
+
10
+ あとで書く
11
+ ----------
12
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
13
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
14
+ * Fork the project.
15
+ * Start a feature/bugfix branch.
16
+ * Commit and push until you are happy with your contribution.
17
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
18
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
19
+
20
+ Copyright
21
+ ----------
22
+
23
+ Copyright (c) 2012 Makoto Ishida. See LICENSE.txt for
24
+ further details.
25
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "yahoo-japan-api"
18
+ gem.homepage = "http://github.com/ishidamakot/yahoo-japan-api"
19
+ gem.license = "MIT"
20
+ gem.summary = %q{Yahoo! Japan Web API wrapper}
21
+ gem.description = %q{wrapper for Yahoo! Japan Web API}
22
+ gem.email = "ishida.makot@gmail.com"
23
+ gem.authors = ["Makoto Ishida"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "yahoo-japan-api #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,9 @@
1
+ #encoding: utf-8
2
+
3
+ module YahooJapanAPI
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), File.basename(__FILE__))
5
+
6
+ require 'yahoo-japan-api/base'
7
+ require 'yahoo-japan-api/updated_search'
8
+ end
9
+
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ module YahooJapanAPI
4
+ module Base
5
+ def self.included c
6
+ c.extend ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ attr_accessor :appid
11
+ end
12
+
13
+ self.extend ClassMethods
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'restclient'
4
+ require 'nokogiri'
5
+
6
+ module YahooJapanAPI
7
+ class UpdatedSearch
8
+ include YahooJapanAPI::Base
9
+
10
+ @url = "http://search.yahooapis.jp/PremiumWebSearchService/V1/webSearch"
11
+
12
+ def self.call(query)
13
+ response = RestClient.get(@url, params: { appid: @appid, query: query})
14
+ xml = Nokogiri response
15
+ (xml / 'Result').map do |r|
16
+ { title: (r/'Title').text,
17
+ summary: (r/'Summary').text,
18
+ url: (r/'Url').text }
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+ #uncomment the following line to use spork with the debugger
4
+ #require 'spork/ext/ruby-debug'
5
+
6
+ Spork.prefork do
7
+ # Loading more in this block will cause your tests to run faster. However,
8
+ # if you change any configuration or code from libraries loaded here, you'll
9
+ # need to restart spork for it take effect.
10
+
11
+ # --- Instructions ---
12
+ # Sort the contents of this file into a Spork.prefork and a Spork.each_run
13
+ # block.
14
+ #
15
+ # The Spork.prefork block is run only once when the spork server is started.
16
+ # You typically want to place most of your (slow) initializer code in here, in
17
+ # particular, require'ing any 3rd-party gems that you don't normally modify
18
+ # during development.
19
+ #
20
+ # The Spork.each_run block is run each time you run your specs. In case you
21
+ # need to load files that tend to change during development, require them here.
22
+ # With Rails, your application modules are loaded automatically, so sometimes
23
+ # this block can remain empty.
24
+ #
25
+ # Note: You can modify files loaded *from* the Spork.each_run block without
26
+ # restarting the spork server. However, this file itself will not be reloaded,
27
+ # so if you change any of the code inside the each_run block, you still need to
28
+ # restart the server. In general, if you have non-trivial code in this file,
29
+ # it's advisable to move it into a separate file so you can easily edit it
30
+ # without restarting spork. (For example, with RSpec, you could move
31
+ # non-trivial code into a file spec/support/my_helper.rb, making sure that the
32
+ # spec/support/* files are require'd from inside the each_run block.)
33
+ #
34
+ # Any code that is left outside the two blocks will be run during preforking
35
+ # *and* during each_run -- that's probably not what you want.
36
+ #
37
+ # These instructions should self-destruct in 10 seconds. If they don't, feel
38
+ # free to delete them.
39
+
40
+
41
+
42
+
43
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
44
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
45
+ require 'rspec'
46
+ require 'yahoo-japan-api'
47
+
48
+ # Requires supporting files with custom matchers and macros, etc,
49
+ # in ./support/ and its subdirectories.
50
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
51
+
52
+ RSpec.configure do |config|
53
+
54
+ end
55
+ end
56
+
57
+ Spork.each_run do
58
+ # This code will be run each time you run your specs.
59
+
60
+ end
61
+
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ describe YahooJapanAPI::Base do
4
+ it "has appid attribute" do
5
+ YahooJapanAPI::Base.appid = "dummy id"
6
+ YahooJapanAPI::Base.appid.should == "dummy id"
7
+ end
8
+
9
+ it "has appid attribute too included module and class" do
10
+ module ApiModule
11
+ include YahooJapanAPI::Base
12
+ end
13
+ module ApiClass
14
+ include YahooJapanAPI::Base
15
+ end
16
+ ApiModule.appid = "dummy on includer"
17
+ ApiModule.appid.should == "dummy on includer"
18
+ ApiClass.appid = "dummy on includer"
19
+ ApiClass.appid.should == "dummy on includer"
20
+ end
21
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'mocha'
4
+
5
+ describe YahooJapanAPI::UpdatedSearch do
6
+ before(:all) do
7
+ response = <<-"EOR"
8
+ <ResultSet>
9
+ <Result>
10
+ <Title>rubyの何とか</Title>
11
+ <Summary>rubyはあれがこうでこれがああで...</Summary>
12
+ <Url>http://example.net/</Url>
13
+ </Result>
14
+ <Result>
15
+ <Title>rubyのサイト</Title>
16
+ <Summary>色は匂へど散りnilを</Summary>
17
+ <Url>http://rubyruby.net/</Url>
18
+ </Result>
19
+ </ResultSet>
20
+ EOR
21
+ RestClient.expects(:get).returns(response)
22
+ end
23
+
24
+ describe "call" do
25
+ it "returns array of hash that has title, summary and url" do
26
+ YahooJapanAPI::UpdatedSearch.appid = "application ID"
27
+ results = YahooJapanAPI::UpdatedSearch.call("ruby")
28
+ [:title, :summary, :url].each do |key|
29
+ results.first[key].should_not be_nil
30
+ end
31
+
32
+ results.should == [
33
+ {title: "rubyの何とか",
34
+ summary: "rubyはあれがこうでこれがああで...",
35
+ url: "http://example.net/"},
36
+ {title: "rubyのサイト",
37
+ summary: "色は匂へど散りnilを",
38
+ url: "http://rubyruby.net/"}
39
+ ]
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe YahooJapanAPI do
4
+ end
@@ -0,0 +1,73 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "yahoo-japan-api"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Makoto Ishida"]
12
+ s.date = "2012-02-15"
13
+ s.description = "wrapper for Yahoo! Japan Web API"
14
+ s.email = "ishida.makot@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".travis.yml",
23
+ "Gemfile",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/yahoo-japan-api.rb",
29
+ "lib/yahoo-japan-api/base.rb",
30
+ "lib/yahoo-japan-api/updated_search.rb",
31
+ "spec/spec_helper.rb",
32
+ "spec/yahoo-japan-api/base_spec.rb",
33
+ "spec/yahoo-japan-api/updated_search_spec.rb",
34
+ "spec/yahoo-japan-api_spec.rb",
35
+ "yahoo-japan-api.gemspec"
36
+ ]
37
+ s.homepage = "http://github.com/ishidamakot/yahoo-japan-api"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.11"
41
+ s.summary = "Yahoo! Japan Web API wrapper"
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.7"])
48
+ s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5.0"])
49
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
50
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
52
+ s.add_development_dependency(%q<simplecov>, ["~> 0.5.4"])
53
+ s.add_development_dependency(%q<spork>, ["~> 0.9.0"])
54
+ else
55
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
56
+ s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
57
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
58
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
60
+ s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
61
+ s.add_dependency(%q<spork>, ["~> 0.9.0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
65
+ s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
66
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
67
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
68
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
69
+ s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
70
+ s.add_dependency(%q<spork>, ["~> 0.9.0"])
71
+ end
72
+ end
73
+
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yahoo-japan-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Makoto Ishida
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: &19359960 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.7
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *19359960
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ requirement: &19359220 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.5.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *19359220
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &19374920 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.8.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *19374920
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdoc
49
+ requirement: &19373860 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *19373860
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &19373100 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.8.3
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *19373100
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &19372380 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.5.4
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *19372380
80
+ - !ruby/object:Gem::Dependency
81
+ name: spork
82
+ requirement: &19371680 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 0.9.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *19371680
91
+ description: wrapper for Yahoo! Japan Web API
92
+ email: ishida.makot@gmail.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files:
96
+ - LICENSE.txt
97
+ - README.md
98
+ files:
99
+ - .document
100
+ - .rspec
101
+ - .travis.yml
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - VERSION
107
+ - lib/yahoo-japan-api.rb
108
+ - lib/yahoo-japan-api/base.rb
109
+ - lib/yahoo-japan-api/updated_search.rb
110
+ - spec/spec_helper.rb
111
+ - spec/yahoo-japan-api/base_spec.rb
112
+ - spec/yahoo-japan-api/updated_search_spec.rb
113
+ - spec/yahoo-japan-api_spec.rb
114
+ - yahoo-japan-api.gemspec
115
+ homepage: http://github.com/ishidamakot/yahoo-japan-api
116
+ licenses:
117
+ - MIT
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ segments:
129
+ - 0
130
+ hash: 2598808310509313851
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.11
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Yahoo! Japan Web API wrapper
143
+ test_files: []