Module: Omniboard
- Defined in:
- lib/omniboard.rb,
lib/omniboard/omniboard.rb
Defined Under Namespace
Modules: Property Classes: Colour, Column, Group, ProjectWrapper, Renderer, StyledText, StyledTextElement
Class Attribute Summary collapse
-
.document ⇒ Object
writeonly
Arbitrarily assign a document object.
Class Method Summary collapse
-
.columns ⇒ Object
Fetch all columns!.
-
.columns_location ⇒ Object
This is where we store columns.
-
.config_exists? ⇒ Boolean
Does the config folder exist?.
-
.config_location ⇒ Object
Retrieve configuration_location.
-
.config_location=(loc) ⇒ Object
Set location where we’ll store the configuration files.
-
.configuration(key) ⇒ Object
Retrieve a configuration variable.
-
.configuration=(hsh) ⇒ Object
Set configuration variables from a dictionary.
-
.configure(key, val) ⇒ Object
Set individual configuration variable.
-
.create_document ⇒ Object
Create a new document.
- .current_id ⇒ Object
-
.custom_css ⇒ Object
Fetches any custom CSS stored in ‘custom.css` inside the config folder.
-
.default_config_location ⇒ Object
Database usually exists here.
-
.document_at_head? ⇒ Boolean
————————————— Methods for reaching head.
- .document_can_reach_head? ⇒ Boolean
-
.document_exists? ⇒ Boolean
Do we already have a serialised document?.
-
.document_location ⇒ Object
This is where our serialised document is located.
- .head_id ⇒ Object
-
.load_document ⇒ Object
Load document from file.
-
.populate ⇒ Object
Populate with base classes.
-
.projects ⇒ Object
————————————— Project-centric methods.
-
.save_document ⇒ Object
Save document to file.
-
.update_document ⇒ Object
Update from an existing rubyfocus document.
Class Attribute Details
.document=(value) ⇒ Object (writeonly)
Arbitrarily assign a document object. Normally used only in debugging
115 116 117 |
# File 'lib/omniboard/omniboard.rb', line 115 def document=(value) @document = value end |
Class Method Details
.columns ⇒ Object
Fetch all columns!
66 67 68 69 70 71 |
# 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 ⇒ Object
This is where we store columns
61 62 63 |
# File 'lib/omniboard/omniboard.rb', line 61 def columns_location File.join(config_location, "columns") end |
.config_exists? ⇒ Boolean
Does the config folder exist?
39 40 41 |
# File 'lib/omniboard/omniboard.rb', line 39 def config_exists? File.exists?(config_location) end |
.config_location ⇒ Object
Retrieve configuration_location
29 30 31 |
# File 'lib/omniboard/omniboard.rb', line 29 def config_location @configuration[:config_location] || default_config_location end |
.config_location=(loc) ⇒ Object
Set location where we’ll store the configuration files
24 25 26 |
# File 'lib/omniboard/omniboard.rb', line 24 def config_location= loc self.configure(:config_location, loc) end |
.configuration(key) ⇒ Object
Retrieve a configuration variable
6 7 8 |
# File 'lib/omniboard/omniboard.rb', line 6 def configuration(key) @configuration[key] end |
.configuration=(hsh) ⇒ Object
Set configuration variables from a dictionary
11 12 13 |
# File 'lib/omniboard/omniboard.rb', line 11 def configuration=(hsh) @configuration = @configuration.merge(hsh) end |
.configure(key, val) ⇒ Object
Set individual configuration variable
16 17 18 |
# File 'lib/omniboard/omniboard.rb', line 16 def configure(key,val) @configuration[key] = val end |
.create_document ⇒ Object
Create a new document. For now, local documents are the only sort supported
110 111 112 |
# File 'lib/omniboard/omniboard.rb', line 110 def create_document @document = Rubyfocus::Document.new(Rubyfocus::LocalFetcher.new) end |
.current_id ⇒ Object
132 |
# File 'lib/omniboard/omniboard.rb', line 132 def current_id; @document.patch_id; end |
.custom_css ⇒ Object
Fetches any custom CSS stored in ‘custom.css` inside the config folder
139 140 141 142 143 144 145 146 |
# 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 ⇒ Object
Database usually exists here
34 35 36 |
# File 'lib/omniboard/omniboard.rb', line 34 def default_config_location @default_config_location ||= File.join(ENV["HOME"], ".omniboard") end |
.document_at_head? ⇒ Boolean
Methods for reaching head
119 120 121 122 123 124 125 |
# 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? ⇒ Boolean
127 128 129 130 |
# 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? ⇒ Boolean
Do we already have a serialised document?
89 90 91 |
# File 'lib/omniboard/omniboard.rb', line 89 def document_exists? File.exists?(document_location) end |
.document_location ⇒ Object
This is where our serialised document is located
84 85 86 |
# File 'lib/omniboard/omniboard.rb', line 84 def document_location File.join(config_location, "db.yaml") end |
.head_id ⇒ Object
133 |
# File 'lib/omniboard/omniboard.rb', line 133 def head_id; @document.fetcher.head; end |
.load_document ⇒ Object
Load document from file
94 95 96 |
# File 'lib/omniboard/omniboard.rb', line 94 def load_document @document = YAML::load_file(document_location) end |
.populate ⇒ Object
Populate with base classes
44 45 46 47 48 49 50 51 52 53 54 55 |
# 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 ⇒ Object
Project-centric methods
76 77 78 |
# File 'lib/omniboard/omniboard.rb', line 76 def projects @document.projects end |
.save_document ⇒ Object
Save document to file
99 100 101 102 |
# 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 ⇒ Object
Update from an existing rubyfocus document
105 106 107 |
# File 'lib/omniboard/omniboard.rb', line 105 def update_document @document.update end |