Class: Bump::CLI::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/bump/cli/resource.rb

Class Method Summary collapse

Class Method Details

.parse(content) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/bump/cli/resource.rb', line 16

def self.parse(content)
  ::JSON.parse(content)
rescue ::JSON::ParserError
  begin
    ::YAML.safe_load(content, [Date, Time])
  rescue ::Psych::SyntaxError
    content
  end
end

.read(location) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/bump/cli/resource.rb', line 7

def self.read(location)
  if location.start_with?("http")
    ::HTTP.follow(max_hops: 50)
      .get(location).to_s
  else
    ::File.read(location).force_encoding(Encoding::UTF_8)
  end
end