Class: Rgit::Configuration
- Inherits:
-
Object
- Object
- Rgit::Configuration
- Defined in:
- lib/rgit/configuration.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Class Method Summary collapse
- .create(filename = File.join(Dir.home, '.rgit.yml')) ⇒ Object
- .exist?(filename = File.join(Dir.home, '.rgit.yml')) ⇒ Boolean
- .load(filename = File.join(Dir.home, '.rgit.yml')) ⇒ Object
Instance Method Summary collapse
- #add_root(path) ⇒ Object
- #find_root(path) ⇒ Object
- #remove_root(path) ⇒ Object
- #roots ⇒ Object
- #save ⇒ Object
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
6 7 8 |
# File 'lib/rgit/configuration.rb', line 6 def filename @filename end |
Class Method Details
.create(filename = File.join(Dir.home, '.rgit.yml')) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rgit/configuration.rb', line 12 def self.create(filename = File.join(Dir.home, '.rgit.yml')) FileUtils.touch(filename) config = Configuration.new(filename) config.save config end |
.exist?(filename = File.join(Dir.home, '.rgit.yml')) ⇒ Boolean
8 9 10 |
# File 'lib/rgit/configuration.rb', line 8 def self.exist?(filename = File.join(Dir.home, '.rgit.yml')) File.exist?(filename) end |
.load(filename = File.join(Dir.home, '.rgit.yml')) ⇒ Object
19 20 21 |
# File 'lib/rgit/configuration.rb', line 19 def self.load(filename = File.join(Dir.home, '.rgit.yml')) Configuration.new(filename) end |
Instance Method Details
#add_root(path) ⇒ Object
27 28 29 30 |
# File 'lib/rgit/configuration.rb', line 27 def add_root(path) raise '"/" path unsupported!' if path == '/' @roots << path unless @roots.include? path end |
#find_root(path) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/rgit/configuration.rb', line 45 def find_root(path) until @roots.include?(path) path = File.('..', path) raise 'Not in a root directory' if path == '/' end path end |
#remove_root(path) ⇒ Object
32 33 34 |
# File 'lib/rgit/configuration.rb', line 32 def remove_root(path) @roots.delete path end |
#roots ⇒ Object
23 24 25 |
# File 'lib/rgit/configuration.rb', line 23 def roots @roots end |
#save ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/rgit/configuration.rb', line 36 def save config = { 'roots' => @roots } File.open(@filename, 'w') do |f| f.write config.to_yaml end end |