Class: Geminabox::Proxy::Splicer

Inherits:
FileHandler show all
Defined in:
lib/geminabox/proxy/splicer.rb

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

Constructor Details

This class inherits a constructor from Geminabox::Proxy::FileHandler

Class Method Details

.make(file_name) ⇒ Object


6
7
8
9
10
# File 'lib/geminabox/proxy/splicer.rb', line 6

def self.make(file_name)
  splicer = new(file_name)
  splicer.create
  splicer
end

Instance Method Details

#createObject


12
13
14
# File 'lib/geminabox/proxy/splicer.rb', line 12

def create
  File.open(splice_path, 'w'){|f| f.write(new_content)}
end

#gzip?Boolean


44
45
46
# File 'lib/geminabox/proxy/splicer.rb', line 44

def gzip?
  /\.gz$/ =~ file_name
end

#merge_contentObject


36
37
38
39
40
41
42
# File 'lib/geminabox/proxy/splicer.rb', line 36

def merge_content
  if gzip?
    merge_gziped_content
  else
    merge_text_content
  end
end

#new_contentObject


16
17
18
19
20
21
22
# File 'lib/geminabox/proxy/splicer.rb', line 16

def new_content
  if local_file_exists?
    merge_content
  else
    remote_content
  end
end

#splice_file_exists?Boolean


32
33
34
# File 'lib/geminabox/proxy/splicer.rb', line 32

def splice_file_exists?
  file_exists? splice_path
end

#splice_folder_pathObject


28
29
30
# File 'lib/geminabox/proxy/splicer.rb', line 28

def splice_folder_path
  proxy_folder_path
end

#splice_pathObject


24
25
26
# File 'lib/geminabox/proxy/splicer.rb', line 24

def splice_path
  proxy_path
end