Class: Rypper::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/rypper/loader.rb

Class Method Summary collapse

Class Method Details

.get(uri) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rypper/loader.rb', line 16

def self.get(uri)
  unless uri.kind_of?(URI)
    uri = ::URI.parse(uri.to_s)
  end
  client = Net::HTTPClient.from_storage(uri.host)
  response = client.get(uri)
  if response.code.to_i == 200
    response.body
  else
    response.code.to_i
  end
end

.mkdir!(path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/rypper/loader.rb', line 5

def self.mkdir!(path)
  path = path.to_s
  parts = []
  path.split(File::Separator).each do |part|
    parts << part
    sub_path = File.join(*parts)
    Dir.mkdir(sub_path) unless File.directory?(sub_path)
  end
  File.directory?(path)
end