smiling 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +44 -0
- data/SPEC.md +25 -0
- data/lib/smiling/tag.rb +34 -0
- data/lib/smiling/version.rb +3 -0
- data/lib/smiling/video.rb +62 -0
- data/lib/smiling.rb +33 -0
- data/smiling.gemspec +27 -0
- data/spec/CHANGELOG.md +11 -0
- data/spec/fixtures/getthumbinfo_sm9.txt +48 -0
- data/spec/fixtures/getthumbinfo_sm9.xml +40 -0
- data/spec/smiling_spec.rb +18 -0
- data/spec/smiling_tag_spec.rb +17 -0
- data/spec/smiling_video_spec.rb +83 -0
- data/spec/spec_helper.rb +30 -0
- metadata +189 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Junya Ogura
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Smiling
|
2
|
+
|
3
|
+
[![Build Status](http://travis-ci.org/qnyp/smiling.png)](http://travis-ci.org/qnyp/smiling)
|
4
|
+
|
5
|
+
API wrapper for Nico Nico Douga.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'smiling'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install smiling
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Fetch video information via getthumbinfo API.
|
24
|
+
|
25
|
+
video = Smiling.video('sm9')
|
26
|
+
puts video.title
|
27
|
+
|
28
|
+
video.tags['jp'] do |tag|
|
29
|
+
# tag is an instance of Smiling::Video
|
30
|
+
print tag.value
|
31
|
+
puts ' (lock)' if tag.locked?
|
32
|
+
end
|
33
|
+
|
34
|
+
See also: [Nico Nico Douga API](http://dic.nicovideo.jp/a/%E3%83%8B%E3%82%B3%E3%83%8B%E3%82%B3%E5%8B%95%E7%94%BBapi)
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
#############################################################################
|
4
|
+
#
|
5
|
+
# Helper functions
|
6
|
+
#
|
7
|
+
#############################################################################
|
8
|
+
|
9
|
+
def name
|
10
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
11
|
+
end
|
12
|
+
|
13
|
+
def version
|
14
|
+
line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
|
15
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
16
|
+
end
|
17
|
+
|
18
|
+
#############################################################################
|
19
|
+
#
|
20
|
+
# Standard tasks
|
21
|
+
#
|
22
|
+
#############################################################################
|
23
|
+
|
24
|
+
task :default => :spec
|
25
|
+
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
28
|
+
t.rspec_opts = '--color'
|
29
|
+
t.pattern = 'spec/*_spec.rb'
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'rdoc/task'
|
33
|
+
RDoc::Task.new do |rdoc|
|
34
|
+
rdoc.rdoc_dir = 'rdoc'
|
35
|
+
rdoc.title = "#{name} #{version}"
|
36
|
+
rdoc.rdoc_files.include('README*')
|
37
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
+
rdoc.markup = 'tomdoc'
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Open an irb session preloaded with this library'
|
42
|
+
task :console do
|
43
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
44
|
+
end
|
data/SPEC.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# SPEC
|
2
|
+
|
3
|
+
## thumb
|
4
|
+
|
5
|
+
work in progress.
|
6
|
+
|
7
|
+
## getflv
|
8
|
+
|
9
|
+
work in progress.
|
10
|
+
|
11
|
+
## getmarquee
|
12
|
+
|
13
|
+
work in progress.
|
14
|
+
|
15
|
+
## getrelation
|
16
|
+
|
17
|
+
work in progress.
|
18
|
+
|
19
|
+
## msg
|
20
|
+
|
21
|
+
work in progress.
|
22
|
+
|
23
|
+
## rss
|
24
|
+
|
25
|
+
work in progress.
|
data/lib/smiling/tag.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Smiling
|
2
|
+
# Public: Tag represents a tag for video.
|
3
|
+
class Tag
|
4
|
+
attr_reader :value
|
5
|
+
|
6
|
+
# Public: Create an instance of Tag.
|
7
|
+
#
|
8
|
+
# attributes - The hash options.
|
9
|
+
# :value - The String value of tag.
|
10
|
+
# :lock - The Boolean value for lock state (optional).
|
11
|
+
#
|
12
|
+
# Examples
|
13
|
+
#
|
14
|
+
# Tag.new(value: 'Foo')
|
15
|
+
# Tag.new(value: 'Foo', lock: true)
|
16
|
+
def initialize(attributes)
|
17
|
+
@value = attributes[:value] unless attributes[:value].nil?
|
18
|
+
@lock = attributes[:lock].nil? ? false : attributes[:lock]
|
19
|
+
end
|
20
|
+
|
21
|
+
# Public: Returns true when tag is locked.
|
22
|
+
#
|
23
|
+
# Examples
|
24
|
+
#
|
25
|
+
# tag = Tag.new(value: 'Foo', lock: true)
|
26
|
+
# tag.locked?
|
27
|
+
# # => true
|
28
|
+
#
|
29
|
+
# Returns the Boolean value.
|
30
|
+
def locked?
|
31
|
+
@lock
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module Smiling
|
4
|
+
# Public: Video represents a video of Nico Nico Douga.
|
5
|
+
class Video
|
6
|
+
attr_reader :id
|
7
|
+
attr_reader :title
|
8
|
+
attr_reader :description
|
9
|
+
attr_reader :thumbnail_url
|
10
|
+
attr_reader :first_retrieve
|
11
|
+
attr_reader :length
|
12
|
+
attr_reader :movie_type
|
13
|
+
attr_reader :size_high
|
14
|
+
attr_reader :size_low
|
15
|
+
attr_reader :view_counter
|
16
|
+
attr_reader :comment_num
|
17
|
+
attr_reader :mylist_counter
|
18
|
+
attr_reader :last_res_body
|
19
|
+
attr_reader :watch_url
|
20
|
+
attr_reader :type
|
21
|
+
attr_reader :embeddable
|
22
|
+
attr_reader :no_live_play
|
23
|
+
attr_reader :tags
|
24
|
+
attr_reader :user_id
|
25
|
+
|
26
|
+
# Public: Create an instance of Video.
|
27
|
+
#
|
28
|
+
# doc - The Nokogiri::XML::Document contains response of getthumbinfo API.
|
29
|
+
def initialize(doc)
|
30
|
+
thumb = doc.xpath('nicovideo_thumb_response/thumb')
|
31
|
+
@id = thumb.xpath('video_id').text
|
32
|
+
@title = thumb.xpath('title').text
|
33
|
+
@description = thumb.xpath('description').text
|
34
|
+
@thumbnail_url = thumb.xpath('thumbnail_url').text
|
35
|
+
@first_retrieve = Time.parse(thumb.xpath('first_retrieve').text)
|
36
|
+
@length = thumb.xpath('length').text
|
37
|
+
@movie_type = thumb.xpath('movie_type').text
|
38
|
+
@size_high = thumb.xpath('size_high').text.to_i
|
39
|
+
@size_low = thumb.xpath('size_low').text.to_i
|
40
|
+
@view_counter = thumb.xpath('view_counter').text.to_i
|
41
|
+
@comment_num = thumb.xpath('comment_num').text.to_i
|
42
|
+
@mylist_counter = thumb.xpath('mylist_counter').text.to_i
|
43
|
+
@last_res_body = thumb.xpath('last_res_body').text
|
44
|
+
@watch_url = thumb.xpath('watch_url').text
|
45
|
+
@type = thumb.xpath('thumb_type').text
|
46
|
+
@embeddable = thumb.xpath('embeddable').text
|
47
|
+
@no_live_play = thumb.xpath('no_live_play').text
|
48
|
+
|
49
|
+
@tags = {}
|
50
|
+
thumb.xpath('tags').each do |tags|
|
51
|
+
domain = tags['domain']
|
52
|
+
@tags[domain] = []
|
53
|
+
tags.xpath('tag').each do |tag|
|
54
|
+
lock = tag['lock'] == '1' ? true : false
|
55
|
+
@tags[domain] << Tag.new(value: tag.text, lock: lock)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
@user_id = thumb.xpath('user_id').text.to_i
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/smiling.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
# Public: Utility methods useful for fetching information from Nico Nico Douga.
|
5
|
+
# All methods are module methods and should be called on the Smiling module.
|
6
|
+
#
|
7
|
+
# Examples
|
8
|
+
#
|
9
|
+
# Smiling.video('sm9')
|
10
|
+
# # => #<Smiling::Video:0x007fd24bb62d88 @id="sm9">
|
11
|
+
module Smiling
|
12
|
+
autoload :Tag, 'smiling/tag'
|
13
|
+
autoload :Video, 'smiling/video'
|
14
|
+
autoload :VERSION, 'smiling/version'
|
15
|
+
|
16
|
+
include HTTParty
|
17
|
+
parser(Proc.new { |body| Nokogiri::XML(body) })
|
18
|
+
base_uri 'ext.nicovideo.jp'
|
19
|
+
|
20
|
+
# Public: Get video information with getthumbinfo API.
|
21
|
+
#
|
22
|
+
# id - The String of video id to get the information.
|
23
|
+
#
|
24
|
+
# Examples
|
25
|
+
#
|
26
|
+
# video = Smiling.video('sm9')
|
27
|
+
# # => #<Smiling::Video:0x007fd24bb62d88 @id="sm9">
|
28
|
+
#
|
29
|
+
# Returns an instance of Smiling::Video.
|
30
|
+
def self.video(id)
|
31
|
+
Video.new(self.get("/api/getthumbinfo/#{id}"))
|
32
|
+
end
|
33
|
+
end
|
data/smiling.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/smiling/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Junya Ogura"]
|
6
|
+
gem.email = ["junyaogura@gmail.com"]
|
7
|
+
gem.description = %q{API wrapper for Nico Nico Douga (experimental)}
|
8
|
+
gem.summary = %q{API wrapper for Nico Nico Douga}
|
9
|
+
gem.homepage = "https://github.com/qnyp/smiling"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "smiling"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Smiling::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rake', '~> 0.9.0'
|
19
|
+
gem.add_development_dependency 'rdoc', '~> 3.0'
|
20
|
+
gem.add_development_dependency 'rspec', '~> 2.10.0'
|
21
|
+
gem.add_development_dependency 'simplecov', '~> 0.6.0'
|
22
|
+
gem.add_development_dependency 'webmock', '~> 1.8.0'
|
23
|
+
|
24
|
+
gem.add_dependency 'nokogiri', '~> 1.5.0'
|
25
|
+
gem.add_dependency 'httparty', '~> 0.8.0'
|
26
|
+
gem.add_dependency('jruby-openssl') if RUBY_PLATFORM == 'java'
|
27
|
+
end
|
data/spec/CHANGELOG.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Tue, 08 May 2012 10:44:11 GMT
|
3
|
+
Server: Apache
|
4
|
+
x-niconico-authflag: 0
|
5
|
+
Content-Length: 1396
|
6
|
+
Connection: close
|
7
|
+
Content-Type: text/xml; charset=UTF-8
|
8
|
+
|
9
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
10
|
+
<nicovideo_thumb_response status="ok">
|
11
|
+
<thumb>
|
12
|
+
<video_id>sm9</video_id>
|
13
|
+
<title>新・豪血寺一族 -煩悩解放 - レッツゴー!陰陽師</title>
|
14
|
+
<description>レッツゴー!陰陽師(フルコーラスバージョン)</description>
|
15
|
+
<thumbnail_url>http://tn-skr2.smilevideo.jp/smile?i=9</thumbnail_url>
|
16
|
+
<first_retrieve>2007-03-06T00:33:00+09:00</first_retrieve>
|
17
|
+
<length>5:19</length>
|
18
|
+
<movie_type>flv</movie_type>
|
19
|
+
<size_high>21138631</size_high>
|
20
|
+
<size_low>17436492</size_low>
|
21
|
+
<view_counter>9860861</view_counter>
|
22
|
+
<comment_num>3996941</comment_num>
|
23
|
+
<mylist_counter>110442</mylist_counter>
|
24
|
+
<last_res_body>ギターソロ長門有希 憂ううううううううう </last_res_body>
|
25
|
+
<watch_url>http://www.nicovideo.jp/watch/sm9</watch_url>
|
26
|
+
<thumb_type>video</thumb_type>
|
27
|
+
<embeddable>1</embeddable>
|
28
|
+
<no_live_play>0</no_live_play>
|
29
|
+
<tags domain="jp">
|
30
|
+
<tag lock="1">陰陽師</tag>
|
31
|
+
<tag lock="1">レッツゴー!陰陽師</tag>
|
32
|
+
<tag lock="1">公式</tag>
|
33
|
+
<tag lock="1">音楽</tag>
|
34
|
+
<tag lock="1">ゲーム</tag>
|
35
|
+
<tag>β時代の英雄</tag>
|
36
|
+
<tag>最古の動画</tag>
|
37
|
+
<tag>1000万再生予備軍</tag>
|
38
|
+
<tag>原点回帰</tag>
|
39
|
+
</tags>
|
40
|
+
<tags domain="tw">
|
41
|
+
<tag>週刊niconico排行榜第1名獲得影片</tag>
|
42
|
+
<tag>原點回歸</tag>
|
43
|
+
<tag>陰陽師的変</tag>
|
44
|
+
<tag>彈幕整理中</tag>
|
45
|
+
</tags>
|
46
|
+
<user_id>4</user_id>
|
47
|
+
</thumb>
|
48
|
+
</nicovideo_thumb_response>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<nicovideo_thumb_response status="ok">
|
3
|
+
<thumb>
|
4
|
+
<video_id>sm9</video_id>
|
5
|
+
<title>新・豪血寺一族 -煩悩解放 - レッツゴー!陰陽師</title>
|
6
|
+
<description>レッツゴー!陰陽師(フルコーラスバージョン)</description>
|
7
|
+
<thumbnail_url>http://tn-skr2.smilevideo.jp/smile?i=9</thumbnail_url>
|
8
|
+
<first_retrieve>2007-03-06T00:33:00+09:00</first_retrieve>
|
9
|
+
<length>5:19</length>
|
10
|
+
<movie_type>flv</movie_type>
|
11
|
+
<size_high>21138631</size_high>
|
12
|
+
<size_low>17436492</size_low>
|
13
|
+
<view_counter>9860861</view_counter>
|
14
|
+
<comment_num>3996941</comment_num>
|
15
|
+
<mylist_counter>110442</mylist_counter>
|
16
|
+
<last_res_body>ギターソロ長門有希 憂ううううううううう </last_res_body>
|
17
|
+
<watch_url>http://www.nicovideo.jp/watch/sm9</watch_url>
|
18
|
+
<thumb_type>video</thumb_type>
|
19
|
+
<embeddable>1</embeddable>
|
20
|
+
<no_live_play>0</no_live_play>
|
21
|
+
<tags domain="jp">
|
22
|
+
<tag lock="1">陰陽師</tag>
|
23
|
+
<tag lock="1">レッツゴー!陰陽師</tag>
|
24
|
+
<tag lock="1">公式</tag>
|
25
|
+
<tag lock="1">音楽</tag>
|
26
|
+
<tag lock="1">ゲーム</tag>
|
27
|
+
<tag>β時代の英雄</tag>
|
28
|
+
<tag>最古の動画</tag>
|
29
|
+
<tag>1000万再生予備軍</tag>
|
30
|
+
<tag>原点回帰</tag>
|
31
|
+
</tags>
|
32
|
+
<tags domain="tw">
|
33
|
+
<tag>週刊niconico排行榜第1名獲得影片</tag>
|
34
|
+
<tag>原點回歸</tag>
|
35
|
+
<tag>陰陽師的変</tag>
|
36
|
+
<tag>彈幕整理中</tag>
|
37
|
+
</tags>
|
38
|
+
<user_id>4</user_id>
|
39
|
+
</thumb>
|
40
|
+
</nicovideo_thumb_response>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
describe Smiling do
|
6
|
+
describe '.video(id)' do
|
7
|
+
context "when id is 'sm9'" do
|
8
|
+
before do
|
9
|
+
stub_request(:get, 'ext.nicovideo.jp/api/getthumbinfo/sm9').
|
10
|
+
to_return(fixture_content('getthumbinfo_sm9.txt'))
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { Smiling.video('sm9') }
|
14
|
+
it { should be_kind_of(Smiling::Video) }
|
15
|
+
its(:id) { should eq('sm9') }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Smiling::Tag do
|
5
|
+
context 'tag is not locked' do
|
6
|
+
let(:tag) { Smiling::Tag.new(value: 'Foo') }
|
7
|
+
subject { tag }
|
8
|
+
it { should_not be_locked }
|
9
|
+
its(:value) { should eq('Foo') }
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'tag is locked' do
|
13
|
+
let(:tag) { Smiling::Tag.new(value: 'Foo', lock: true) }
|
14
|
+
subject { tag }
|
15
|
+
it { should be_locked }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
describe Smiling::Video do
|
6
|
+
let(:xml_doc) { Nokogiri::XML(fixture_content('getthumbinfo_sm9.xml')) }
|
7
|
+
let(:video) { Smiling::Video.new(xml_doc) }
|
8
|
+
|
9
|
+
subject { video }
|
10
|
+
its(:id) { should eq('sm9') }
|
11
|
+
its(:title) { should eq('新・豪血寺一族 -煩悩解放 - レッツゴー!陰陽師') }
|
12
|
+
its(:description) { should eq('レッツゴー!陰陽師(フルコーラスバージョン)') }
|
13
|
+
its(:thumbnail_url) { should eq('http://tn-skr2.smilevideo.jp/smile?i=9') }
|
14
|
+
its(:length) { should eq('5:19') }
|
15
|
+
its(:movie_type) { should eq('flv') }
|
16
|
+
its(:last_res_body) { should eq('ギターソロ長門有希 憂ううううううううう ') }
|
17
|
+
its(:watch_url) { should eq('http://www.nicovideo.jp/watch/sm9') }
|
18
|
+
its(:type) { should eq('video') }
|
19
|
+
its(:embeddable) { should eq('1') }
|
20
|
+
its(:no_live_play) { should eq('0') }
|
21
|
+
|
22
|
+
describe 'first_retrieve' do
|
23
|
+
subject { video.first_retrieve }
|
24
|
+
it { should be_kind_of(Time) }
|
25
|
+
it { should eq(Time.parse('2007-03-06 00:33:00 +0900')) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'size_high' do
|
29
|
+
subject { video.size_high }
|
30
|
+
it { should be_kind_of(Integer) }
|
31
|
+
it { should eq(21138631) }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'size_low' do
|
35
|
+
subject { video.size_low }
|
36
|
+
it { should be_kind_of(Integer) }
|
37
|
+
it { should eq(17436492) }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'view_counter' do
|
41
|
+
subject { video.view_counter }
|
42
|
+
it { should be_kind_of(Integer) }
|
43
|
+
it { should eq(9860861) }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'comment_num' do
|
47
|
+
subject { video.comment_num }
|
48
|
+
it { should be_kind_of(Integer) }
|
49
|
+
it { should eq(3996941) }
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'mylist_counter' do
|
53
|
+
subject { video.mylist_counter }
|
54
|
+
it { should be_kind_of(Integer) }
|
55
|
+
it { should eq(110442) }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'tags' do
|
59
|
+
subject { video.tags }
|
60
|
+
it { should be_kind_of(Hash) }
|
61
|
+
it { should have(2).tags }
|
62
|
+
its(:keys) { should include('jp') }
|
63
|
+
its(:keys) { should include('tw') }
|
64
|
+
|
65
|
+
describe "tags['jp']" do
|
66
|
+
subject { video.tags['jp'] }
|
67
|
+
it { should have(9).tag_objects }
|
68
|
+
its(:first) { should be_kind_of(Smiling::Tag) }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "tags['tw']" do
|
72
|
+
subject { video.tags['tw'] }
|
73
|
+
it { should have(4).tag_objects }
|
74
|
+
its(:first) { should be_kind_of(Smiling::Tag) }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'user_id' do
|
79
|
+
subject { video.user_id }
|
80
|
+
it { should be_kind_of(Integer) }
|
81
|
+
it { should eq(4) }
|
82
|
+
end
|
83
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter '.bundle/'
|
4
|
+
add_filter 'spec/'
|
5
|
+
end
|
6
|
+
|
7
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'webmock/rspec'
|
11
|
+
|
12
|
+
require 'smiling'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
end
|
16
|
+
|
17
|
+
# Public: Returns the String of specified file contents.
|
18
|
+
#
|
19
|
+
# filename - Fixture filename.
|
20
|
+
#
|
21
|
+
# Examples
|
22
|
+
#
|
23
|
+
# stub_request(:get, 'ext.nicovideo.jp/api/getthumbinfo/sm9').
|
24
|
+
# to_return(fixture_content('getthumbinfo_sm9.txt'))
|
25
|
+
#
|
26
|
+
# Returns the String.
|
27
|
+
def fixture_content(filename)
|
28
|
+
path = File.expand_path("../fixtures/#{filename}", __FILE__)
|
29
|
+
File.read(path)
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smiling
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Junya Ogura
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.10.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.10.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: simplecov
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.6.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.6.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: webmock
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.8.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.8.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: nokogiri
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.5.0
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.5.0
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: httparty
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.8.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.8.0
|
126
|
+
description: API wrapper for Nico Nico Douga (experimental)
|
127
|
+
email:
|
128
|
+
- junyaogura@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .travis.yml
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- SPEC.md
|
140
|
+
- lib/smiling.rb
|
141
|
+
- lib/smiling/tag.rb
|
142
|
+
- lib/smiling/version.rb
|
143
|
+
- lib/smiling/video.rb
|
144
|
+
- smiling.gemspec
|
145
|
+
- spec/CHANGELOG.md
|
146
|
+
- spec/fixtures/getthumbinfo_sm9.txt
|
147
|
+
- spec/fixtures/getthumbinfo_sm9.xml
|
148
|
+
- spec/smiling_spec.rb
|
149
|
+
- spec/smiling_tag_spec.rb
|
150
|
+
- spec/smiling_video_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
homepage: https://github.com/qnyp/smiling
|
153
|
+
licenses: []
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
hash: 3326149382230922117
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
segments:
|
174
|
+
- 0
|
175
|
+
hash: 3326149382230922117
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 1.8.23
|
179
|
+
signing_key:
|
180
|
+
specification_version: 3
|
181
|
+
summary: API wrapper for Nico Nico Douga
|
182
|
+
test_files:
|
183
|
+
- spec/CHANGELOG.md
|
184
|
+
- spec/fixtures/getthumbinfo_sm9.txt
|
185
|
+
- spec/fixtures/getthumbinfo_sm9.xml
|
186
|
+
- spec/smiling_spec.rb
|
187
|
+
- spec/smiling_tag_spec.rb
|
188
|
+
- spec/smiling_video_spec.rb
|
189
|
+
- spec/spec_helper.rb
|