Class: LicenseAuto::Readme

Inherits:
Object
  • Object
show all
Defined in:
lib/license_auto/license/readme.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, content) ⇒ Readme

Returns a new instance of Readme.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/license_auto/license/readme.rb', line 16

def initialize(filename, content)
  @content = content.encode('UTF-8', :invalid => :replace, :undef => :replace)
  impl = formator(filename)
  @license_content =
      if impl.nil?
        LicenseAuto.info("Unknown readme format: #{filename}, returned full-text instead")
        @content
      else
         impl.cut_license(@content)
      end
end

Instance Attribute Details

#license_contentObject (readonly)

RDOC_EXT = /.rdoc$/ RDOC_PATTERN = //

RST_EXT = /.rst/ RST_PATTERN = //



14
15
16
# File 'lib/license_auto/license/readme.rb', line 14

def license_content
  @license_content
end

Instance Method Details

#extensionsObject



28
29
30
# File 'lib/license_auto/license/readme.rb', line 28

def extensions
  [Markdown, RDoc]
end

#formator(filename) ⇒ Object



32
33
34
35
36
# File 'lib/license_auto/license/readme.rb', line 32

def formator(filename)
  extensions.find { |format|
    format::FILE_EXTENSION.match(filename)
  }
end