Class: FluentPluginGenerator::ApacheLicense

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/command/plugin_generator.rb

Constant Summary collapse

LICENSE_URL =
"http://www.apache.org/licenses/LICENSE-2.0.txt"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApacheLicense

Returns a new instance of ApacheLicense.



280
281
282
283
284
285
286
287
288
289
# File 'lib/fluent/command/plugin_generator.rb', line 280

def initialize
  @text = ""
  @preamble_source = ""
  @preamble = nil
  uri = URI.parse(LICENSE_URL)
  uri.open do |io|
    @text = io.read
  end
  @preamble_source = @text[/^(\s*Copyright.+)/m, 1]
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



278
279
280
# File 'lib/fluent/command/plugin_generator.rb', line 278

def text
  @text
end

Instance Method Details

#full_nameObject



295
296
297
# File 'lib/fluent/command/plugin_generator.rb', line 295

def full_name
  "Apache License, Version 2.0"
end

#nameObject



291
292
293
# File 'lib/fluent/command/plugin_generator.rb', line 291

def name
  "Apache-2.0"
end

#preamble(user_name) ⇒ Object



299
300
301
302
303
304
305
306
# File 'lib/fluent/command/plugin_generator.rb', line 299

def preamble(user_name)
  @preamble ||= @preamble_source.dup.tap do |source|
    source.gsub!(/\[yyyy\]/, "#{Date.today.year}-")
    source.gsub!(/\[name of copyright owner\]/, user_name)
    source.gsub!(/^ {2}|^$/, "#")
    source.chomp!
  end
end