Class: TTY::Gemspec

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/gemspec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

The gemspec content



6
7
8
# File 'lib/tty/gemspec.rb', line 6

def content
  @content
end

#post_var_indentObject

The gemspec indentation size afater variable name



15
16
17
# File 'lib/tty/gemspec.rb', line 15

def post_var_indent
  @post_var_indent
end

#pre_var_indentObject

The gemspec indentation before variable name



12
13
14
# File 'lib/tty/gemspec.rb', line 12

def pre_var_indent
  @pre_var_indent
end

#var_nameObject

The gemspec variable name



9
10
11
# File 'lib/tty/gemspec.rb', line 9

def var_name
  @var_name
end

Instance Method Details

#read(path) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/tty/gemspec.rb', line 17

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

#write(path) ⇒ Object



25
26
27
# File 'lib/tty/gemspec.rb', line 25

def write(path)
  ::File.write(path, content)
end