Class: RightPublish::Profile

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/right_publish/profile.rb

Constant Summary collapse

USER_PROFILE_DIR =

Location where per-user profiles are stored

File.expand_path('~/.right_publish/profiles')
DEFAULT_VERBOSE =
false

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



10
11
12
# File 'lib/right_publish/profile.rb', line 10

def settings
  @settings
end

Class Method Details

.configObject



13
14
15
# File 'lib/right_publish/profile.rb', line 13

def self.config()
  return Profile.instance.settings
end

.log(s, level = :info) ⇒ Object



17
18
19
# File 'lib/right_publish/profile.rb', line 17

def self.log(s, level=:info)
  puts(s) if Profile.config[:verbose] || level != :debug
end

Instance Method Details

#load(path) ⇒ true

Load a YML profile from disk. Profiles can be identified by their path on disk, or by the name of a YML file located in USER_PROFILE_DIR (without YML extension).

Examples:

per-user profile

Profile.instance.load("gem")

profile on disk

Profile.instance.load("config/publish/nightly.yml")

Parameters:

  • path (String)

    absolute/relative path to file, or the name of per-user profile

Returns:

  • (true)

    always returns true

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/right_publish/profile.rb', line 34

def load(path)
  if File.exists?(path)
    @settings ||= Profile.symbolize_profile(YAML.load_file(path))
    validate_profile
  elsif (path = File.join(, "#{path}.yml")) && File.exists?(path)
    @settings ||= Profile.symbolize_profile(YAML.load_file(path))
    validate_profile
  else
    raise LoadError, "Missing profile '#{path}'"
  end

  true
rescue LoadError
  raise
rescue Exception => e
  raise LoadError, "Cannot load profile '#{path}' - #{e}"
end

#register_section(section_key, section_options) ⇒ Object



52
53
54
55
# File 'lib/right_publish/profile.rb', line 52

def register_section(section_key, section_options)
  @config_map ||= {}
  @config_map[section_key] ||= section_options
end