rcv 0.0.1 → 0.0.2
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/Manifest.txt +0 -17
- data/bin/rcv +9 -9
- data/lib/rcv.rb +1 -1
- data/lib/rcv/reader.rb +135 -195
- metadata +1 -20
- data/PostInstall.txt +0 -7
- data/config/hoe.rb +0 -73
- data/config/requirements.rb +0 -15
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/manifest.rb +0 -21
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -11
- data/website/index.txt +0 -83
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -48
data/Manifest.txt
CHANGED
@@ -1,29 +1,12 @@
|
|
1
1
|
History.txt
|
2
2
|
License.txt
|
3
3
|
Manifest.txt
|
4
|
-
PostInstall.txt
|
5
4
|
README.txt
|
6
5
|
Rakefile
|
7
6
|
bin/rcv
|
8
|
-
config/hoe.rb
|
9
|
-
config/requirements.rb
|
10
7
|
lib/rcv.rb
|
11
8
|
lib/rcv/config.rb
|
12
9
|
lib/rcv/reader.rb
|
13
10
|
lib/rcv/version.rb
|
14
|
-
script/console
|
15
|
-
script/destroy
|
16
|
-
script/generate
|
17
|
-
script/manifest.rb
|
18
|
-
script/txt2html
|
19
|
-
setup.rb
|
20
|
-
tasks/deployment.rake
|
21
|
-
tasks/environment.rake
|
22
|
-
tasks/website.rake
|
23
11
|
test/test_helper.rb
|
24
12
|
test/test_rcv.rb
|
25
|
-
website/index.html
|
26
|
-
website/index.txt
|
27
|
-
website/javascripts/rounded_corners_lite.inc.js
|
28
|
-
website/stylesheets/screen.css
|
29
|
-
website/template.html.erb
|
data/bin/rcv
CHANGED
@@ -33,9 +33,9 @@ module RCV
|
|
33
33
|
def read(file)
|
34
34
|
@filename = file
|
35
35
|
if file
|
36
|
-
@reader = RCV::
|
36
|
+
@reader = RCV::Reader.new(file)
|
37
37
|
@reader.read
|
38
|
-
print @reader.
|
38
|
+
print @reader.next_image
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -59,11 +59,11 @@ module RCV
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def on_press_right
|
62
|
-
print @reader.
|
62
|
+
print @reader.next_image if @reader
|
63
63
|
end
|
64
64
|
|
65
65
|
def on_press_left
|
66
|
-
print @reader.
|
66
|
+
print @reader.prev_image if @reader
|
67
67
|
end
|
68
68
|
|
69
69
|
def on_press_o
|
@@ -87,8 +87,8 @@ module RCV
|
|
87
87
|
def on_press_b
|
88
88
|
state = RCV::Config.bookmark @filename if @filename
|
89
89
|
if state && @reader
|
90
|
-
@reader.
|
91
|
-
print @reader.
|
90
|
+
@reader.state = state
|
91
|
+
print @reader.current_image
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -102,9 +102,9 @@ module RCV
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
def print
|
106
|
-
if
|
107
|
-
get_pixbuf
|
105
|
+
def print temp
|
106
|
+
if temp
|
107
|
+
get_pixbuf temp
|
108
108
|
@drawing_area.signal_emit("expose_event", nil)
|
109
109
|
end
|
110
110
|
end
|
data/lib/rcv.rb
CHANGED
data/lib/rcv/reader.rb
CHANGED
@@ -5,247 +5,187 @@ zip archive reader
|
|
5
5
|
require "rubygems"
|
6
6
|
require "zip/zip"
|
7
7
|
require "tempfile"
|
8
|
-
require "fileutils"
|
9
8
|
require "kconv"
|
10
|
-
require "thread"
|
11
9
|
require "logger"
|
12
10
|
require "singleton"
|
13
11
|
|
14
12
|
module RCV
|
15
|
-
class
|
13
|
+
class Reader
|
16
14
|
def initialize(file)
|
17
|
-
@
|
18
|
-
@zis = Zip::ZipInputStream.new(file)
|
19
|
-
@entries = []
|
20
|
-
@index = 0
|
15
|
+
@file = file
|
21
16
|
end
|
22
17
|
|
18
|
+
# todo : other archive
|
23
19
|
def read
|
24
|
-
|
25
|
-
|
26
|
-
when /\.zip$/i
|
27
|
-
@entries << ZipEntry.new(entry)
|
28
|
-
when /\.(jpg|jpeg|png)$/i
|
29
|
-
@entries << ImageEntry.new(entry)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
@entries = @entries.sort_by { |e| e.name }
|
20
|
+
@archive = Archive::ZipFileEntry.new(nil, @file)
|
21
|
+
@archive.read
|
33
22
|
end
|
34
23
|
|
35
|
-
def
|
36
|
-
@
|
37
|
-
@zis.close
|
24
|
+
def next_image
|
25
|
+
@archive.next_image
|
38
26
|
end
|
39
27
|
|
40
|
-
def
|
41
|
-
|
42
|
-
unless entry
|
43
|
-
@index -= 1
|
44
|
-
entry = current
|
45
|
-
end
|
46
|
-
if entry.last?
|
47
|
-
entry.close
|
48
|
-
@index += 1
|
49
|
-
entry = current
|
50
|
-
end
|
51
|
-
return unless entry
|
52
|
-
entry.get_next
|
28
|
+
def prev_image
|
29
|
+
@archive.prev_image
|
53
30
|
end
|
54
31
|
|
55
|
-
def
|
56
|
-
|
57
|
-
unless entry
|
58
|
-
@index -= 1
|
59
|
-
entry = current
|
60
|
-
end
|
61
|
-
if @index == 0
|
62
|
-
return if entry.top?
|
63
|
-
end
|
64
|
-
if entry.top?
|
65
|
-
entry.close
|
66
|
-
@index -= 1
|
67
|
-
entry = current
|
68
|
-
end
|
69
|
-
return unless entry
|
70
|
-
entry.get_prev
|
32
|
+
def current_image
|
33
|
+
@archive.current_image
|
71
34
|
end
|
72
35
|
|
73
36
|
def state
|
74
|
-
|
75
|
-
@logger.debug "Get state : #{state.join(",")}"
|
76
|
-
state
|
77
|
-
end
|
78
|
-
|
79
|
-
def load(state)
|
80
|
-
@logger.debug "Set state : #{state.join(",")}"
|
81
|
-
@index = state.shift
|
82
|
-
current.load state
|
37
|
+
@archive.state.flatten
|
83
38
|
end
|
84
39
|
|
85
|
-
def
|
86
|
-
@
|
40
|
+
def state=(state)
|
41
|
+
@archive.state = state
|
87
42
|
end
|
88
43
|
end
|
89
44
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
45
|
+
module Archive
|
46
|
+
class ZipImageEntry
|
47
|
+
def initialize(entry)
|
48
|
+
super()
|
49
|
+
@entry = entry
|
50
|
+
@name = entry.name.toutf8
|
51
|
+
@logger = Logger.new(STDOUT)
|
52
|
+
@logger.level = Logger::ERROR
|
53
|
+
@readend = false
|
54
|
+
@index = 0
|
55
|
+
end
|
102
56
|
|
103
|
-
|
104
|
-
end
|
57
|
+
attr_reader :name, :readend, :index
|
105
58
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
59
|
+
def read; end
|
60
|
+
def next_image; current; end
|
61
|
+
def prev_image; current; end
|
62
|
+
def state; @index; end
|
63
|
+
def state=(state); end
|
112
64
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
@temp.
|
121
|
-
end
|
122
|
-
@entries[@index].close if @entries[@index]
|
123
|
-
@index += 1
|
124
|
-
@entries[@index].get_next
|
125
|
-
end
|
126
|
-
|
127
|
-
def get_prev
|
128
|
-
unless @zis
|
129
|
-
create_temp
|
130
|
-
end
|
131
|
-
if @temp.closed?
|
132
|
-
@index = @entries.size
|
133
|
-
@temp.open
|
65
|
+
def current
|
66
|
+
@readend = true
|
67
|
+
@logger.debug "load : #{@name}"
|
68
|
+
@temp = Tempfile.new("rcv")
|
69
|
+
@temp.binmode
|
70
|
+
@temp.write @entry.get_input_stream.read
|
71
|
+
@temp.flush
|
72
|
+
@temp.path
|
134
73
|
end
|
135
|
-
@entries[@index].close if @entries[@index]
|
136
|
-
@index -= 1
|
137
|
-
@entries[@index].get_prev
|
138
|
-
end
|
139
74
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
@temp.write @entry.get_input_stream.read
|
145
|
-
@temp.flush
|
146
|
-
@logger.debug "Create temp : #{@name} to #{@temp.path}"
|
147
|
-
@zis = Zip::ZipInputStream.new(@temp.path)
|
148
|
-
while entry = @zis.get_next_entry
|
149
|
-
@entries << ImageEntry.new(entry) if entry.name =~ /\.(jpg|jpeg|png)$/i
|
75
|
+
def close
|
76
|
+
@readend = false
|
77
|
+
@logger.debug "close : #{@name}"
|
78
|
+
@temp.close(true) if @temp
|
150
79
|
end
|
151
|
-
@entries = @entries.sort_by { |e| e.name }
|
152
80
|
end
|
153
81
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
# @temp.close(true)
|
160
|
-
end
|
161
|
-
|
162
|
-
def last?
|
163
|
-
create_temp unless @zis
|
164
|
-
@index + 1 >= @entries.size
|
165
|
-
end
|
82
|
+
class ZipFileEntry
|
83
|
+
PATTERN = {
|
84
|
+
/\.zip$/i => ZipFileEntry,
|
85
|
+
/\.(jpg|jpeg|png)$/i => ZipImageEntry
|
86
|
+
}
|
166
87
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
def load(state)
|
176
|
-
@index = state.shift
|
177
|
-
current.load state
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
class ImageEntry < Entry
|
182
|
-
def initialize(entry)
|
183
|
-
super
|
184
|
-
end
|
185
|
-
|
186
|
-
def get_next
|
187
|
-
current
|
188
|
-
end
|
189
|
-
|
190
|
-
def get_prev
|
191
|
-
current
|
192
|
-
end
|
88
|
+
def initialize(entry = nil, file = nil)
|
89
|
+
super()
|
90
|
+
@zipfile = file
|
91
|
+
@entry = entry
|
92
|
+
@index = -1
|
93
|
+
@name = entry ? entry.name : nil
|
94
|
+
@readend = false
|
95
|
+
end
|
193
96
|
|
194
|
-
|
195
|
-
|
196
|
-
|
97
|
+
attr_reader :name, :readend, :index
|
98
|
+
|
99
|
+
def read
|
100
|
+
create_temp unless @zipfile
|
101
|
+
unless @entries
|
102
|
+
@entries = []
|
103
|
+
file = @zipfile || @tempfile
|
104
|
+
@zis = Zip::ZipInputStream.new(file)
|
105
|
+
while entry = @zis.get_next_entry
|
106
|
+
PATTERN.each do |k, v|
|
107
|
+
@entries << v.new(entry) if k =~ entry.name
|
108
|
+
end
|
109
|
+
end
|
110
|
+
@entries = @entries.sort_by { |e| e.name }
|
111
|
+
end
|
112
|
+
end
|
197
113
|
|
198
|
-
|
199
|
-
@temp
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
114
|
+
def create_temp
|
115
|
+
unless @temp
|
116
|
+
@temp = Tempfile.new("rcv")
|
117
|
+
@temp.binmode
|
118
|
+
@temp.write @entry.get_input_stream.read
|
119
|
+
@temp.flush
|
120
|
+
@tempfile = @temp.path
|
121
|
+
end
|
122
|
+
if @temp.closed?
|
123
|
+
@temp.open
|
124
|
+
end
|
204
125
|
end
|
205
|
-
|
206
|
-
|
126
|
+
|
127
|
+
def next_image
|
128
|
+
return get_next if @index < 0
|
129
|
+
return unless current
|
130
|
+
return get_next if current.readend
|
131
|
+
image = current.next_image
|
132
|
+
return get_next unless image
|
133
|
+
image
|
207
134
|
end
|
208
135
|
|
209
|
-
|
210
|
-
|
136
|
+
def prev_image
|
137
|
+
return get_prev unless current
|
138
|
+
return get_prev if current.readend
|
139
|
+
image = current.prev_image
|
140
|
+
return get_prev unless image
|
141
|
+
image
|
142
|
+
end
|
211
143
|
|
212
|
-
|
213
|
-
|
214
|
-
|
144
|
+
def get_next
|
145
|
+
if @index >= @entries.size - 1
|
146
|
+
return nil
|
147
|
+
end
|
148
|
+
current.close if @index > -1 && current
|
149
|
+
@index += 1
|
150
|
+
current.read if current
|
151
|
+
return current.next_image if current
|
152
|
+
end
|
215
153
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
154
|
+
def get_prev
|
155
|
+
if @index <= 0
|
156
|
+
return nil
|
157
|
+
end
|
158
|
+
current.close if current
|
159
|
+
@index -= 1
|
160
|
+
current.read if current
|
161
|
+
return current.prev_image if current
|
162
|
+
end
|
221
163
|
|
222
|
-
|
223
|
-
|
224
|
-
|
164
|
+
def state
|
165
|
+
[@index, current.state]
|
166
|
+
end
|
225
167
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
168
|
+
def state=(state)
|
169
|
+
@index = state.shift
|
170
|
+
current.state = state if state.size > 0
|
171
|
+
end
|
230
172
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
@logger = Logger.new(STDOUT)
|
235
|
-
@logger.level = Logger::ERROR
|
236
|
-
@m = Mutex.new
|
237
|
-
end
|
173
|
+
def current
|
174
|
+
@entries[@index]
|
175
|
+
end
|
238
176
|
|
239
|
-
|
240
|
-
|
241
|
-
@logger.debug str
|
177
|
+
def current_image
|
178
|
+
current.current
|
242
179
|
end
|
243
|
-
end
|
244
180
|
|
245
|
-
|
246
|
-
|
247
|
-
@
|
181
|
+
def close
|
182
|
+
@temp.close if @temp
|
183
|
+
@index = @entries.size - 1
|
248
184
|
end
|
249
185
|
end
|
186
|
+
|
187
|
+
# todo
|
188
|
+
class RarFileEntry; end
|
189
|
+
class RarImageEntry; end
|
250
190
|
end
|
251
191
|
end
|