Class: ScmCheckout
- Inherits:
-
Object
- Object
- ScmCheckout
- Includes:
- Helpers, Skylight::Helpers
- Defined in:
- lib/scm_checkout.rb,
lib/skylight_instrumentation.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#name ⇒ Object
Returns the value of attribute name.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #checkout ⇒ Object
- #clear_source_files ⇒ Object
- #error_file ⇒ Object
- #flush_cache ⇒ Object
-
#initialize(app, url, commit = nil) ⇒ ScmCheckout
constructor
A new instance of ScmCheckout.
- #is_primary_branch? ⇒ Boolean
- #primary_branch ⇒ Object
- #project_path ⇒ Object
- #register_project ⇒ Object
- #remove_project ⇒ Object
- #repository_path ⇒ Object
- #run_checkout ⇒ Object
- #unlink_error_file ⇒ Object
- #write_error_file(out) ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(app, url, commit = nil) ⇒ ScmCheckout
Returns a new instance of ScmCheckout.
16 17 18 19 20 21 |
# File 'lib/scm_checkout.rb', line 16 def initialize(app, url, commit = nil) self.settings = app.settings self.app = app self.url = url self.commit = commit end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
14 15 16 |
# File 'lib/scm_checkout.rb', line 14 def app @app end |
#commit ⇒ Object
Returns the value of attribute commit.
14 15 16 |
# File 'lib/scm_checkout.rb', line 14 def commit @commit end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/scm_checkout.rb', line 14 def name @name end |
#settings ⇒ Object
Returns the value of attribute settings.
14 15 16 |
# File 'lib/scm_checkout.rb', line 14 def settings @settings end |
#url ⇒ Object
Returns the value of attribute url.
14 15 16 |
# File 'lib/scm_checkout.rb', line 14 def url @url end |
Instance Method Details
#checkout ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/scm_checkout.rb', line 50 def checkout unlink_error_file if run_checkout && settings.scm_adapter.libraries[name] clear_source_files register_project flush_cache true else remove_project false end end |
#clear_source_files ⇒ Object
81 82 |
# File 'lib/scm_checkout.rb', line 81 def clear_source_files end |
#error_file ⇒ Object
67 68 69 70 71 |
# File 'lib/scm_checkout.rb', line 67 def error_file FileUtils.mkdir_p("#{settings.logdir}/errors") @error_file ||= "#{settings.logdir}/errors/#{[name.gsub('/', '_'), commit || 'unknown'].join('_')}.error.txt" end |
#flush_cache ⇒ Object
84 85 |
# File 'lib/scm_checkout.rb', line 84 def flush_cache end |
#is_primary_branch? ⇒ Boolean
46 47 48 |
# File 'lib/scm_checkout.rb', line 46 def is_primary_branch? commit == primary_branch end |
#primary_branch ⇒ Object
42 43 44 |
# File 'lib/scm_checkout.rb', line 42 def primary_branch raise NotImplementedError end |
#project_path ⇒ Object
38 39 40 |
# File 'lib/scm_checkout.rb', line 38 def project_path [name, commit].compact.join('/') end |
#register_project ⇒ Object
27 28 29 30 31 32 |
# File 'lib/scm_checkout.rb', line 27 def register_project puts "#{Time.now}: Registering project #{name}" unlink_error_file app.recent_store.push(settings.scm_adapter.libraries[name]) puts "#{Time.now}: Adding #{name} to recent projects list" end |
#remove_project ⇒ Object
87 88 |
# File 'lib/scm_checkout.rb', line 87 def remove_project end |
#repository_path ⇒ Object
34 35 36 |
# File 'lib/scm_checkout.rb', line 34 def repository_path File.join(settings.repos, name, commit) end |
#run_checkout ⇒ Object
63 64 65 |
# File 'lib/scm_checkout.rb', line 63 def run_checkout raise NotImplementedError end |
#unlink_error_file ⇒ Object
77 78 79 |
# File 'lib/scm_checkout.rb', line 77 def unlink_error_file File.unlink(error_file) if File.file?(error_file) end |
#write_error_file(out) ⇒ Object
73 74 75 |
# File 'lib/scm_checkout.rb', line 73 def write_error_file(out) File.open(error_file, "a") {|f| f.write(out + "\n") } end |