Module: Rails3::Assist::File::Special::Methods
- Included in:
- Rails3::Assist::File::Special, Rails3::Assist::File::Special
- Defined in:
- lib/rails3_assist/file/special.rb
Instance Method Summary collapse
- #clean_gemfile ⇒ Object
- #database_file ⇒ Object
- #gem_file ⇒ Object
- #has_gem?(name) ⇒ Boolean
- #has_gem_version?(name, version = nil) ⇒ Boolean
- #insert_into_routes(route_stmt = nil, &block) ⇒ Object
- #seed_file ⇒ Object
Instance Method Details
#clean_gemfile ⇒ Object
35 36 37 38 |
# File 'lib/rails3_assist/file/special.rb', line 35 def clean_gemfile clean_gemfile_content = read_gem_file.gsub(/('|"|end)\s*gem/m, "\\1\ngem") File.open(gem_file, 'w') {|f| f.write(clean_gemfile_content) } end |
#database_file ⇒ Object
15 16 17 |
# File 'lib/rails3_assist/file/special.rb', line 15 def database_file File.join(Rails3::Assist::Directory.config_dir, 'database.yml') end |
#gem_file ⇒ Object
23 24 25 |
# File 'lib/rails3_assist/file/special.rb', line 23 def gem_file File.join(Rails3::Assist::Directory.root_dir, 'Gemfile') end |
#has_gem?(name) ⇒ Boolean
27 28 29 |
# File 'lib/rails3_assist/file/special.rb', line 27 def has_gem? name File.new(gem_file).read =~ /gem\s+('|")#{name}\1/ end |
#has_gem_version?(name, version = nil) ⇒ Boolean
31 32 33 |
# File 'lib/rails3_assist/file/special.rb', line 31 def has_gem_version? name, version = nil File.new(gem_file).read =~ /gem\s+('|")#{name}\1,\s*('|")#{version}\2/ end |
#insert_into_routes(route_stmt = nil, &block) ⇒ Object
40 41 42 43 |
# File 'lib/rails3_assist/file/special.rb', line 40 def insert_into_routes route_stmt=nil, &block statement = block ? yield : route_stmt File.insert_into routes_file, statement, :after => 'Application.routes.draw do' end |