Class: BaggerProfile

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

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ BaggerProfile

Returns a new instance of BaggerProfile


10
11
12
13
14
15
16
17
18
19
# File 'lib/bagger_profile.rb', line 10

def initialize(uri)
  uri = URI.parse(uri)
  profile = if uri.scheme == "file"
    File.read(uri.path)
  else
    uri.read
  end

  @tags = JSON.parse(profile)["ordered"].map {|t| BaggerTag.from_hash(t) }
end

Instance Method Details

#valid?(bag_info, errors: []) ⇒ Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/bagger_profile.rb', line 21

def valid?(bag_info, errors: [])
  tags.map {|tag| tag.value_valid?(bag_info[tag.name], errors: errors) }.all? {|valid| valid == true }
end