Class: Intent::Core::Projects
- Inherits:
-
Object
- Object
- Intent::Core::Projects
- Defined in:
- lib/intent/core/projects.rb
Instance Attribute Summary collapse
-
#ledger_path ⇒ Object
readonly
Returns the value of attribute ledger_path.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #add_directory!(path, project, id, computer) ⇒ Object
- #all ⇒ Object
- #all_tokens ⇒ Object
-
#initialize(db_path) ⇒ Projects
constructor
A new instance of Projects.
- #linked_directory(path) ⇒ Object
- #sync! ⇒ Object
Constructor Details
Instance Attribute Details
#ledger_path ⇒ Object (readonly)
Returns the value of attribute ledger_path.
5 6 7 |
# File 'lib/intent/core/projects.rb', line 5 def ledger_path @ledger_path end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
4 5 6 |
# File 'lib/intent/core/projects.rb', line 4 def list @list end |
Instance Method Details
#add_directory!(path, project, id, computer) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/intent/core/projects.rb', line 37 def add_directory!(path, project, id, computer) record = Record.new([ Date.today, path, project, "is:directory", "id:#{id}", "computer:#{computer}" ].join(' ')) @list.append(record) @list.save! end |
#all ⇒ Object
12 13 14 |
# File 'lib/intent/core/projects.rb', line 12 def all list.by_not_done end |
#all_tokens ⇒ Object
16 17 18 |
# File 'lib/intent/core/projects.rb', line 16 def all_tokens all.map { |item| item.projects.first }.uniq end |
#linked_directory(path) ⇒ Object
20 21 22 |
# File 'lib/intent/core/projects.rb', line 20 def linked_directory(path) all.find { |item| item.text == path && ['repository', 'directory'].include?(item.[:is]) } end |
#sync! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/intent/core/projects.rb', line 24 def sync! ledger_file = File.basename(ledger_path) if repo.status.changed?(ledger_file) repo.add(ledger_file) repo.commit("Synchronizing projects [#{Time.new}]") repo.push true # Result:OK else false # Result::NO_CHANGES end end |