Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3caf7a2
commit 8dce742
Showing
71 changed files
with
9,327 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Logfile created on Mon May 04 02:09:40 -07:00 2009 by / | ||
Migrating to CreatePeople (20090423112611) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'person' | ||
|
||
puts "Loading .NET Libraries #{Time.now}" | ||
require 'mscorlib' | ||
require 'system' | ||
require 'System.Drawing' | ||
require 'System.Windows.Forms' | ||
|
||
include System | ||
include System::Drawing | ||
include System::Windows::Forms | ||
include System::ComponentModel | ||
|
||
puts "Starting app #{Time.now}" | ||
|
||
require 'c:/dev/repl' | ||
|
||
class MyForm < Form # System::Windows::Forms | ||
def initialize | ||
@binding_src = BindingSource.new | ||
@datagrid = DataGridView.new | ||
self.controls.add @datagrid | ||
@datagrid.dock = DockStyle.top; | ||
self.size = Size.new 800, 200 | ||
self.load do |s,e| | ||
@customer_list = BindingList.of(Person).new | ||
|
||
# Make sure all fields are loaded by calling | ||
# one field on each record | ||
Person.all.each{|pe| pe.age } | ||
|
||
Person.all.each do |pe| | ||
@customer_list.add pe | ||
end rescue nil # Note sure why rescue is needed | ||
|
||
@binding_src.data_source = @customer_list | ||
@datagrid.data_source = @binding_src | ||
end | ||
end | ||
end | ||
|
||
t = Thread.new do | ||
Application.enable_visual_styles | ||
Application.run MyForm.new | ||
end | ||
|
||
repl binding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'event' # defines RubyEvent | ||
|
||
require 'mscorlib' | ||
require 'system' | ||
|
||
include System::ComponentModel | ||
|
||
# For use in a ActiveRecord model, to databind it's attributes. | ||
module ActiveRecord::AttributeChangeNotifier | ||
include INotifyPropertyChanged | ||
|
||
# required by INotifyPropertyChange | ||
def add_PropertyChanged handler | ||
@attr_change ||= RubyEvent.new | ||
repl binding, 'AddPropertyChanged' | ||
@attr_change.add handler | ||
end | ||
|
||
# required by INotifyPropertyChange | ||
def remove_PropertyChanged handler | ||
@attr_change.remove handler if @attr_change | ||
end | ||
|
||
# Executed before ActiveRecord::Base#save | ||
def before_save | ||
if self.changed? | ||
@model_changes = self.changes.clone | ||
end | ||
true | ||
end | ||
|
||
# Executed after ActiveRecord::Base#save | ||
def after_save | ||
repl binding, 'after_save' | ||
@model_changes.each do |field, (oldval, newval)| | ||
@attr_change.caller.call(field, oldval, newval) if @attr_change | ||
end | ||
@model_changes = [] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
puts "Loading rubygems #{Time.now}" | ||
require 'rubygems' | ||
|
||
puts "Loading activerecord #{Time.now}" | ||
require 'activerecord' | ||
|
||
puts "Connecting to database #{Time.now}" | ||
ActiveRecord::Base.establish_connection( | ||
:adapter => "mssql", | ||
:host => "JIMMYSCH-GEMINI\\SQLEXPRESS", | ||
:database => "ardb2", | ||
:integrated_security => true | ||
) | ||
|
||
ActiveRecord::Base.logger = Logger.new("activerecord.log") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'person' | ||
require 'irb' | ||
IRB.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# CLR event-like functionality for Ruby. | ||
# | ||
# >>> foo_event, on_foo_event = RubyEvent.build | ||
# >>> handler = foo.add { puts "foo event fired" } | ||
# >>> # or | ||
# >>> def another | ||
# >>> puts "foo event fired again" | ||
# >>> end | ||
# >>> foo.add method(:another) | ||
# >>> on_foo_event.call | ||
# foo event fired | ||
# foo event fired again | ||
# => nil | ||
class RubyEvent | ||
|
||
# List of event handlers of type Proc | ||
attr_reader :handlers | ||
|
||
# Triggers the event; Proc which calls all handlers | ||
attr_reader :caller | ||
|
||
def initialize | ||
@handlers = [] | ||
@caller ||= lambda do |*args| | ||
@handlers.each { |h| h.call(*args) } | ||
nil | ||
end | ||
end | ||
|
||
def add(event = nil, &block) | ||
event = block if event.nil? && block_given? | ||
if event.kind_of?(RubyEvent) | ||
@handlers.concat event.handlers | ||
else | ||
raise TypeError, "event handler must respond to call" unless event.respond_to?(:call) | ||
@handlers << event | ||
end | ||
event | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'arinit' | ||
puts "Migrating database #{Time.now}" | ||
ActiveRecord::Migrator.migrate "migrations" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CreatePeople < ActiveRecord::Migration | ||
def self.up | ||
create_table :people do |t| | ||
t.string :first_name | ||
t.string :last_name | ||
|
||
t.integer :age | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :people | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'arinit' | ||
require 'ardb' | ||
|
||
# ActiveRecord Person model, to be databinded with | ||
class Person < ActiveRecord::Base | ||
include ActiveRecord::AttributeChangeNotifier | ||
end |
Oops, something went wrong.