Skip to content

Commit

Permalink
moved toolbox.rb to bin and added warbler
Browse files Browse the repository at this point in the history
  • Loading branch information
xea committed Oct 29, 2015
1 parent 39fffc7 commit 1609914
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.tmp
*.gem
*.rbc
*.jar
/.config
/coverage/
/InstalledFiles
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ gem 'safe_attributes'
gem 'highline'
gem 'pry'
gem 'celluloid'
gem 'warbler'
File renamed without changes.
15 changes: 13 additions & 2 deletions packages/postgres/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ def feature_console_down(console)
@console = nil
end

def execute_query(query)
[ :lofasz ]
def connect_to(conninfo)
begin
connection = PG.connect(conninfo)
PGConnection.new connection
rescue PG::Error => error
# TODO error handling
end
end
end

class PGConnection

def initialize(connection)
@connection = connection
end
end
9 changes: 7 additions & 2 deletions packages/postgres/postgres_mode.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
class PostgresMode < BaseMode

mode_id :pg
mode_id :postgres
access_from :home, "postgres", "Enter PostgreSQL mode"

register_command(:exit_mode, 'exit', 'Exit current mode') { |intp| intp.modes.exit_mode }
register_command(:execute_query, 'execute *query')
register_command(:connect_to, 'connect :server :db :username? :password?')
register_command(:execute_query, 'execute *query')

def execute_query(out, pg, query)
result = pg.execute_query query
p result
end

def connect_to(out, server, db, username, password)
out.puts "Connecting to server at #{server} to #{db}"
end
end

0 comments on commit 1609914

Please sign in to comment.