class PF::Profile
Attributes
box[RW]
qiniu[RW]
Public Class Methods
box()
click to toggle source
# File lib/pf/profile/profile.rb, line 49 def self.box p = profile if p.box.nil? p.box = BoxProfile.new(p) end p.save p.box end
create_profile_if_not_exist()
click to toggle source
# File lib/pf/profile/profile.rb, line 24 def self.create_profile_if_not_exist path = profile_path require 'fileutils' unless File.directory?(File.dirname(path)) FileUtils.mkdir_p(File.dirname(path)) end unless File.exist?(path) Profile.new.save end end
new()
click to toggle source
# File lib/pf/profile/profile.rb, line 8 def initialize @qiniu = QiniuProfile.new(self) @box = BoxProfile.new(self) end
profile()
click to toggle source
# File lib/pf/profile/profile.rb, line 39 def self.profile create_profile_if_not_exist file = profile_path YAML.load_file(file) end
profile_file_for_write()
click to toggle source
# File lib/pf/profile/profile.rb, line 35 def self.profile_file_for_write File.open(profile_path, "w+") end
profile_path()
click to toggle source
# File lib/pf/profile/profile.rb, line 19 def self.profile_path pf_home = File.join(Dir.home(), '.pf') File.join(pf_home, "profile.yaml") end
qiniu()
click to toggle source
# File lib/pf/profile/profile.rb, line 45 def self.qiniu profile.qiniu end
Public Instance Methods
save()
click to toggle source
# File lib/pf/profile/profile.rb, line 13 def save file = self.class.profile_file_for_write file.write(to_yaml) file.close end