Class: Mighost::Capturer
- Inherits:
-
Object
- Object
- Mighost::Capturer
- Defined in:
- lib/mighost/capturer.rb
Instance Attribute Summary collapse
-
#migration_path ⇒ Object
readonly
Returns the value of attribute migration_path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #capture ⇒ Object
-
#initialize(version, migration_path) ⇒ Capturer
constructor
A new instance of Capturer.
Constructor Details
#initialize(version, migration_path) ⇒ Capturer
Returns a new instance of Capturer.
11 12 13 14 |
# File 'lib/mighost/capturer.rb', line 11 def initialize(version, migration_path) @version = version.to_s @migration_path = migration_path end |
Instance Attribute Details
#migration_path ⇒ Object (readonly)
Returns the value of attribute migration_path.
9 10 11 |
# File 'lib/mighost/capturer.rb', line 9 def migration_path @migration_path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
9 10 11 |
# File 'lib/mighost/capturer.rb', line 9 def version @version end |
Instance Method Details
#capture ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mighost/capturer.rb', line 16 def capture return unless Mighost.enabled? return unless Mighost.configuration.auto_capture return unless File.exist?(migration_path) content = File.read(migration_path) filename = File.basename(migration_path) attributes = { version: version, content: content, filename: filename } if Mighost.configuration. attributes[:branch_name] = GitMetadata.current_branch attributes[:git_sha] = GitMetadata.current_sha , = (migration_path) attributes[:author_name] = attributes[:author_email] = end Snapshot.store(**attributes) rescue => e # Don't break migrations if snapshot capture fails warn "[Mighost] Failed to capture snapshot for #{version}: #{e.}" end |