1
0
Fork 0
mirror of https://github.com/pry/pry-rails.git synced 2022-11-09 12:36:03 -05:00

1.8 compatibility and Readme updates

This commit is contained in:
Ryan Fitzgerald 2012-09-23 15:21:19 -07:00
parent 16c0f2a459
commit c3feb6f3d8
8 changed files with 57 additions and 20 deletions

View file

@ -18,7 +18,9 @@ end
appraise "rails4" do appraise "rails4" do
gem "rails", gem "rails",
:git => "git@github.com:rails/rails.git" :git => "git@github.com:rails/rails.git"
gem "active_record_deprecated_finders", gem "activerecord-deprecated_finders",
:git => "git@github.com:rails/active_record_deprecated_finders" :git => "git@github.com:rails/activerecord-deprecated_finders"
gem "journey",
:git => "git@github.com:rails/journey"
gem "sqlite3" gem "sqlite3"
end end

14
Appraisals-1.8 Normal file
View file

@ -0,0 +1,14 @@
appraise "rails30" do
gem "rails", "3.0.15"
gem "sqlite3"
end
appraise "rails31" do
gem "rails", "3.1.6"
gem "sqlite3"
end
appraise "rails32" do
gem "rails", "3.2.6"
gem "sqlite3"
end

View file

@ -4,6 +4,16 @@ require "bundler/gem_tasks"
require "rake/testtask" require "rake/testtask"
require "appraisal" require "appraisal"
if RUBY_VERSION =~ /^1.8/
module Appraisal
class File
def path
'Appraisals-1.8'
end
end
end
end
Rake::TestTask.new do |t| Rake::TestTask.new do |t|
t.libs.concat %w(pry-rails spec) t.libs.concat %w(pry-rails spec)
t.pattern = "spec/*_spec.rb" t.pattern = "spec/*_spec.rb"
@ -12,8 +22,13 @@ end
desc 'Start the Rails server' desc 'Start the Rails server'
task :server => :development_env do task :server => :development_env do
require 'rails/commands/server' require 'rails/commands/server'
Rails::Server.start(server: 'WEBrick', environment: 'development', Rails::Server.start(
Host: '0.0.0.0', Port: 3000, config: 'config/config.ru') :server => 'WEBrick',
:environment => 'development',
:Host => '0.0.0.0',
:Port => 3000,
:config => 'config/config.ru'
)
end end
desc 'Start the Rails console' desc 'Start the Rails console'
@ -24,7 +39,7 @@ end
task :development_env do task :development_env do
ENV['RAILS_ENV'] = 'development' ENV['RAILS_ENV'] = 'development'
require_relative 'spec/config/environment' require File.expand_path('../spec/config/environment', __FILE__)
Dir.chdir(Rails.application.root) Dir.chdir(Rails.application.root)
end end

View file

@ -72,18 +72,19 @@ Pokemon
has_many beers through hacker has_many beers through hacker
``` ```
# Developing # Developing and Testing
To initialize the dev environment for pry-rails, run To generate Gemfiles for Rails 3.0, 3.1, 3.2, and 4.0, run
`rake init_test_app`. `rake appraisal:gemfiles appraisal:install`.
To test any changes across Rails 3.0, 3.1, 3.2, and 4.0, run You can then run the tests across all four versions with `rake appraisal`.
`rake appraisal console` and `rake appraisal server`. You can also manually run the Rails console and server with `rake
appraisal console` and `rake appraisal server`.
For a specific version of Rails, you can use `rake appraisal:rails30`, For a specific version of Rails, use `rake appraisal:rails30`, `rake
`rake appraisal:rails31`, `rake appraisal:rails32`, and `rake appraisal:rails31`, `rake appraisal:rails32`, or `rake appraisal:rails4`.
appraisal:rails4`.
# Alternative # Alternative
If you want to enable pry everywhere, make sure to check out [pry everywhere](http://lucapette.com/pry/pry-everywhere/). If you want to enable pry everywhere, make sure to check out
[pry everywhere](http://lucapette.com/pry/pry-everywhere/).

View file

@ -37,7 +37,11 @@ PryRails::Commands.create_command "show-models" do
display_error "Table doesn't exist" display_error "Table doesn't exist"
end end
model.reflections.each do |other_model, reflection| reflections = model.reflections.sort_by do |other_model, reflection|
[reflection.macro.to_s, other_model.to_s]
end
reflections.each do |other_model, reflection|
options = [] options = []
if reflection.options[:through].present? if reflection.options[:through].present?

View file

@ -20,5 +20,6 @@ Gem::Specification.new do |s|
s.add_dependency "pry", ">= 0.9.10" s.add_dependency "pry", ">= 0.9.10"
s.add_development_dependency "appraisal" s.add_development_dependency "appraisal"
s.add_development_dependency "minitest"
s.add_development_dependency "rr" s.add_development_dependency "rr"
end end

View file

@ -55,7 +55,7 @@ end
class Pokemon < ActiveRecord::Base class Pokemon < ActiveRecord::Base
belongs_to :hacker belongs_to :hacker
has_many :beers, through: :hacker has_many :beers, :through => :hacker
end end
begin begin
@ -64,7 +64,7 @@ begin
class Artist class Artist
include Mongoid::Document include Mongoid::Document
field :name, type: String field :name, :type => String
embeds_one :beer embeds_one :beer
embeds_many :instruments embeds_many :instruments
end end
@ -72,8 +72,8 @@ begin
class Instrument class Instrument
include Mongoid::Document include Mongoid::Document
field :name, type: String field :name, :type => String
embedded_in :artist embedded_in :artist
end end
rescue LoadError # Mongoid doesn't support Rails 3.0 or 4.0 rescue LoadError # Mongoid doesn't support Rails 3.0 or 4.0 or Ruby 1.8
end end

View file

@ -18,8 +18,8 @@ Beer
Hacker Hacker
id: integer id: integer
social_ability: integer social_ability: integer
has_many :pokemons
has_many :beers has_many :beers
has_many :pokemons
Pokemon Pokemon
id: integer id: integer
name: string name: string