Top Level Namespace

Defined Under Namespace

Modules: ActiveRecord, Clevic, DocumentEvent, Java, Kernel, Qt, Sequel, Ui Classes: AbstractButton, Array, BlockRunner, CaretEvent, Class, Component, EventObject, ItemEvent, JComboBox, JObject, JTabbedPane, KeyEvent, KeyStroke, ModelColumn, MouseEvent, Object, String, TableModelEvent, Ui_Browser, Ui_SearchDialog

Constant Summary collapse

OrderedHash =
Hash
SwingUtilities =
javax.swing.SwingUtilities

Instance Method Summary collapse

Instance Method Details

#distanceObject



91
92
93
# File 'lib/clevic/extensions.rb', line 91

def distance
  last - first
end

#load_rails_models(root, config, models) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/clevic/rails_models_loaders.rb', line 16

def load_rails_models( root, config, models )
  # initialize Rails
  load config / 'environment.rb'
  require 'initializer.rb'
  Rails::Initializer.run do |config|
    config.frameworks -= [ :action_mailer, :action_pack, :active_resource ]
  end

  # load lib/ files for the rails project
  $: << ( root / 'lib' ).realpath.to_s
  ( root / 'lib' ).children.each do |filename|
    load filename if filename.file?
  end

  # include Dirty if it isn't already
  begin
    ActiveRecord::Dirty
  rescue NameError
    ActiveRecord::Base.send(:include, ActiveRecord::Dirty)
  end

  # load models
  models.find do |dir_entry|
    # don't load directory entries
    next unless dir_entry.file?
    # only load .rb files
    next unless dir_entry.basename.to_s =~ /\.rb$/
    begin
      load dir_entry
    rescue Exception => e
      puts "Error loading #{dir_entry.basename.to_s}: #{e.message}"
      puts e.backtrace
    end
  end

  # include the Clevic::Record module in each descendant of
  # the entity class so that the default views will be created.
  subclasses( Clevic.base_entity_class ).each do |model|
    if model.table_exists?
      model.send :include, Clevic::Record unless model.abstract_class?
    end
  end
end

#maybe_load_rails_modelsObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/clevic/rails_models_loaders.rb', line 60

def maybe_load_rails_models
  config = pathname / 'config'
  app = pathname / 'app'
  models = app / 'models'
  # check if this is a Rails directory
  if config.exist? && app.exist? && models.exist?
    # this is probably a Rails project"
    load_rails_models( pathname, config, models )
  end  
end

#RangeObject



90
91
92
93
94
# File 'lib/clevic/extensions.rb', line 90

def Range
  def distance
    last - first
  end
end

#subclasses(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/clevic/rails_models_loaders.rb', line 3

def subclasses( base )
  classes = []
  ObjectSpace.each_object( Class ) do |x|
    if x.ancestors.include?( base )
      case
        when x == Clevic.base_entity_class; # don't include this
        else; classes << x
      end
    end
  end
  classes.sort{|a,b| a.name <=> b.name}
end