nicoquery-crawler 0.0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aac258c7dbf2cf95ad785874395ba7a68ffc0da9
4
+ data.tar.gz: 32de5be84206c90cbd924e8d9eda8846a030e539
5
+ SHA512:
6
+ metadata.gz: 061f0707a69e1fcad3aec5e2c34d5203e9bf82ef68124edaaa43e6e920ba4183dde6b51cf3162ccb86cb55a7c061d432371b698a6461ebbbdf483489508f6abc
7
+ data.tar.gz: 5e8b7c8aba33a2601a02145bb2977a92f4391f7fd660e514a9435f02dd1d6098b78d6623fd04ae84b1d6df97c31f34db3ed5d8311ef2af43205517df36daf6ea
@@ -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 @@
1
+ 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nicoquery-crawler.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Masami Yonehara
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,29 @@
1
+ # Nicoquery::Crawler
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'nicoquery-crawler'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install nicoquery-crawler
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => [:spec]
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ spec.rspec_opts = ['-cfs']
9
+ end
10
+ rescue LoadError => e
11
+ end
@@ -0,0 +1,12 @@
1
+ require "nicoquery/crawler/tag_search"
2
+
3
+
4
+ module NicoQuery
5
+ module Crawler
6
+ def tag_search(tag: tag, sort: sort, order: order, &block)
7
+ NicoQuery::Crawler::TagSearch.execute(tag: tag, sort: sort, order: order, &block)
8
+ end
9
+
10
+ module_function :tag_search
11
+ end
12
+ end
@@ -0,0 +1,44 @@
1
+ require "nicoquery/core"
2
+ require "nicoquery/parser"
3
+ require "nori"
4
+
5
+
6
+ module NicoQuery
7
+ module Crawler
8
+ module TagSearch
9
+ def execute(tag: tag, sort: sort, order: order, &block)
10
+ parser = NicoQuery::Parser::TagSearch.new
11
+ page = 0
12
+
13
+ loop do
14
+ command = nil
15
+ page += 1
16
+
17
+ result = NicoQuery::Core.tag_search(tag: tag, sort: sort, order: order, page: page)
18
+ parser.parse result
19
+
20
+ self.each_movie(parser.items) do |movie|
21
+ command = block.call movie
22
+ break if command == :break || command != :continue
23
+ end
24
+
25
+ break if command == :break || command != :continue
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def continue; :continue end
32
+ def stop; :stop end
33
+
34
+ def each_movie(parsed_movies, &block)
35
+ while parsed_movies.length > 0 do
36
+ block.call parsed_movies.shift
37
+ end
38
+ end
39
+
40
+ module_function :execute
41
+ module_function :each_movie
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module NicoQuery
2
+ module Crawler
3
+ VERSION = "0.0.1.4"
4
+ end
5
+ end
@@ -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 'nicoquery/crawler/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nicoquery-crawler"
8
+ spec.version = NicoQuery::Crawler::VERSION
9
+ spec.authors = ["Masami Yonehara"]
10
+ spec.email = ["zeitdiebe@gmail.com"]
11
+ spec.description = %q{crawler of niconico}
12
+ spec.summary = %q{crawler of niconico}
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.add_runtime_dependency "activesupport", "~> 4.0.0"
22
+ spec.add_runtime_dependency "nicoquery-core"
23
+ spec.add_runtime_dependency "nicoquery-parser"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ end
@@ -0,0 +1,28 @@
1
+ require "nicoquery/crawler"
2
+
3
+
4
+ describe "NicoQuery" do
5
+ describe "tag_search" do
6
+ before do
7
+ counter = 0
8
+ @acquired_movies = []
9
+
10
+ NicoQuery::Crawler::TagSearch.execute( tag: "ゆっくり実況プレイ",
11
+ sort: :published_at,
12
+ order: :asc
13
+ ) do |result|
14
+ counter += 1
15
+ @acquired_movies.push result
16
+ if counter >= 50 then :break else :continue end
17
+ end
18
+ end
19
+
20
+ it "should sorted by published date" do
21
+ expect(@acquired_movies[0].publish_date).to be < @acquired_movies[1].publish_date
22
+ end
23
+
24
+ it "should scrape movie's info the number of times -1 that returns :continue" do
25
+ expect(@acquired_movies.length).to eq 50
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nicoquery-crawler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Masami Yonehara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: nicoquery-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nicoquery-parser
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: crawler of niconico
98
+ email:
99
+ - zeitdiebe@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .ruby-version
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - lib/nicoquery/crawler.rb
111
+ - lib/nicoquery/crawler/tag_search.rb
112
+ - lib/nicoquery/crawler/version.rb
113
+ - nicoquery-crawler.gemspec
114
+ - spec/tag_search_spec.rb
115
+ homepage: ''
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.0.3
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: crawler of niconico
139
+ test_files:
140
+ - spec/tag_search_spec.rb