Sha256: d52ebb0757305d626e93b283800668452d9cacb621c8d47881707d4010f9893e

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

module TTY
  class Gemspec
    # The gemspec content
    attr_accessor :content

    # The gemspec variable name
    attr_accessor :var_name

    # The gemspec indentation before variable name
    attr_accessor :pre_var_indent

    # The gemspec indentation size afater variable name
    attr_accessor :post_var_indent

    def read(path)
      self.content = ::File.read(path.to_s)
      self.var_name = content.match(/(\w+)\.name/)[1]
      matches = content.match(/^(\s*)#{var_name}(\.name\s*)=.*$/)
      self.pre_var_indent  = matches[1].size
      self.post_var_indent = matches[2].size
    end

    def write(path)
      ::File.write(path, content)
    end
  end # Gemspec
end # TTY

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tty-0.10.0 lib/tty/gemspec.rb
tty-0.9.1 lib/tty/gemspec.rb