lib/firebrew/firefox/profile.rb in firebrew-0.1.3 vs lib/firebrew/firefox/profile.rb in firebrew-0.2.0
- old
+ new
@@ -1,18 +1,18 @@
-require 'active_model'
require 'inifile'
+require 'firebrew/entity'
require 'firebrew/firefox/extension'
module Firebrew::Firefox
class Profile
- include ActiveModel::Model
+ include Firebrew::Entity
class Manager
def initialize(params={})
@base_dir = params[:base_dir]
@data_file = params[:data_file] || 'profiles.ini'
- raise Firebrew::ProfilesFileNotFoundError unless File.exists? self.data_path
+ raise Firebrew::ProfilesFileNotFoundError, %["profiles.ini" not found: #{self.data_path}] unless File.exists? self.data_path
end
def all
sections = IniFile.load(self.data_path).to_h
profiles = sections.find_all{|(name,prop)| name.match(/^Profile\d+$/)}
@@ -29,11 +29,11 @@
self.all.find{|p| p.name == name }
end
def find!(name)
result = self.find(name)
- raise Firebrew::ProfileNotFoundError if result.nil?
+ raise Firebrew::ProfileNotFoundError, "Profile not found: #{name}" if result.nil?
result
end
protected
@@ -45,10 +45,10 @@
path = is_relative ? File.join(@base_dir, path) : path
File.expand_path path
end
end
- attr_accessor :name, :path, :is_default
+ entity_attr :name, :path, :is_default
def extensions
Extension::Manager.new(profile: self)
end
end