Class: RspecGenerateDoc::GenerateFIle

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_generate_doc/generate_file.rb

Constant Summary collapse

TEMPLATE_EXTNAME =
'erb'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ GenerateFIle

Returns a new instance of GenerateFIle.



10
11
12
13
14
# File 'lib/rspec_generate_doc/generate_file.rb', line 10

def initialize(data = {})
  @actions = data[:actions]
  @parent = data[:parent]
  I18n.locale = configuration.locale
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



8
9
10
# File 'lib/rspec_generate_doc/generate_file.rb', line 8

def actions
  @actions
end

#parentObject (readonly)

Returns the value of attribute parent.



8
9
10
# File 'lib/rspec_generate_doc/generate_file.rb', line 8

def parent
  @parent
end

Class Method Details

.source_rootObject



16
17
18
# File 'lib/rspec_generate_doc/generate_file.rb', line 16

def self.source_root
  configuration.docs_dir
end

Instance Method Details

#create_file_by_templateObject



20
21
22
23
24
25
# File 'lib/rspec_generate_doc/generate_file.rb', line 20

def create_file_by_template
  file = File.open(file_path, 'w+')
  file.write ERB.new(File.binread(configuration.template_file), nil, '-').result(binding).to_s
                .force_encoding('utf-8')
  file.close
end