Class: Sign::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/sign/fetcher.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_list(list) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/sign/fetcher.rb', line 4

def self.get_list(list)
  Dir["#{$LOAD_PATH[2]}/licenses/*.txt"].select do |file|
    if File.file?(file)
      name = File.basename(file, ".txt")
      info = File.open(file){ |file| file.readline }.downcase.strip.gsub(/[^-a-z0-9\s]/, "")
      list[name] = info unless list.has_key?(name)
    end
  end
end

Instance Method Details

#get_license(license) ⇒ Object



14
15
16
17
# File 'lib/sign/fetcher.rb', line 14

def get_license(license)      
  file_name = "#{license}.txt"
  File.open("#{license_path}/#{file_name}")
end

#license_pathObject



19
20
21
# File 'lib/sign/fetcher.rb', line 19

def license_path
  File.expand_path("#{$LOAD_PATH[2]}/licenses", __dir__)
end