Class: MinimumTerm::Infrastructure
- Inherits:
-
Object
- Object
- MinimumTerm::Infrastructure
- Defined in:
- lib/minimum-term/infrastructure.rb
Instance Attribute Summary collapse
-
#data_dir ⇒ Object
readonly
Returns the value of attribute data_dir.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #consumers ⇒ Object
- #contracts_fulfilled? ⇒ Boolean
- #convert_all!(keep_intermediary_files = false) ⇒ Object
-
#initialize(data_dir:, verbose: false) ⇒ Infrastructure
constructor
A new instance of Infrastructure.
- #json_files ⇒ Object
- #mson_files ⇒ Object
- #publishers ⇒ Object
- #reload ⇒ Object
Constructor Details
#initialize(data_dir:, verbose: false) ⇒ Infrastructure
Returns a new instance of Infrastructure.
7 8 9 10 11 12 |
# File 'lib/minimum-term/infrastructure.rb', line 7 def initialize(data_dir:, verbose: false) @verbose = !!verbose @data_dir = data_dir @mutex = Mutex.new load_services end |
Instance Attribute Details
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
5 6 7 |
# File 'lib/minimum-term/infrastructure.rb', line 5 def data_dir @data_dir end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/minimum-term/infrastructure.rb', line 5 def errors @errors end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
5 6 7 |
# File 'lib/minimum-term/infrastructure.rb', line 5 def services @services end |
Instance Method Details
#consumers ⇒ Object
37 38 39 40 41 |
# File 'lib/minimum-term/infrastructure.rb', line 37 def consumers services.values.select do |service| service.consumed_objects.length > 0 end end |
#contracts_fulfilled? ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/minimum-term/infrastructure.rb', line 18 def contracts_fulfilled? load_services @mutex.synchronize do @errors = {} publishers.each do |publisher| publisher.satisfies_consumers?(verbose: @verbose) next if publisher.errors.empty? @errors.merge! publisher.errors end @errors.empty? end end |
#convert_all!(keep_intermediary_files = false) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/minimum-term/infrastructure.rb', line 43 def convert_all!(keep_intermediary_files = false) json_files.each{ |file| FileUtils.rm_f(file) } mson_files.each do |file| MinimumTerm::Conversion.mson_to_json_schema!( filename: file, keep_intermediary_files: keep_intermediary_files, verbose: @verbose) end reload end |
#json_files ⇒ Object
58 59 60 |
# File 'lib/minimum-term/infrastructure.rb', line 58 def json_files Dir.glob(File.join(@data_dir, "/**/*.schema.json")) end |
#mson_files ⇒ Object
54 55 56 |
# File 'lib/minimum-term/infrastructure.rb', line 54 def mson_files Dir.glob(File.join(@data_dir, "/**/*.mson")) end |
#publishers ⇒ Object
31 32 33 34 35 |
# File 'lib/minimum-term/infrastructure.rb', line 31 def publishers services.values.select do |service| service.published_objects.length > 0 end end |
#reload ⇒ Object
14 15 16 |
# File 'lib/minimum-term/infrastructure.rb', line 14 def reload load_services end |