bigrecord 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/{MIT-LICENSE → LICENSE} +0 -0
  2. data/README.rdoc +3 -3
  3. data/Rakefile +1 -2
  4. data/VERSION +1 -1
  5. data/doc/bigrecord_specs.rdoc +0 -0
  6. data/doc/getting_started.rdoc +4 -0
  7. data/examples/bigrecord.yml +0 -0
  8. data/generators/bigrecord/bigrecord_generator.rb +0 -0
  9. data/generators/bigrecord/templates/bigrecord.rake +0 -0
  10. data/generators/bigrecord_migration/bigrecord_migration_generator.rb +0 -0
  11. data/generators/bigrecord_migration/templates/migration.rb +0 -0
  12. data/generators/bigrecord_model/bigrecord_model_generator.rb +0 -0
  13. data/generators/bigrecord_model/templates/migration.rb +0 -0
  14. data/generators/bigrecord_model/templates/model.rb +0 -0
  15. data/generators/bigrecord_model/templates/model_spec.rb +0 -0
  16. data/init.rb +1 -9
  17. data/install.rb +0 -0
  18. data/lib/big_record/abstract_base.rb +0 -1
  19. data/lib/big_record/action_view_extensions.rb +0 -0
  20. data/lib/big_record/ar_associations/association_collection.rb +0 -0
  21. data/lib/big_record/ar_associations/association_proxy.rb +0 -0
  22. data/lib/big_record/ar_associations/belongs_to_association.rb +0 -0
  23. data/lib/big_record/ar_associations/belongs_to_many_association.rb +0 -0
  24. data/lib/big_record/ar_associations/has_and_belongs_to_many_association.rb +0 -0
  25. data/lib/big_record/ar_associations/has_many_association.rb +0 -0
  26. data/lib/big_record/ar_associations/has_one_association.rb +0 -0
  27. data/lib/big_record/ar_associations.rb +8 -6
  28. data/lib/big_record/ar_reflection.rb +1 -1
  29. data/lib/big_record/attribute_methods.rb +1 -1
  30. data/lib/big_record/base.rb +35 -24
  31. data/lib/big_record/br_associations/association_collection.rb +0 -0
  32. data/lib/big_record/br_associations/association_proxy.rb +0 -0
  33. data/lib/big_record/br_associations/belongs_to_association.rb +0 -0
  34. data/lib/big_record/br_associations/belongs_to_many_association.rb +0 -0
  35. data/lib/big_record/br_associations/cached_item_proxy.rb +0 -0
  36. data/lib/big_record/br_associations/cached_item_proxy_factory.rb +0 -0
  37. data/lib/big_record/br_associations/has_and_belongs_to_many_association.rb +0 -0
  38. data/lib/big_record/br_associations/has_one_association.rb +0 -0
  39. data/lib/big_record/br_associations.rb +8 -6
  40. data/lib/big_record/br_reflection.rb +0 -0
  41. data/lib/big_record/callbacks.rb +0 -0
  42. data/lib/big_record/connection_adapters/abstract/connection_specification.rb +0 -0
  43. data/lib/big_record/connection_adapters/abstract/database_statements.rb +0 -0
  44. data/lib/big_record/connection_adapters/abstract/quoting.rb +0 -0
  45. data/lib/big_record/connection_adapters/abstract_adapter.rb +0 -0
  46. data/lib/big_record/connection_adapters/column.rb +0 -0
  47. data/lib/big_record/connection_adapters/hbase_adapter.rb +0 -0
  48. data/lib/big_record/connection_adapters/view.rb +13 -1
  49. data/lib/big_record/connection_adapters.rb +0 -0
  50. data/lib/big_record/deletion.rb +0 -0
  51. data/lib/big_record/dynamic_schema.rb +3 -6
  52. data/lib/big_record/embedded.rb +0 -0
  53. data/lib/big_record/embedded_associations/association_proxy.rb +0 -0
  54. data/lib/big_record/family_span_columns.rb +0 -0
  55. data/lib/big_record/fixtures.rb +0 -0
  56. data/lib/big_record/migration.rb +1 -16
  57. data/lib/big_record/routing_ext.rb +1 -27
  58. data/lib/big_record/timestamp.rb +3 -3
  59. data/lib/big_record/validations.rb +1 -1
  60. data/lib/big_record.rb +35 -47
  61. data/lib/bigrecord.rb +0 -0
  62. data/rails/init.rb +8 -2
  63. data/spec/connections/bigrecord.yml +0 -0
  64. data/spec/connections/cassandra/connection.rb +0 -0
  65. data/spec/connections/hbase/connection.rb +0 -0
  66. data/spec/debug.log +40722 -246
  67. data/spec/integration/br_associations_spec.rb +0 -0
  68. data/spec/lib/animal.rb +10 -5
  69. data/spec/lib/book.rb +0 -0
  70. data/spec/lib/broken_migrations/duplicate_name/20090706182535_add_animals_table.rb +0 -0
  71. data/spec/lib/broken_migrations/duplicate_name/20090706193019_add_animals_table.rb +0 -0
  72. data/spec/lib/broken_migrations/duplicate_version/20090706190623_add_books_table.rb +0 -0
  73. data/spec/lib/broken_migrations/duplicate_version/20090706190623_add_companies_table.rb +0 -0
  74. data/spec/lib/company.rb +0 -0
  75. data/spec/lib/embedded/web_link.rb +0 -0
  76. data/spec/lib/employee.rb +0 -0
  77. data/spec/lib/migrations/20090706182535_add_animals_table.rb +0 -0
  78. data/spec/lib/migrations/20090706190623_add_books_table.rb +0 -0
  79. data/spec/lib/migrations/20090706193019_add_companies_table.rb +0 -0
  80. data/spec/lib/migrations/20090706194512_add_employees_table.rb +0 -0
  81. data/spec/lib/migrations/20090706195741_add_zoos_table.rb +0 -0
  82. data/spec/lib/novel.rb +0 -0
  83. data/spec/lib/zoo.rb +0 -0
  84. data/spec/spec.opts +0 -0
  85. data/spec/spec_helper.rb +0 -0
  86. data/spec/unit/abstract_base_spec.rb +0 -56
  87. data/spec/unit/adapters/abstract_adapter_spec.rb +0 -0
  88. data/spec/unit/adapters/adapter_shared_spec.rb +0 -0
  89. data/spec/unit/adapters/hbase_adapter_spec.rb +0 -0
  90. data/spec/unit/ar_associations_spec.rb +0 -0
  91. data/spec/unit/base_spec.rb +101 -0
  92. data/spec/unit/br_associations_spec.rb +0 -0
  93. data/spec/unit/embedded_spec.rb +0 -0
  94. data/spec/unit/find_spec.rb +0 -0
  95. data/spec/unit/hash_helper_spec.rb +0 -0
  96. data/spec/unit/migration_spec.rb +0 -0
  97. data/spec/unit/model_spec.rb +0 -0
  98. data/spec/unit/validations_spec.rb +0 -0
  99. data/tasks/bigrecord_tasks.rake +0 -0
  100. data/tasks/data_store.rb +0 -0
  101. data/tasks/gem.rb +4 -3
  102. data/tasks/rdoc.rb +0 -0
  103. data/tasks/spec.rb +1 -1
  104. metadata +24 -4
