Sha256: 12081b2f273dfc353a14545a1a2705b3a24cfea05fa663e302fd8d7140214455

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

#We might have rails...
if defined?(Rails) && !defined?(Rake) && defined?(config) && config.respond_to?(:gems)

  if RUBY_VERSION.to_f >= 1.9
    require 'csv'
  else
    puts "- When you upgrade to Ruby 1.9 fastercsv gem will not be a dependecy anymore"
    config.gem 'fastercsv', :lib => 'faster_csv', :version => '>=1.4.0'
  end

  require 'csv_pirate'
  require 'ninth_bit/pirate_ship'

  config.to_prepare do
    # If you are using this on a vanilla Ruby class (no rails or active record) then extend your class like this:
    #  MyClass.send(:extend, NinthBit::PirateShip::ActMethods) if defined?(MyClass)
    # Alternatively you can do this inside your class definition:
    #   class MyClass
    #     extend NinthBit::PirateShip::ActMethods
    #   end
    # If you are using ActiveRecord then it is done for you :)
    ActiveRecord::Base.send(:extend, NinthBit::PirateShip::ActMethods) if defined?(ActiveRecord)
  end

#And we might not... (rake needs to come hear to load the gems properly)
else

  begin

    require 'rubygems'
    if RUBY_VERSION.to_f >= 1.9
      require 'csv'
    else
      puts "* When you upgrade to Ruby 1.9 fastercsv gem will not be a dependecy anymore"
      gem 'fastercsv', '>=1.4.0', :lib => 'faster_csv'
    end
    require 'csv_pirate'
    require 'ninth_bit/pirate_ship'
    ActiveRecord::Base.send(:extend, NinthBit::PirateShip::ActMethods) if defined?(ActiveRecord)

  rescue Gem::LoadError
    if RUBY_VERSION.to_f >= 1.9
      raise
    else
      puts "Install the fastercsv gem to enable CsvPirate"
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
csv_pirate-4.1.4 rails/init.rb
csv_pirate-4.1.3 rails/init.rb
csv_pirate-4.1.2 rails/init.rb
csv_pirate-4.1.1 rails/init.rb
csv_pirate-4.1.0 rails/init.rb