Class: TTY::Gemspec
- Inherits:
-
Object
- Object
- TTY::Gemspec
- Defined in:
- lib/tty/gemspec.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
The gemspec content.
-
#post_var_indent ⇒ Object
The gemspec indentation size afater variable name.
-
#pre_var_indent ⇒ Object
The gemspec indentation before variable name.
-
#var_name ⇒ Object
The gemspec variable name.
Instance Method Summary collapse
Instance Attribute Details
#content ⇒ Object
The gemspec content
7 8 9 |
# File 'lib/tty/gemspec.rb', line 7 def content @content end |
#post_var_indent ⇒ Object
The gemspec indentation size afater variable name
16 17 18 |
# File 'lib/tty/gemspec.rb', line 16 def post_var_indent @post_var_indent end |
#pre_var_indent ⇒ Object
The gemspec indentation before variable name
13 14 15 |
# File 'lib/tty/gemspec.rb', line 13 def pre_var_indent @pre_var_indent end |
#var_name ⇒ Object
The gemspec variable name
10 11 12 |
# File 'lib/tty/gemspec.rb', line 10 def var_name @var_name end |
Instance Method Details
#read(path) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/tty/gemspec.rb', line 18 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
26 27 28 |
# File 'lib/tty/gemspec.rb', line 26 def write(path) ::File.write(path, content) end |