Class: Testament::Project
- Inherits:
-
Object
- Object
- Testament::Project
- Defined in:
- lib/testament/project.rb
Instance Attribute Summary collapse
-
#default_category ⇒ Object
readonly
Returns the value of attribute default_category.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(arguments) ⇒ Project
constructor
A new instance of Project.
- #log ⇒ Object
- #record(command_words) ⇒ Object
- #report(name) ⇒ Object
Constructor Details
#initialize(arguments) ⇒ Project
Returns a new instance of Project.
9 10 11 12 13 14 15 |
# File 'lib/testament/project.rb', line 9 def initialize(arguments) @database = Database.new arguments.fetch('database') @name = arguments.fetch('project') @user = arguments.fetch('user') @version = arguments.fetch('version') @default_category = arguments.fetch('default_category') end |
Instance Attribute Details
#default_category ⇒ Object (readonly)
Returns the value of attribute default_category.
7 8 9 |
# File 'lib/testament/project.rb', line 7 def default_category @default_category end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/testament/project.rb', line 7 def name @name end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/testament/project.rb', line 7 def user @user end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/testament/project.rb', line 7 def version @version end |
Class Method Details
.load ⇒ Object
48 49 50 51 52 |
# File 'lib/testament/project.rb', line 48 def self.load config_path = ".testament/config.yml" config = YAML.load(ERB.new(File.read(config_path)).result) new config end |
Instance Method Details
#log ⇒ Object
39 40 41 |
# File 'lib/testament/project.rb', line 39 def log database.db[:executions].order(:start_time).all end |
#record(command_words) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/testament/project.rb', line 17 def record(command_words) start_time = Time.now system *command_words end_time = Time.now elapsed_milliseconds = ((end_time - start_time) * 1000).round command = command_words.join(' ') memento = { project: name, command: command, start_time: start_time, elapsed_milliseconds: elapsed_milliseconds, exit_status: $?.exitstatus, user: user, version: version, category: default_category } database.record memento memento end |