Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #12 from texticle/texticle_console

Texticle Console
  • Loading branch information...
commit a7bd9bee5647ca679fc750727c220c4d1ad67820 2 parents 435dceb + 3d37189
@benhamill benhamill authored
View
3  CHANGELOG.rdoc
@@ -13,9 +13,10 @@
characters like &, and % in search terms. Fuzzy is based on Postgres's trigram matching extension
pg_trgm. Advanced is the same functionality from `search` previously.
-* 1 dev improvement
+* 2 dev improvements
* Test database configuration not automatically generated from a rake task and ignored by git.
+ * New interactive developer console (powered by pry).
== 2.0.3
View
58 Rakefile
@@ -13,6 +13,64 @@ task :default do
Rake::Task["test"].invoke
end
+desc "Fire up an interactive terminal to play with"
+task :console do
+ require 'pry'
+ require File.expand_path(File.dirname(__FILE__) + '/lib/texticle')
+
+ config = YAML.load_file File.expand_path(File.dirname(__FILE__) + '/spec/config.yml')
+ ActiveRecord::Base.establish_connection config.merge(:adapter => :postgresql)
+
+ class Character < ActiveRecord::Base
+ belongs_to :web_comic
+ end
+
+ class WebComic < ActiveRecord::Base
+ has_many :characters
+ end
+
+ class Game < ActiveRecord::Base
+ end
+
+ # add ability to reload console
+ def reload
+ reload_msg = '# Reloading the console...'
+ puts CodeRay.scan(reload_msg, :ruby).term
+ Pry.save_history
+ exec('rake console')
+ end
+
+ # start the console! :-)
+ welcome = <<-EOS
+ Welcome to the Texticle devloper console. You have some classes you can play with:
+
+ class Character < ActiveRecord::Base
+ # string :name
+ # string :description
+ # integer :web_comic_id
+
+ belongs_to :web_comic
+ end
+
+ class WebComic < ActiveRecord::Base
+ # string :name
+ # string :author
+ # integer :id
+
+ has_many :characters
+ end
+
+ class Game < ActiveRecord::Base
+ # string :system
+ # string :title
+ # text :description
+ end
+ EOS
+
+ puts CodeRay.scan(welcome, :ruby).term
+ Pry.start
+end
+
task :test do
require 'texticle_spec'
require 'texticle/searchable_spec'
View
1  spec/spec_helper.rb
@@ -3,6 +3,7 @@
require 'yaml'
require 'texticle'
require 'shoulda'
+require 'pry'
config = YAML.load_file File.expand_path(File.dirname(__FILE__) + '/config.yml')
ActiveRecord::Base.establish_connection config.merge(:adapter => :postgresql)
View
8 texticle.gemspec
@@ -44,9 +44,11 @@ Gem::Specification.new do |s|
- s.add_development_dependency('pg', '~> 0.11.0')
- s.add_development_dependency('shoulda', '~> 2.11.3')
- s.add_development_dependency('rake', '~> 0.9.0')
+ s.add_development_dependency 'pg', '~> 0.11.0'
+ s.add_development_dependency 'shoulda', '~> 2.11.3'
+ s.add_development_dependency 'rake', '~> 0.9.0'
+ s.add_development_dependency 'pry'
+ s.add_development_dependency 'pry-doc'
s.add_dependency('activerecord', '~> 3.0')
end
Please sign in to comment.
Something went wrong with that request. Please try again.