Class: Cyrun::SpecCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/cyrun/spec_collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_directory, npm_task_name, patterns) ⇒ SpecCollector

Returns a new instance of SpecCollector.



7
8
9
10
11
# File 'lib/cyrun/spec_collector.rb', line 7

def initialize(base_directory, npm_task_name, patterns)
  @patterns = patterns
  @npm_task_name = npm_task_name
  @base_directory = base_directory
end

Instance Attribute Details

#base_directoryObject (readonly)

Returns the value of attribute base_directory.



5
6
7
# File 'lib/cyrun/spec_collector.rb', line 5

def base_directory
  @base_directory
end

#npm_task_nameObject (readonly)

Returns the value of attribute npm_task_name.



5
6
7
# File 'lib/cyrun/spec_collector.rb', line 5

def npm_task_name
  @npm_task_name
end

#patternsObject (readonly)

Returns the value of attribute patterns.



5
6
7
# File 'lib/cyrun/spec_collector.rb', line 5

def patterns
  @patterns
end

Instance Method Details

#create_task(filename) ⇒ Object



20
21
22
# File 'lib/cyrun/spec_collector.rb', line 20

def create_task(filename)
  SpecTask.new(filename, @npm_task_name)
end

#filesObject



13
14
15
16
17
18
# File 'lib/cyrun/spec_collector.rb', line 13

def files
  @files ||= patterns
             .map { |pattern| Dir.glob(pattern, base: base_directory) }
             .flatten
             .map { |filename| File.expand_path(filename, base_directory) }
end