File without changes
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Big Record
2
2
 
3
- A Ruby Object/Data Mapper for distributed column-oriented data stores (inspired by BigTable) such as HBase. Intended to work as a drop-in for Rails applications. More information soon...
3
+ A Ruby Object/Data Mapper for distributed column-oriented data stores (inspired by BigTable) such as HBase. Intended to work as a drop-in for Rails applications.
4
4
 
5
5
  == Features
6
6
  * Dynamic schemas (due to the schema-less design of BigTable).
@@ -10,9 +10,9 @@ A Ruby Object/Data Mapper for distributed column-oriented data stores (inspired
10
10
  * Automatic versioning.
11
11
  * Scalability (depending on the data store used).
12
12
 
13
- == Why would I use it?
13
+ == Motivations
14
14
 
15
- BigTable, and by extension, Big Record isn't right for everyone. A great introductory article discussing this topic can be found at http://blog.rapleaf.com/dev/?p=26 explaining why you would or wouldn't use BigTable. The rule of thumb, however, is that if your data model is simple or can fit into a standard RDBMS, then you probably don't need it.
15
+ BigTable, and by extension, Bigrecord isn't right for everyone. A great introductory article discussing this topic can be found at http://blog.rapleaf.com/dev/?p=26 explaining why you would or wouldn't use BigTable. The rule of thumb, however, is that if your data model is simple or can fit into a standard RDBMS, then you probably don't need it.
16
16
 
17
17
  Beyond this though, there are two basic motivations that almost immediately demand a BigTable model database:
18
18
  1. Your data is highly dynamic in nature and would not fit in a schema bound model, or you cannot define a schema ahead of time.
data/Rakefile CHANGED
@@ -4,12 +4,11 @@ require 'rubygems'
4
4
  require 'rake'
5
5
  require 'rake/rdoctask'
6
6
  require 'rake/gempackagetask'
7
- require 'pathname'
8
7
  require 'spec/rake/spectask'
9
8
 
10
9
 
11
10
  DATA_STORES = ["hbase", "cassandra"]
12
- ROOT = Pathname(__FILE__).dirname.expand_path
11
+ ROOT = File.expand_path(File.dirname(__FILE__)) + '/'
13
12
 
14
13
  require ROOT + 'tasks/gem'
15
14
  require ROOT + 'tasks/rdoc'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
File without changes
@@ -18,6 +18,10 @@
18
18
 
19
19
  config.gem "bigrecord", :source => "http://gemcutter.org"
20
20
 
21
+ and run the following command to install all the gems listed for your Rails app:
22
+
23
+ [sudo] rake gems:install
24
+
21
25
  (3) Bootstrap Bigrecord into your project:
22
26
 
23
27
  script/generate bigrecord
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/init.rb CHANGED
@@ -1,9 +1 @@
1
- require 'big_record'
2
-
3
- # Use the same logger as ActiveRecord to make sure that the access to the log file is properly handled
4
- BigRecord::Base.logger = ActiveRecord::Base.logger
5
- BigRecord::Embedded.logger = ActiveRecord::Base.logger
6
-
7
- # Establish the connection with the database
8
- BigRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/bigrecord.yml"))
9
- BigRecord::Base.establish_connection
1
+ require File.join(File.dirname(__FILE__), "rails", "init")
data/install.rb CHANGED
File without changes
@@ -1,4 +1,3 @@
1
- ## The sub-classes of this class must implement the abstract method 'column_names' of this class.
2
1
  module BigRecord
3
2
  class BigRecordError < StandardError #:nodoc:
4
3
  end
File without changes
File without changes
@@ -1,9 +1,11 @@
1
- require 'big_record/ar_associations/association_proxy'
2
- require 'big_record/ar_associations/association_collection'
3
- require 'big_record/ar_associations/belongs_to_association'
4
- require 'big_record/ar_associations/has_one_association'
5
- require 'big_record/ar_associations/has_many_association'
6
- require 'big_record/ar_associations/has_and_belongs_to_many_association'
1
+ dir = File.expand_path(File.join(File.dirname(__FILE__), "ar_associations"))
2
+
3
+ require dir + '/association_proxy'
4
+ require dir + '/association_collection'
5
+ require dir + '/belongs_to_association'
6
+ require dir + '/has_one_association'
7
+ require dir + '/has_many_association'
8
+ require dir + '/has_and_belongs_to_many_association'
7
9
 
8
10
  module BigRecord
9
11
  class HasManyThroughAssociationNotFoundError < BigRecordError #:nodoc:
@@ -4,7 +4,7 @@ module BigRecord
4
4
  base.extend(ClassMethods)
5
5
  end
6
6
 
7
- # Reflection allows you to interrogate Active Record classes and objects about their associations and aggregations.
7
+ # Reflection allows you to interrogate Big Record classes and objects about their associations and aggregations.
8
8
  # This information can, for example, be used in a form builder that took an Active Record object and created input
9
9
  # fields for all of the attributes depending on their type and displayed the associations to other objects.
10
10
  #
@@ -19,7 +19,7 @@ module BigRecord
19
19
  # the attr argument.
20
20
  #
21
21
  # For example:
22
- # class Person < ActiveRecord::Base
22
+ # class Person < BigRecord::Base
23
23
  # attribute_method_suffix '_changed?'
24
24
  #
25
25
  # private
@@ -1,4 +1,3 @@
1
- ## The sub-classes of this class must implement the abstract method 'column_names' of this class.
2
1
  module BigRecord
3
2
 
4
3
  class Base < AbstractBase
@@ -411,14 +410,14 @@ module BigRecord
411
410
  (superclass == BigRecord::Base) ? self : superclass.base_class
412
411
  end
413
412
 
414
- def view(name, columns)
413
+ def view(name, *columns)
415
414
  name = name.to_sym
416
415
  @views_hash ||= default_views
417
416
 
418
417
  # The other variables that are cached and depend on @views_hash need to be reloaded
419
418
  invalidate_views
420
419
 
421
- @views_hash[name] = ConnectionAdapters::View.new(name, columns, self)
420
+ @views_hash[name] = ConnectionAdapters::View.new(name, columns.flatten, self)
422
421
  end
423
422
 
424
423
  def views
@@ -471,6 +470,39 @@ module BigRecord
471
470
  end
472
471
  end
473
472
 
473
+ # return the list of columns to get from hbase
474
+ def columns_to_find(options={})
475
+ c =
476
+ if options[:columns]
477
+ column_list = []
478
+ options[:columns].each do |column_name|
479
+ # If the column name provided is a full name, i.e. includes column family and qualifier,
480
+ # then add it to the list.
481
+ if column_name.to_s =~ /:/
482
+ column_list << column_name
483
+
484
+ # Otherwise, it's probably an alias and we need to check that.
485
+ else
486
+ columns.select{|column| column_list << column.name if column.alias == column_name.to_s}
487
+ end
488
+ end
489
+ column_list
490
+ elsif options[:view]
491
+ raise ArgumentError, "Unknown view: #{options[:view]}" unless views_hash[options[:view]]
492
+ if options[:view] == :all
493
+ ["#{default_family}:"]
494
+ else
495
+ views_hash[options[:view]].column_names
496
+ end
497
+ elsif views_hash[:default]
498
+ views_hash[:default].column_names
499
+ else
500
+ ["#{default_family}:"]
501
+ end
502
+ c += [options[:include]] if options[:include]
503
+ c.flatten.reject{|x| x == "id"}
504
+ end
505
+
474
506
  protected
475
507
  def invalidate_views
476
508
  @views = nil
@@ -567,27 +599,6 @@ module BigRecord
567
599
  end
568
600
  end
569
601
 
570
- # return the list of columns to get from hbase
571
- def columns_to_find(options={})
572
- c =
573
- if options[:columns]
574
- options[:columns]
575
- elsif options[:view]
576
- raise ArgumentError, "Unknown view: #{options[:view]}" unless views_hash[options[:view]]
577
- if options[:view] == :all
578
- ["#{default_family}:"]
579
- else
580
- views_hash[options[:view]].column_names
581
- end
582
- elsif views_hash[:default]
583
- views_hash[:default].column_names
584
- else
585
- ["#{default_family}:"]
586
- end
587
- c += [options[:include]] if options[:include]
588
- c.flatten.reject{|x| x == "id"}
589
- end
590
-
591
602
  # Add the missing cells to the raw record and set them to nil. We know that it's
592
603
  # nil because else we would have received those cells. That way, when the value of
593
604
  # one of these cells will be requested by the client we won't try to lazy load it.
File without changes
File without changes
@@ -1,9 +1,11 @@
1
- require 'big_record/br_associations/association_proxy'
2
- require 'big_record/br_associations/association_collection'
3
- require 'big_record/br_associations/belongs_to_association'
4
- require 'big_record/br_associations/belongs_to_many_association'
5
- require 'big_record/br_associations/has_one_association'
6
- require 'big_record/br_associations/has_and_belongs_to_many_association'
1
+ dir = File.expand_path(File.join(File.dirname(__FILE__), "br_associations"))
2
+
3
+ require dir + '/association_proxy'
4
+ require dir + '/association_collection'
5
+ require dir + '/belongs_to_association'
6
+ require dir + '/belongs_to_many_association'
7
+ require dir + '/has_one_association'
8
+ require dir + '/has_and_belongs_to_many_association'
7
9
 
8
10
  module BigRecord
9
11
  module BrAssociations # :nodoc:
File without changes
File without changes
File without changes
File without changes
@@ -12,7 +12,19 @@ module BigRecord
12
12
  # Return the column objects associated with this view. By default the views 'all' and 'default' return every column.
13
13
  def columns
14
14
  if @column_names
15
- @column_names.collect{|cn| owner.columns_hash[cn]}
15
+ columns = []
16
+
17
+ # First match against fully named columns, e.g. 'attribute:name'
18
+ @column_names.each{|cn| columns << owner.columns_hash[cn] if owner.columns_hash.has_key?(cn)}
19
+
20
+ # Now match against aliases if the number of columns found previously do not
21
+ # match the expected @columns_names size, i.e. there's still some missing.
22
+ if columns.size != @column_names.size
23
+ columns_left = @column_names - columns.map{|column| column.name}
24
+ owner.columns_hash.each { |name,column| columns << column if columns_left.include?(column.alias) }
25
+ end
26
+
27
+ columns
16
28
  else
17
29
  owner.columns
18
30
  end
File without changes
File without changes
@@ -1,4 +1,3 @@
1
- # Replace the anonymous classes
2
1
  module BigRecord
3
2
  module DynamicSchema
4
3
 
@@ -9,12 +8,10 @@ module BigRecord
9
8
  base.alias_method_chain :attributes_from_column_definition, :dynamic_schema
10
9
  base.alias_method_chain :inspect, :dynamic_schema
11
10
  base.alias_method_chain :define_read_methods, :dynamic_schema
12
-
13
11
  end
14
12
 
15
13
  # Stub of the callback for setting the dynamic columns. Override this to add dynamic columns
16
14
  def initialize_columns(options={})
17
-
18
15
  end
19
16
 
20
17
  # Create and add a dynamic column to this record
@@ -23,10 +20,10 @@ module BigRecord
23
20
  end
24
21
 
25
22
  # Add an existing dynamic column to this record
26
- def add_dynamic_column(c)
27
- columns_hash[c.name] = c
23
+ def add_dynamic_column(col)
24
+ columns_hash[c.name] = col
28
25
  @columns_name= nil; @columns= nil #reset
29
- c
26
+ col
30
27
  end
31
28
 
32
29
  def columns_hash
File without changes
File without changes
File without changes
@@ -1,19 +1,4 @@
1
- # require 'active_support/core_ext/object/metaclass'
2
-
3
- # Instead of requiring the activesupport class (metaclass)
4
- class Object
5
- # Get object's meta (ghost, eigenclass, singleton) class
6
- def metaclass
7
- class << self
8
- self
9
- end
10
- end
11
-
12
- # If class_eval is called on an object, add those methods to its metaclass
13
- def class_eval(*args, &block)
14
- metaclass.class_eval(*args, &block)
15
- end
16
- end
1
+ require 'active_support/core_ext/object/metaclass'
17
2
 
18
3
  module BigRecord
19
4
  class IrreversibleMigration < BigRecordError#:nodoc:
@@ -35,31 +35,5 @@ module ActionController
35
35
  end
36
36
  end
37
37
  end
38
-
39
- # TODO: Remove this monkey patch once we migrate to rails 2.3. This patch
40
- # add support for the :as option in map.resources.
41
- module Resources
42
- class Resource
43
-
44
- attr_reader :path_segment
45
-
46
- def initialize(entities, options)
47
- @plural ||= entities
48
- @singular ||= options[:singular] || plural.to_s.singularize
49
- @path_segment = options.delete(:as) || @plural
50
-
51
- @options = options
52
-
53
- arrange_actions
54
- add_default_actions
55
- set_prefixes
56
- end
57
-
58
- def path
59
- @path ||= "#{path_prefix}/#{path_segment}"
60
- end
61
-
62
- end
63
- end
64
-
38
+
65
39
  end
@@ -1,15 +1,15 @@
1
1
  module BigRecord
2
- # Active Record automatically timestamps create and update if the table has fields
2
+ # Big Record automatically timestamps create and update if the table has fields
3
3
  # created_at/created_on or updated_at/updated_on.
4
4
  #
5
5
  # Timestamping can be turned off by setting
6
- # <tt>ActiveRecord::Base.record_timestamps = false</tt>
6
+ # <tt>BigRecord::Base.record_timestamps = false</tt>
7
7
  #
8
8
  # Keep in mind that, via inheritance, you can turn off timestamps on a per
9
9
  # model basis by setting <tt>record_timestamps</tt> to false in the desired
10
10
  # models.
11
11
  #
12
- # class Feed < ActiveRecord::Base
12
+ # class Feed < BigRecord::Base
13
13
  # self.record_timestamps = false
14
14
  # # ...
15
15
  # end
@@ -3,7 +3,7 @@ module BigRecord
3
3
  # record method to retrieve the record which did not validate.
4
4
  # begin
5
5
  # complex_operation_that_calls_save!_internally
6
- # rescue ActiveRecord::RecordInvalid => invalid
6
+ # rescue BigRecord::RecordInvalid => invalid
7
7
  # puts invalid.record.errors
8
8
  # end
9
9
  class RecordInvalid < BigRecordError #:nodoc:
data/lib/big_record.rb CHANGED
@@ -21,56 +21,42 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- $:.unshift(File.dirname(__FILE__)) unless
25
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
24
+ dir = File.expand_path(File.join(File.dirname(__FILE__), "big_record"))
26
25
 
27
- unless defined?(ActiveSupport)
28
- begin
29
- $:.unshift(File.dirname(__FILE__) + "/../../activesupport/lib")
30
- require 'active_support'
31
- rescue LoadError
32
- require 'rubygems'
33
- gem 'activesupport'
34
- require 'active_support'
35
- end
26
+ begin
27
+ require 'active_support'
28
+ rescue LoadError
29
+ raise LoadError, "Bigrecord depends on ActiveSupport. Install it with: gem install activesupport"
36
30
  end
37
31
 
38
- unless defined?(ActiveRecord)
39
- begin
40
- $:.unshift(File.dirname(__FILE__) + "/../../activerecord/lib")
41
- require 'active_record'
42
- rescue LoadError
43
- require 'rubygems'
44
- gem 'activerecord'
45
- require 'active_record'
46
- end
32
+ begin
33
+ require 'active_record'
34
+ rescue LoadError
35
+ puts "[Bigrecord] ActiveRecord could not be loaded. Bigrecord associations with AR models disabled."
47
36
  end
48
37
 
49
- # FIXME: this shouldn't be required
50
- # require 'active_record/fixtures'
51
-
52
- require 'big_record/routing_ext'
53
- require 'big_record/abstract_base'
54
- require 'big_record/base'
55
- require 'big_record/embedded'
56
- require 'big_record/validations'
57
- require 'big_record/callbacks'
58
- require 'big_record/ar_reflection'
59
- require 'big_record/br_reflection'
60
- require 'big_record/ar_associations'
61
- require 'big_record/br_associations'
62
- require 'big_record/timestamp'
63
- require 'big_record/attribute_methods'
64
- require 'big_record/embedded_associations/association_proxy'
65
- require 'big_record/dynamic_schema'
66
- require 'big_record/deletion'
67
- require 'big_record/family_span_columns'
68
- require 'big_record/migration'
69
- require 'big_record/connection_adapters'
70
- require 'big_record/fixtures'
38
+ require dir + '/routing_ext'
39
+ require dir + '/abstract_base'
40
+ require dir + '/base'
41
+ require dir + '/embedded'
42
+ require dir + '/validations'
43
+ require dir + '/callbacks'
44
+ require dir + '/ar_reflection'
45
+ require dir + '/br_reflection'
46
+ require dir + '/ar_associations'
47
+ require dir + '/br_associations'
48
+ require dir + '/timestamp'
49
+ require dir + '/attribute_methods'
50
+ require dir + '/embedded_associations/association_proxy'
51
+ require dir + '/dynamic_schema'
52
+ require dir + '/deletion'
53
+ require dir + '/family_span_columns'
54
+ require dir + '/migration'
55
+ require dir + '/connection_adapters'
56
+ require dir + '/fixtures'
71
57
 
72
58
  # Add support for collections to tag builders
73
- require 'big_record/action_view_extensions'
59
+ require dir + '/action_view_extensions'
74
60
 
75
61
  BigRecord::Base.class_eval do
76
62
  include BigRecord::Validations
@@ -99,12 +85,14 @@ BigRecord::Embedded.class_eval do
99
85
  end
100
86
 
101
87
  # Mixin the BigRecord associations with ActiveRecord
102
- ActiveRecord::Base.class_eval do
103
- include BigRecord::BrAssociations
104
- include BigRecord::BrReflection
88
+ if defined?(ActiveRecord)
89
+ ActiveRecord::Base.class_eval do
90
+ include BigRecord::BrAssociations
91
+ include BigRecord::BrReflection
92
+ end
105
93
  end
106
94
 
107
- # Patch to call the validation of the embedded objects to HbaseRecord::Base instances.
95
+ # Patch to call the validation of the embedded objects to BigRecord::Base instances.
108
96
  BigRecord::Base.class_eval do
109
97
  validate :validate_embeddeds
110
98
 
data/lib/bigrecord.rb CHANGED
File without changes
data/rails/init.rb CHANGED
@@ -4,6 +4,12 @@ require 'big_record'
4
4
  BigRecord::Base.logger = ActiveRecord::Base.logger
5
5
  BigRecord::Embedded.logger = ActiveRecord::Base.logger
6
6
 
7
- # Establish the connection with the database
8
- BigRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/bigrecord.yml"))
7
+ # Load in the config from the RAILS_ROOT/config folder
8
+ begin
9
+ BigRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/bigrecord.yml"))
10
+ rescue
11
+ puts "[Bigrecord] Couldn't load the config/bigrecord.yml config file. Please bootstrap it into your application with: script/generate bigrecord"
12
+ end
13
+
14
+ # Try establishing the connection
9
15
  BigRecord::Base.establish_connection
File without changes
File without changes
File without changes