Class: PeakFlowUtils::ErbInspector

Inherits:
Object
  • Object
show all
Defined in:
app/services/peak_flow_utils/erb_inspector.rb

Defined Under Namespace

Classes: FileInspector, TranslationInspector

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ ErbInspector

Returns a new instance of ErbInspector.



2
3
4
5
6
7
8
9
10
11
# File 'app/services/peak_flow_utils/erb_inspector.rb', line 2

def initialize(args = {})
  @args = args
  @args[:exts] ||= [".erb", ".haml", ".liquid", ".markerb", ".rb", ".rake", ".slim", "."] + PeakFlowUtils::ErbInspector::FileInspector::JS_FILE_EXTS

  if @args[:dirs]
    @dirs = @args[:dirs]
  else
    @dirs = PeakFlowUtils::ConfigurationService.current.paths_to_translate
  end
end

Instance Method Details

#file(root_path, file_path) ⇒ Object



22
23
24
25
26
27
# File 'app/services/peak_flow_utils/erb_inspector.rb', line 22

def file(root_path, file_path)
  PeakFlowUtils::ErbInspector::FileInspector.new(
    file_path: file_path,
    root_path: root_path
  )
end

#filesObject

Yields all relevant .erb- and .haml-files.



14
15
16
17
18
19
20
# File 'app/services/peak_flow_utils/erb_inspector.rb', line 14

def files
  Enumerator.new do |yielder|
    @dirs.each do |dir|
      scan_dir("", dir, yielder)
    end
  end
end