Class: Aruba::Initializers::CommonInitializer
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Aruba::Initializers::CommonInitializer
- Includes:
- Thor::Actions
- Defined in:
- lib/aruba/initializer.rb
Overview
Common initializer
Instance Method Summary collapse
-
#add_gem ⇒ Object
Add gem to gemfile.
Instance Method Details
#add_gem ⇒ Object
Add gem to gemfile
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/aruba/initializer.rb', line 17 def add_gem file = "Gemfile" creator = if File.exist? file :append_to_file else :create_file end content = if File.exist? file file_ends_with_carriage_return = File.open(file, "r").readlines.last.match(/.*\n$/) prefix = file_ends_with_carriage_return ? "" : "\n" %(#{prefix}gem 'aruba', '~> #{Aruba::VERSION}') else %(source 'https://rubygems.org'\ngem 'aruba', '~> #{Aruba::VERSION}'\n) end send creator, file, content end |