Class: Geminabox::Proxy::Splicer
Instance Attribute Summary
Attributes inherited from FileHandler
#file_name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from FileHandler
#file_exists?, #initialize, #local_content, #local_file_exists?, #local_path, #proxy_file_exists?, #proxy_folder_name, #proxy_folder_path, #proxy_path, #remote_content, #remote_url, #root_path
Class Method Details
.make(file_name) ⇒ Object
11
12
13
14
15
|
# File 'lib/geminabox/proxy/splicer.rb', line 11
def self.make(file_name)
splicer = new(file_name)
splicer.create
splicer
end
|
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/geminabox/proxy/splicer.rb', line 17
def create
if data = new_content
f = Tempfile.create('geminabox')
f.binmode
begin
f.write(data)
ensure
f.close rescue nil
end
FileUtils.mv f.path, splice_path
end
end
|
#gzip? ⇒ Boolean
58
59
60
|
# File 'lib/geminabox/proxy/splicer.rb', line 58
def gzip?
/\.gz$/ =~ file_name
end
|
#merge_content ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/geminabox/proxy/splicer.rb', line 50
def merge_content
if gzip?
merge_gziped_content
else
merge_text_content
end
end
|
#new_content ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/geminabox/proxy/splicer.rb', line 30
def new_content
if local_file_exists?
merge_content
else
remote_content
end
end
|
#splice_file_exists? ⇒ Boolean
46
47
48
|
# File 'lib/geminabox/proxy/splicer.rb', line 46
def splice_file_exists?
file_exists? splice_path
end
|
#splice_folder_path ⇒ Object
42
43
44
|
# File 'lib/geminabox/proxy/splicer.rb', line 42
def splice_folder_path
proxy_folder_path
end
|
#splice_path ⇒ Object
38
39
40
|
# File 'lib/geminabox/proxy/splicer.rb', line 38
def splice_path
proxy_path
end
|