Class: Capfile
- Inherits:
-
Object
- Object
- Capfile
- Defined in:
- lib/negroku/capfile.rb
Instance Attribute Summary collapse
-
#capfile_path ⇒ Object
Returns the value of attribute capfile_path.
Instance Method Summary collapse
- #add(line) ⇒ Object
- #assets ⇒ Object
-
#initialize(capfile_path) ⇒ Capfile
constructor
A new instance of Capfile.
- #negroku ⇒ Object
Constructor Details
#initialize(capfile_path) ⇒ Capfile
Returns a new instance of Capfile.
4 5 6 |
# File 'lib/negroku/capfile.rb', line 4 def initialize(capfile_path) @capfile_path = capfile_path end |
Instance Attribute Details
#capfile_path ⇒ Object
Returns the value of attribute capfile_path.
2 3 4 |
# File 'lib/negroku/capfile.rb', line 2 def capfile_path @capfile_path end |
Instance Method Details
#add(line) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/negroku/capfile.rb', line 8 def add(line) capfile = File.read(@capfile_path) if capfile.include?(line) replace = capfile.gsub(/\s*#\s*#{line}\s*/, "\n#{line}\n") File.open(@capfile_path, "w") do |cfile| cfile.puts replace end else File.open(@capfile_path, "a") do |cfile| cfile.puts line end end end |
#assets ⇒ Object
22 23 24 |
# File 'lib/negroku/capfile.rb', line 22 def assets() self.add('load \'deploy/assets\'') end |
#negroku ⇒ Object
26 27 28 29 30 |
# File 'lib/negroku/capfile.rb', line 26 def negroku() self.add("\n# Negroku recipies") self.add('require "negroku"') self.add('load negroku') end |