Class: Diggit::Source
- Inherits:
-
Object
- Object
- Diggit::Source
- Defined in:
- lib/dgit/core.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
Returns the value of attribute entry.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #all_analyses ⇒ Object
- #clone ⇒ Object
- #cloned? ⇒ Boolean
- #error ⇒ Object
- #error=(error) ⇒ Object
- #error? ⇒ Boolean
- #folder ⇒ Object
- #id ⇒ Object
-
#initialize(url) ⇒ Source
constructor
A new instance of Source.
- #load_repository ⇒ Object
- #new? ⇒ Boolean
- #ongoing_analyses ⇒ Object
- #performed_analyses ⇒ Object
- #state ⇒ Object
- #state=(state) ⇒ Object
Constructor Details
#initialize(url) ⇒ Source
Returns a new instance of Source.
62 63 64 65 66 |
# File 'lib/dgit/core.rb', line 62 def initialize(url) @url = url @entry = Journal.new_source_entry @repository = nil end |
Instance Attribute Details
#entry ⇒ Object
Returns the value of attribute entry.
60 61 62 |
# File 'lib/dgit/core.rb', line 60 def entry @entry end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
59 60 61 |
# File 'lib/dgit/core.rb', line 59 def repository @repository end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
59 60 61 |
# File 'lib/dgit/core.rb', line 59 def url @url end |
Instance Method Details
#all_analyses ⇒ Object
104 105 106 |
# File 'lib/dgit/core.rb', line 104 def all_analyses performed_analyses + ongoing_analyses end |
#clone ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/dgit/core.rb', line 116 def clone if File.exist?(folder) Rugged::Repository.new(folder) else Rugged::Repository.clone_at(url, folder) end self.state = :cloned rescue => e Log.error "Error cloning #{url}." self.error = Journal.dump_error(e) end |
#cloned? ⇒ Boolean
100 101 102 |
# File 'lib/dgit/core.rb', line 100 def cloned? @entry[:state] == :cloned end |
#error ⇒ Object
80 81 82 |
# File 'lib/dgit/core.rb', line 80 def error @entry[:last_error] end |
#error=(error) ⇒ Object
84 85 86 |
# File 'lib/dgit/core.rb', line 84 def error=(error) @entry[:last_error] = error end |
#error? ⇒ Boolean
76 77 78 |
# File 'lib/dgit/core.rb', line 76 def error? !(@entry[:last_error].nil? || @entry[:last_error].empty?) end |
#folder ⇒ Object
72 73 74 |
# File 'lib/dgit/core.rb', line 72 def folder Dig.it.file_path("sources/#{id}") end |
#id ⇒ Object
68 69 70 |
# File 'lib/dgit/core.rb', line 68 def id @url.id end |
#load_repository ⇒ Object
128 129 130 131 |
# File 'lib/dgit/core.rb', line 128 def load_repository fail "Source not cloned #{url}." if new? @repository = Rugged::Repository.new(folder) end |
#new? ⇒ Boolean
96 97 98 |
# File 'lib/dgit/core.rb', line 96 def new? @entry[:state] == :new end |
#ongoing_analyses ⇒ Object
112 113 114 |
# File 'lib/dgit/core.rb', line 112 def ongoing_analyses @entry[:ongoing_analyses] end |
#performed_analyses ⇒ Object
108 109 110 |
# File 'lib/dgit/core.rb', line 108 def performed_analyses @entry[:performed_analyses] end |
#state ⇒ Object
88 89 90 |
# File 'lib/dgit/core.rb', line 88 def state @entry[:state] end |
#state=(state) ⇒ Object
92 93 94 |
# File 'lib/dgit/core.rb', line 92 def state=(state) @entry[:state] = state end |