heritage 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. data/Gemfile.lock +14 -0
  2. data/heritage_demo/.rspec +1 -0
  3. data/heritage_demo/Gemfile +9 -24
  4. data/heritage_demo/Gemfile.lock +33 -2
  5. data/heritage_demo/app/models/blog_post.rb +1 -1
  6. data/heritage_demo/app/models/post.rb +5 -1
  7. data/heritage_demo/spec/factories.rb +4 -0
  8. data/heritage_demo/spec/models/blog_post_spec.rb +17 -0
  9. data/heritage_demo/spec/spec_helper.rb +33 -0
  10. data/lib/heritage/active_record/acts_as_heir.rb +6 -2
  11. data/lib/heritage/active_record/acts_as_predecessor.rb +4 -0
  12. data/lib/heritage/version.rb +1 -1
  13. metadata +8 -21
  14. data/heritage_demo/test/fixtures/blog_posts.yml +0 -9
  15. data/heritage_demo/test/fixtures/categories.yml +0 -11
  16. data/heritage_demo/test/fixtures/image_posts.yml +0 -9
  17. data/heritage_demo/test/fixtures/posts.yml +0 -11
  18. data/heritage_demo/test/functional/blog_posts_controller_test.rb +0 -8
  19. data/heritage_demo/test/functional/image_posts_controller_test.rb +0 -8
  20. data/heritage_demo/test/functional/posts_controller_test.rb +0 -8
  21. data/heritage_demo/test/performance/browsing_test.rb +0 -9
  22. data/heritage_demo/test/test_helper.rb +0 -13
  23. data/heritage_demo/test/unit/blog_post_test.rb +0 -8
  24. data/heritage_demo/test/unit/category_test.rb +0 -8
  25. data/heritage_demo/test/unit/helpers/blog_posts_helper_test.rb +0 -4
  26. data/heritage_demo/test/unit/helpers/image_posts_helper_test.rb +0 -4
  27. data/heritage_demo/test/unit/helpers/posts_helper_test.rb +0 -4
  28. data/heritage_demo/test/unit/image_post_test.rb +0 -8
  29. data/heritage_demo/test/unit/post_test.rb +0 -8
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ heritage (0.3.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ heritage!
@@ -0,0 +1 @@
1
+ --colour
@@ -6,27 +6,12 @@ gem 'rails', '3.0.6'
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
7
 
8
8
  gem 'sqlite3'
9
- gem "heritage", :path => "~/Projects/benjamin/heritage"
10
-
11
- # Use unicorn as the web server
12
- # gem 'unicorn'
13
-
14
- # Deploy with Capistrano
15
- # gem 'capistrano'
16
-
17
- # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
18
- # gem 'ruby-debug'
19
- # gem 'ruby-debug19', :require => 'ruby-debug'
20
-
21
- # Bundle the extra gems:
22
- # gem 'bj'
23
- # gem 'nokogiri'
24
- # gem 'sqlite3-ruby', :require => 'sqlite3'
25
- # gem 'aws-s3', :require => 'aws/s3'
26
-
27
- # Bundle gems for the local environment. Make sure to
28
- # put test-only gems in this group so their generators
29
- # and rake tasks are available in development mode:
30
- # group :development, :test do
31
- # gem 'webrat'
32
- # end
9
+ gem "heritage", :path => '../'
10
+
11
+ group :test do
12
+ gem 'rspec-rails'
13
+ gem 'factory_girl_rails'
14
+ gem 'autotest'
15
+ gem 'autotest-fsevent'
16
+ gem 'autotest-growl'
17
+ end
@@ -1,11 +1,12 @@
1
1
  PATH
2
- remote: ~/Projects/benjamin/heritage
2
+ remote: ../
3
3
  specs:
4
- heritage (0.3.0)
4
+ heritage (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
+ ZenTest (4.6.2)
9
10
  abstract (1.0.0)
10
11
  actionmailer (3.0.6)
11
12
  actionpack (= 3.0.6)
@@ -34,9 +35,20 @@ GEM
34
35
  activesupport (= 3.0.6)
35
36
  activesupport (3.0.6)
36
37
  arel (2.0.9)
38
+ autotest (4.4.6)
39
+ ZenTest (>= 4.4.1)
40
+ autotest-fsevent (0.2.7)
41
+ sys-uname
42
+ autotest-growl (0.2.16)
37
43
  builder (2.1.2)
44
+ diff-lcs (1.1.3)
38
45
  erubis (2.6.6)
39
46
  abstract (>= 1.0.0)
47
+ factory_girl (2.3.2)
48
+ activesupport
49
+ factory_girl_rails (1.4.0)
50
+ factory_girl (~> 2.3.0)
51
+ railties (>= 3.0.0)
40
52
  i18n (0.5.0)
41
53
  mail (2.2.15)
42
54
  activesupport (>= 2.3.6)
@@ -64,7 +76,21 @@ GEM
64
76
  rake (>= 0.8.7)
65
77
  thor (~> 0.14.4)
66
78
  rake (0.8.7)
79
+ rspec (2.7.0)
80
+ rspec-core (~> 2.7.0)
81
+ rspec-expectations (~> 2.7.0)
82
+ rspec-mocks (~> 2.7.0)
83
+ rspec-core (2.7.1)
84
+ rspec-expectations (2.7.0)
85
+ diff-lcs (~> 1.1.2)
86
+ rspec-mocks (2.7.0)
87
+ rspec-rails (2.7.0)
88
+ actionpack (~> 3.0)
89
+ activesupport (~> 3.0)
90
+ railties (~> 3.0)
91
+ rspec (~> 2.7.0)
67
92
  sqlite3 (1.3.3)
93
+ sys-uname (0.8.6)
68
94
  thor (0.14.6)
69
95
  treetop (1.4.9)
70
96
  polyglot (>= 0.3.1)
@@ -74,6 +100,11 @@ PLATFORMS
74
100
  ruby
75
101
 
76
102
  DEPENDENCIES
103
+ autotest
104
+ autotest-fsevent
105
+ autotest-growl
106
+ factory_girl_rails
77
107
  heritage!
78
108
  rails (= 3.0.6)
109
+ rspec-rails
79
110
  sqlite3
@@ -1,6 +1,6 @@
1
1
  class BlogPost < ActiveRecord::Base
2
2
 
3
- acts_as_heir_of :post
3
+ child_of :post
4
4
 
5
5
  validates_presence_of :body
6
6
  validates_presence_of :title
@@ -1,6 +1,6 @@
1
1
  class Post < ActiveRecord::Base
2
2
 
3
- acts_as_predecessor :exposes => :hello
3
+ parent_model :exposes => :hello
4
4
 
5
5
  belongs_to :category
6
6
 
@@ -8,4 +8,8 @@ class Post < ActiveRecord::Base
8
8
  "Hi there!"
9
9
  end
10
10
 
11
+ def hidden_hello
12
+ "Oh no!"
13
+ end
14
+
11
15
  end
@@ -0,0 +1,4 @@
1
+ Factory.define :blog_post do |blog_post|
2
+ blog_post.body "Hey there!"
3
+ blog_post.title "Hello World"
4
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe BlogPost do
4
+ let(:blog_post) { Factory(:blog_post) }
5
+
6
+ it "should inherit attributes" do
7
+ blog_post.should respond_to :title
8
+ end
9
+
10
+ it "should inherit exposed methods" do
11
+ blog_post.should respond_to :hello
12
+ end
13
+
14
+ it "should not inherit non-exposed methods" do
15
+ blog_post.should_not respond_to :hidden_hello
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc,
8
+ # in spec/support/ and its subdirectories.
9
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ # == Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+ config.mock_with :rspec
20
+
21
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
22
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
23
+
24
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
25
+ # examples within a transaction, remove the following line or assign false
26
+ # instead of true.
27
+ config.use_transactional_fixtures = true
28
+
29
+ # If true, the base class of anonymous controllers will be inferred
30
+ # automatically. This will be the default behavior in future versions of
31
+ # rspec-rails.
32
+ config.infer_base_class_for_anonymous_controllers = false
33
+ end
@@ -1,6 +1,10 @@
1
1
  module Heritage
2
2
  module ActiveRecord
3
3
  module ActsAsHeir
4
+
5
+ def child_of(parent_symbol)
6
+ acts_as_heir_of(parent_symbol)
7
+ end
4
8
 
5
9
  def acts_as_heir_of(predecessor_symbol)
6
10
  extend ClassMethods
@@ -8,9 +12,9 @@ module Heritage
8
12
 
9
13
  class_attribute :_predecessor_klass, :_predecessor_symbol
10
14
  self._predecessor_symbol = predecessor_symbol
11
- self._predecessor_klass = Object.const_get(predecessor_symbol.to_s.capitalize)
15
+ self._predecessor_klass = Object.const_get(predecessor_symbol.to_s.camelize)
12
16
 
13
- has_one :predecessor, :as => :heir, :class_name => predecessor_symbol.to_s.capitalize, :autosave => true, :dependent => :destroy
17
+ has_one :predecessor, :as => :heir, :class_name => predecessor_symbol.to_s.camelize, :autosave => true, :dependent => :destroy
14
18
 
15
19
  alias_method_chain :predecessor, :build
16
20
 
@@ -1,6 +1,10 @@
1
1
  module Heritage
2
2
  module ActiveRecord
3
3
  module ActsAsPredecessor
4
+
5
+ def parent_model(options = {})
6
+ acts_as_predecessor(options)
7
+ end
4
8
 
5
9
  def acts_as_predecessor(options = {})
6
10
  extend ClassMethods
@@ -1,3 +1,3 @@
1
1
  module Heritage
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heritage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-01 00:00:00.000000000 +01:00
13
- default_executable:
12
+ date: 2013-06-28 00:00:00.000000000 Z
14
13
  dependencies: []
15
14
  description: A gem for implementing multiple table inheritance in rails 3
16
15
  email:
@@ -21,10 +20,12 @@ extra_rdoc_files: []
21
20
  files:
22
21
  - .gitignore
23
22
  - Gemfile
23
+ - Gemfile.lock
24
24
  - README.textile
25
25
  - Rakefile
26
26
  - heritage.gemspec
27
27
  - heritage_demo/.gitignore
28
+ - heritage_demo/.rspec
28
29
  - heritage_demo/Gemfile
29
30
  - heritage_demo/Gemfile.lock
30
31
  - heritage_demo/README
@@ -91,29 +92,15 @@ files:
91
92
  - heritage_demo/public/robots.txt
92
93
  - heritage_demo/public/stylesheets/.gitkeep
93
94
  - heritage_demo/script/rails
94
- - heritage_demo/test/fixtures/blog_posts.yml
95
- - heritage_demo/test/fixtures/categories.yml
96
- - heritage_demo/test/fixtures/image_posts.yml
97
- - heritage_demo/test/fixtures/posts.yml
98
- - heritage_demo/test/functional/blog_posts_controller_test.rb
99
- - heritage_demo/test/functional/image_posts_controller_test.rb
100
- - heritage_demo/test/functional/posts_controller_test.rb
101
- - heritage_demo/test/performance/browsing_test.rb
102
- - heritage_demo/test/test_helper.rb
103
- - heritage_demo/test/unit/blog_post_test.rb
104
- - heritage_demo/test/unit/category_test.rb
105
- - heritage_demo/test/unit/helpers/blog_posts_helper_test.rb
106
- - heritage_demo/test/unit/helpers/image_posts_helper_test.rb
107
- - heritage_demo/test/unit/helpers/posts_helper_test.rb
108
- - heritage_demo/test/unit/image_post_test.rb
109
- - heritage_demo/test/unit/post_test.rb
95
+ - heritage_demo/spec/factories.rb
96
+ - heritage_demo/spec/models/blog_post_spec.rb
97
+ - heritage_demo/spec/spec_helper.rb
110
98
  - heritage_demo/vendor/plugins/.gitkeep
111
99
  - lib/heritage.rb
112
100
  - lib/heritage/active_record/acts_as_heir.rb
113
101
  - lib/heritage/active_record/acts_as_predecessor.rb
114
102
  - lib/heritage/railtie.rb
115
103
  - lib/heritage/version.rb
116
- has_rdoc: true
117
104
  homepage: http://rubygems.org/gems/heritage
118
105
  licenses: []
119
106
  post_install_message:
@@ -134,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
121
  version: '0'
135
122
  requirements: []
136
123
  rubyforge_project:
137
- rubygems_version: 1.6.2
124
+ rubygems_version: 1.8.23
138
125
  signing_key:
139
126
  specification_version: 3
140
127
  summary: A gem for implementing multiple table inheritance in rails 3
@@ -1,9 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- one:
4
- predecessor_id: 1
5
- body: MyText
6
-
7
- two:
8
- predecessor_id: 1
9
- body: MyText
@@ -1,11 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- # This model initially had no columns defined. If you add columns to the
4
- # model remove the '{}' from the fixture names and add the columns immediately
5
- # below each fixture, per the syntax in the comments below
6
- #
7
- one: {}
8
- # column: value
9
- #
10
- two: {}
11
- # column: value
@@ -1,9 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- one:
4
- predecessor_id: 1
5
- aspect: 1
6
-
7
- two:
8
- predecessor_id: 1
9
- aspect: 1
@@ -1,11 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- one:
4
- heir_id: 1
5
- heir_type: MyString
6
- title: MyString
7
-
8
- two:
9
- heir_id: 1
10
- heir_type: MyString
11
- title: MyString
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BlogPostsControllerTest < ActionController::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ImagePostsControllerTest < ActionController::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PostsControllerTest < ActionController::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/performance_test_help'
3
-
4
- # Profiling results for each test method are written to tmp/performance.
5
- class BrowsingTest < ActionDispatch::PerformanceTest
6
- def test_homepage
7
- get '/'
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rails/test_help'
4
-
5
- class ActiveSupport::TestCase
6
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
- #
8
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
- # -- they do not yet inherit this setting
10
- fixtures :all
11
-
12
- # Add more helper methods to be used by all tests here...
13
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BlogPostTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CategoryTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BlogPostsHelperTest < ActionView::TestCase
4
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ImagePostsHelperTest < ActionView::TestCase
4
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PostsHelperTest < ActionView::TestCase
4
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ImagePostTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PostTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end