bookscan 0.4.3 → 0.5.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
data/bookscan.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bookscan}
8
- s.version = "0.4.3"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yoshihiro TAKAHARA"]
12
- s.date = %q{2011-01-19}
12
+ s.date = %q{2011-01-20}
13
13
  s.default_executable = %q{bookscan}
14
14
  s.description = %q{This is a scraper of Bookscan (http://www.bookscan.co.jp) Service.This is *NOT* a official software of Bookscan.}
15
15
  s.email = %q{y.takahara@gmail.com}
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  s.homepage = %q{http://github.com/tumf/bookscan}
41
41
  s.licenses = ["MIT"]
42
42
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.4.2}
43
+ s.rubygems_version = %q{1.3.7}
44
44
  s.summary = %q{BookScan Scraper}
45
45
  s.test_files = [
46
46
  "test/helper.rb",
@@ -48,6 +48,7 @@ Gem::Specification.new do |s|
48
48
  ]
49
49
 
50
50
  if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
52
  s.specification_version = 3
52
53
 
53
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -73,15 +73,12 @@ module Bookscan
73
73
  end
74
74
 
75
75
  def tune(book,type,is_premium = true)
76
- if is_premium
77
- max_queue = 10
78
- else
79
- max_queue = 1
80
- end
76
+ max_queue = 1
77
+ max_queue = 10 if is_premium
81
78
 
82
79
  @tuning = tuning unless @tuning
83
80
  # チューニングいっぱい
84
- raise "tune queue is full" if @tuning.length >= max_queue
81
+ raise SystemExit.new(0,"tune queue is full") if @tuning.length >= max_queue
85
82
  # チューニング
86
83
  return false if tuning?(book,type)
87
84
  # tune
data/lib/bookscan/book.rb CHANGED
@@ -28,8 +28,9 @@ module Bookscan
28
28
  a
29
29
  end
30
30
 
31
- def by_id(book_id)
31
+ def by_id(book_id,type = nil)
32
32
  each do |b|
33
+ next if type and b.tune_type != type
33
34
  return b if b.book_id == book_id
34
35
  end
35
36
  nil
@@ -25,12 +25,13 @@ module Bookscan
25
25
  ts_uniq << t
26
26
  end
27
27
  }
28
- require 'pp'
29
28
  return ts_uniq.compact
30
29
  end
31
30
 
32
31
  def tuned?(book,type)
33
- tuned.has?(book.book_id) and tuned.by_id(book.book_id).tune_type == type
32
+ b = tuned.by_id(book.book_id,type)
33
+ return false unless b
34
+ b.book_id == book.book_id and b.tune_type == type
34
35
  end
35
36
 
36
37
  def books(group = nil)
@@ -240,13 +240,18 @@ module Bookscan
240
240
  type = ask_tune_type(@command_options.shift)
241
241
 
242
242
  if book_id == "all"
243
- tuned = @cache.tuned
243
+ start unless dry_run
244
+ unless dry_run
245
+ @cache.transaction do |cache|
246
+ cache["tuned"] = @agent.tuned
247
+ end
248
+ end
244
249
  @cache.books.each { |book|
245
250
  next unless /#{pattern}/ =~ book.title
246
251
  unless @cache.tuned?(book,type)
247
252
  # tune
248
- start unless dry_run
249
253
  puts "tune for %s: %s" % [type, book.title] if dry_run or @agent.tune(book,type)
254
+ # puts "tune for %s: %s" % [type, book.title]
250
255
  end
251
256
  }
252
257
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookscan
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease:
4
+ hash: 11
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 3
10
- version: 0.4.3
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoshihiro TAKAHARA
@@ -15,12 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-19 00:00:00 +09:00
18
+ date: 2011-01-20 00:00:00 +09:00
19
19
  default_executable: bookscan
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- type: :development
23
- name: shoulda
22
+ prerelease: false
24
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
@@ -30,11 +29,11 @@ dependencies:
30
29
  segments:
31
30
  - 0
32
31
  version: "0"
33
- prerelease: false
34
32
  requirement: *id001
35
- - !ruby/object:Gem::Dependency
33
+ name: shoulda
36
34
  type: :development
37
- name: bundler
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
38
37
  version_requirements: &id002 !ruby/object:Gem::Requirement
39
38
  none: false
40
39
  requirements:
@@ -46,11 +45,11 @@ dependencies:
46
45
  - 0
47
46
  - 0
48
47
  version: 1.0.0
49
- prerelease: false
50
48
  requirement: *id002
51
- - !ruby/object:Gem::Dependency
49
+ name: bundler
52
50
  type: :development
53
- name: jeweler
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
54
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
55
54
  none: false
56
55
  requirements:
@@ -62,11 +61,11 @@ dependencies:
62
61
  - 5
63
62
  - 2
64
63
  version: 1.5.2
65
- prerelease: false
66
64
  requirement: *id003
67
- - !ruby/object:Gem::Dependency
65
+ name: jeweler
68
66
  type: :development
69
- name: rcov
67
+ - !ruby/object:Gem::Dependency
68
+ prerelease: false
70
69
  version_requirements: &id004 !ruby/object:Gem::Requirement
71
70
  none: false
72
71
  requirements:
@@ -76,11 +75,11 @@ dependencies:
76
75
  segments:
77
76
  - 0
78
77
  version: "0"
79
- prerelease: false
80
78
  requirement: *id004
79
+ name: rcov
80
+ type: :development
81
81
  - !ruby/object:Gem::Dependency
82
- type: :runtime
83
- name: mutter
82
+ prerelease: false
84
83
  version_requirements: &id005 !ruby/object:Gem::Requirement
85
84
  none: false
86
85
  requirements:
@@ -90,11 +89,11 @@ dependencies:
90
89
  segments:
91
90
  - 0
92
91
  version: "0"
93
- prerelease: false
94
92
  requirement: *id005
95
- - !ruby/object:Gem::Dependency
93
+ name: mutter
96
94
  type: :runtime
97
- name: keystorage
95
+ - !ruby/object:Gem::Dependency
96
+ prerelease: false
98
97
  version_requirements: &id006 !ruby/object:Gem::Requirement
99
98
  none: false
100
99
  requirements:
@@ -105,11 +104,11 @@ dependencies:
105
104
  - 0
106
105
  - 1
107
106
  version: "0.1"
108
- prerelease: false
109
107
  requirement: *id006
110
- - !ruby/object:Gem::Dependency
108
+ name: keystorage
111
109
  type: :runtime
112
- name: mechanize
110
+ - !ruby/object:Gem::Dependency
111
+ prerelease: false
113
112
  version_requirements: &id007 !ruby/object:Gem::Requirement
114
113
  none: false
115
114
  requirements:
@@ -121,11 +120,11 @@ dependencies:
121
120
  - 0
122
121
  - 0
123
122
  version: 1.0.0
124
- prerelease: false
125
123
  requirement: *id007
126
- - !ruby/object:Gem::Dependency
124
+ name: mechanize
127
125
  type: :runtime
128
- name: highline
126
+ - !ruby/object:Gem::Dependency
127
+ prerelease: false
129
128
  version_requirements: &id008 !ruby/object:Gem::Requirement
130
129
  none: false
131
130
  requirements:
@@ -136,8 +135,9 @@ dependencies:
136
135
  - 1
137
136
  - 6
138
137
  version: "1.6"
139
- prerelease: false
140
138
  requirement: *id008
139
+ name: highline
140
+ type: :runtime
141
141
  description: This is a scraper of Bookscan (http://www.bookscan.co.jp) Service.This is *NOT* a official software of Bookscan.
142
142
  email: y.takahara@gmail.com
143
143
  executables:
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  requirements: []
196
196
 
197
197
  rubyforge_project:
198
- rubygems_version: 1.4.2
198
+ rubygems_version: 1.3.7
199
199
  signing_key:
200
200
  specification_version: 3
201
201
  summary: BookScan Scraper