module Omniboard
Attributes
document[W]
Arbitrarily assign a document object. Normally used only in debugging
Public Class Methods
columns()
click to toggle source
Fetch all columns!
# File lib/omniboard/omniboard.rb, line 66 def columns @columns ||= begin Dir[File.join(columns_location, "*.rb")].each{ |f| require(f) } if File.exists?(columns_location) Omniboard::Column.columns end end
columns_location()
click to toggle source
This is where we store columns
# File lib/omniboard/omniboard.rb, line 61 def columns_location File.join(config_location, "columns") end
config_exists?()
click to toggle source
Does the config folder exist?
# File lib/omniboard/omniboard.rb, line 39 def config_exists? File.exists?(config_location) end
config_location()
click to toggle source
Retrieve configuration_location
# File lib/omniboard/omniboard.rb, line 29 def config_location @configuration[:config_location] || default_config_location end
config_location=(loc)
click to toggle source
Set location where we'll store the configuration files
# File lib/omniboard/omniboard.rb, line 24 def config_location= loc self.configure(:config_location, loc) end
configuration(key)
click to toggle source
Retrieve a configuration variable
# File lib/omniboard/omniboard.rb, line 6 def configuration(key) @configuration[key] end
configuration=(hsh)
click to toggle source
Set configuration variables from a dictionary
# File lib/omniboard/omniboard.rb, line 11 def configuration=(hsh) @configuration = @configuration.merge(hsh) end
configure(key,val)
click to toggle source
Set individual configuration variable
# File lib/omniboard/omniboard.rb, line 16 def configure(key,val) @configuration[key] = val end
create_document()
click to toggle source
Create a new document. For now, local documents are the only sort supported
# File lib/omniboard/omniboard.rb, line 110 def create_document @document = Rubyfocus::Document.new(Rubyfocus::LocalFetcher.new) end
current_id()
click to toggle source
# File lib/omniboard/omniboard.rb, line 132 def current_id; @document.patch_id; end
custom_css()
click to toggle source
Fetches any custom CSS stored in `custom.css` inside the config folder
# File lib/omniboard/omniboard.rb, line 139 def custom_css custom_css_path = File.join(config_location, "custom.css") if File.exists?(custom_css_path) File.read(custom_css_path) else nil end end
default_config_location()
click to toggle source
Database usually exists here
# File lib/omniboard/omniboard.rb, line 34 def default_config_location @default_config_location ||= File.join(ENV["HOME"], ".omniboard") end
document_at_head?()
click to toggle source
# File lib/omniboard/omniboard.rb, line 119 def document_at_head? raise(RuntimeError, "Called Omniboard.document_at_head? before document loaded") if @document.nil? return ( @document.fetcher.nil? || # Always at head if we have no fetcher @document.fetcher.head == @document.patch_id ) end
document_can_reach_head?()
click to toggle source
# File lib/omniboard/omniboard.rb, line 127 def document_can_reach_head? raise(RuntimeError, "Called Omniboard.document_can_reach_head? before document loaded") if @document.nil? return @document.fetcher.can_reach_head_from?(@document.patch_id) end
document_exists?()
click to toggle source
Do we already have a serialised document?
# File lib/omniboard/omniboard.rb, line 89 def document_exists? File.exists?(document_location) end
document_location()
click to toggle source
This is where our serialised document is located
# File lib/omniboard/omniboard.rb, line 84 def document_location File.join(config_location, "db.yaml") end
head_id()
click to toggle source
# File lib/omniboard/omniboard.rb, line 133 def head_id; @document.fetcher.head; end
load_document()
click to toggle source
Load document from file
# File lib/omniboard/omniboard.rb, line 94 def load_document @document = YAML::load_file(document_location) end
populate()
click to toggle source
Populate with base classes
# File lib/omniboard/omniboard.rb, line 44 def populate # 1. Make the columns folder FileUtils::mkdir_p columns_location # 2. Drop base columns + config into columns folder Dir[File.join(__dir__, "columns/*.rb")].each{ |f| FileUtils::cp f, columns_location } # 3. Add blank "custom.css" file custom_css = File.join(config_location, "custom.css") File.open(custom_css,"w"){ |io| io.puts "/* Custom CSS goes here */" } end
projects()
click to toggle source
# File lib/omniboard/omniboard.rb, line 76 def projects @document.projects end
save_document()
click to toggle source
Save document to file
# File lib/omniboard/omniboard.rb, line 99 def save_document FileUtils::mkdir_p config_location unless File.exists?(config_location) File.open(document_location, "w"){ |io| io.puts YAML.dump(@document) } end
update_document()
click to toggle source
Update from an existing rubyfocus document
# File lib/omniboard/omniboard.rb, line 105 def update_document @document.update end