Module: Qlive::Registry
- Defined in:
- lib/qlive/registry.rb
Defined Under Namespace
Classes: Registration
Class Method Summary collapse
- .all_by_name ⇒ Object
- .build_suite(suite_name) ⇒ Object
- .find_suites ⇒ Object
- .register_class(klass) ⇒ Object
- .reset_all ⇒ Object
Class Method Details
.all_by_name ⇒ Object
71 72 73 |
# File 'lib/qlive/registry.rb', line 71 def self.all_by_name $qlive_registrations_by_name end |
.build_suite(suite_name) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/qlive/registry.rb', line 40 def self.build_suite(suite_name) suite_name = URI.unescape(suite_name) registration = Registry.all_by_name[suite_name] unless registration || Qlive.setup[:skip_suite_reloader] Registry.find_suites registration = Registry.all_by_name[suite_name] end raise "Qlive Suite not found: #{suite_name}" unless registration load registration.path klass = registration.klass raise "Qlive could not find class for suite: #{suite_name}" unless klass klass.new end |
.find_suites ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/qlive/registry.rb', line 24 def self.find_suites base_path = Qlive.setup[:base_path] Dir.glob("#{base_path}#{base_path.end_with?('/') ? '' : '/'}**/*qlive.rb").sort.flatten.each do |path| name = self.extract_suite_name_from_path(path) unless all_by_name[name] all_by_name[name] = Registration.new( :name => name, :path => path) @qlive_current_suite_name = name load(path.to_s) @qlive_current_suite_name = nil end end all_by_name end |
.register_class(klass) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/qlive/registry.rb', line 54 def self.register_class(klass) registration = $qlive_registrations_by_class[klass] registration ||= Registry.all_by_name[@qlive_current_suite_name] if registration registration.klass = klass $qlive_registrations_by_class[klass] = registration else Qlive.logger.warn "Ignoring Qlive class '#{klass}'. File must be placed within the Qlive base_path: #{Qlive.setup[:base_path]}. Or you can change the base_path with Qlive.setup[:base_path] = /some/other/path" end registration end |
.reset_all ⇒ Object
66 67 68 69 |
# File 'lib/qlive/registry.rb', line 66 def self.reset_all $qlive_registrations_by_name = {} $qlive_registrations_by_class = {} end |