Class: MxxRu::TargetState
- Inherits:
-
Object
- Object
- MxxRu::TargetState
- Defined in:
- lib/mxx_ru/abstract_target.rb
Overview
Target status description.
Constant Summary collapse
- ABSENT =
Target is absent or rebuild is required.
0
- REBUILT =
Target was rebuilt.
1
- EXISTS =
Target exists and up-to-date.
2
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
-
.detect(name, depends) ⇒ Object
Detect target status.
Instance Method Summary collapse
-
#initialize(a_state = ABSENT) ⇒ TargetState
constructor
A new instance of TargetState.
Constructor Details
#initialize(a_state = ABSENT) ⇒ TargetState
Returns a new instance of TargetState.
49 50 51 |
# File 'lib/mxx_ru/abstract_target.rb', line 49 def initialize( a_state = ABSENT ) @state = a_state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
47 48 49 |
# File 'lib/mxx_ru/abstract_target.rb', line 47 def state @state end |
Class Method Details
.detect(name, depends) ⇒ Object
Detect target status. TargetState object returned.
- name
-
Target name.
- depends
-
Dependencies list. Array of String.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/mxx_ru/abstract_target.rb', line 58 def TargetState.detect( name, depends ) state = ABSENT # In dry-run mode we always return that target is absent. if !MxxRu::Util::Mode.instance.is_dry_run if FileTest.exists?( name ) # It's necessary to detect time of target and it's dependencies. target_mtime = File.mtime( name ) if nil != depends.find { |d| if !FileTest.exists?( d ) raise MxxRu::MissingDependFileEx.new( d, name ) end depend_mtime = File.mtime( d ) target_mtime < depend_mtime } # More young dependency found. state = REBUILT else # Target is up-to-date. state = EXISTS end end end return TargetState.new( state ) end |