classy-inheritance 0.6.2 → 0.6.4

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.
@@ -0,0 +1,54 @@
1
+
2
+ if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
3
+ require 'spec/rake/verify_rcov'
4
+
5
+ namespace :spec do
6
+
7
+ desc 'Run all specs with basic output'
8
+ Spec::Rake::SpecTask.new(:run) do |t|
9
+ t.ruby_opts = PROJ.ruby_opts
10
+ t.spec_opts = PROJ.spec.opts
11
+ t.spec_files = PROJ.spec.files
12
+ t.libs += PROJ.libs
13
+ end
14
+
15
+ desc 'Run all specs with text output'
16
+ Spec::Rake::SpecTask.new(:specdoc) do |t|
17
+ t.ruby_opts = PROJ.ruby_opts
18
+ t.spec_opts = PROJ.spec.opts + ['--format', 'specdoc']
19
+ t.spec_files = PROJ.spec.files
20
+ t.libs += PROJ.libs
21
+ end
22
+
23
+ if HAVE_RCOV
24
+ desc 'Run all specs with RCov'
25
+ Spec::Rake::SpecTask.new(:rcov) do |t|
26
+ t.ruby_opts = PROJ.ruby_opts
27
+ t.spec_opts = PROJ.spec.opts
28
+ t.spec_files = PROJ.spec.files
29
+ t.libs += PROJ.libs
30
+ t.rcov = true
31
+ t.rcov_dir = PROJ.rcov.dir
32
+ t.rcov_opts = PROJ.rcov.opts + ['--exclude', 'spec']
33
+ end
34
+
35
+ RCov::VerifyTask.new(:verify) do |t|
36
+ t.threshold = PROJ.rcov.threshold
37
+ t.index_html = File.join(PROJ.rcov.dir, 'index.html')
38
+ t.require_exact_threshold = PROJ.rcov.threshold_exact
39
+ end
40
+
41
+ task :verify => :rcov
42
+ remove_desc_for_task %w(spec:clobber_rcov)
43
+ end
44
+
45
+ end # namespace :spec
46
+
47
+ desc 'Alias to spec:run'
48
+ task :spec => 'spec:run'
49
+
50
+ task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
51
+
52
+ end # if HAVE_SPEC_RAKE_SPECTASK
53
+
54
+ # EOF
@@ -0,0 +1,47 @@
1
+
2
+ if HAVE_SVN
3
+
4
+ unless PROJ.svn.root
5
+ info = %x/svn info ./
6
+ m = %r/^Repository Root:\s+(.*)$/.match(info)
7
+ PROJ.svn.root = (m.nil? ? '' : m[1])
8
+ end
9
+ PROJ.svn.root = File.join(PROJ.svn.root, PROJ.svn.path) unless PROJ.svn.path.empty?
10
+
11
+ namespace :svn do
12
+
13
+ # A prerequisites task that all other tasks depend upon
14
+ task :prereqs
15
+
16
+ desc 'Show tags from the SVN repository'
17
+ task :show_tags => 'svn:prereqs' do |t|
18
+ tags = %x/svn list #{File.join(PROJ.svn.root, PROJ.svn.tags)}/
19
+ tags.gsub!(%r/\/$/, '')
20
+ tags = tags.split("\n").sort {|a,b| b <=> a}
21
+ puts tags
22
+ end
23
+
24
+ desc 'Create a new tag in the SVN repository'
25
+ task :create_tag => 'svn:prereqs' do |t|
26
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
27
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
28
+
29
+ svn = PROJ.svn
30
+ trunk = File.join(svn.root, svn.trunk)
31
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
32
+ tag = File.join(svn.root, svn.tags, tag)
33
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
34
+
35
+ puts "Creating SVN tag '#{tag}'"
36
+ unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
37
+ abort "Tag creation failed"
38
+ end
39
+ end
40
+
41
+ end # namespace :svn
42
+
43
+ task 'gem:release' => 'svn:create_tag'
44
+
45
+ end # if PROJ.svn.path
46
+
47
+ # EOF
@@ -0,0 +1,40 @@
1
+
2
+ if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+
7
+ Rake::TestTask.new(:run) do |t|
8
+ t.libs = PROJ.libs
9
+ t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
10
+ else PROJ.test.files end
11
+ t.ruby_opts += PROJ.ruby_opts
12
+ t.ruby_opts += PROJ.test.opts
13
+ end
14
+
15
+ if HAVE_RCOV
16
+ desc 'Run rcov on the unit tests'
17
+ task :rcov => :clobber_rcov do
18
+ opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
19
+ opts = opts.join(' ')
20
+ files = if test(?f, PROJ.test.file) then [PROJ.test.file]
21
+ else PROJ.test.files end
22
+ files = files.join(' ')
23
+ sh "#{RCOV} #{files} #{opts}"
24
+ end
25
+
26
+ task :clobber_rcov do
27
+ rm_r 'coverage' rescue nil
28
+ end
29
+ end
30
+
31
+ end # namespace :test
32
+
33
+ desc 'Alias to test:run'
34
+ task :test => 'test:run'
35
+
36
+ task :clobber => 'test:clobber_rcov' if HAVE_RCOV
37
+
38
+ end
39
+
40
+ # EOF
@@ -8,10 +8,6 @@ class TestClassyInheritance < Test::Unit::TestCase
8
8
  @user = User.new
9
9
  end
10
10
 
11
- def test_active_record_should_have_classy_inheritance_included
12
- assert ActiveRecord::Base.included_modules.include?(Stonean::ClassyInheritance)
13
- end
14
-
15
11
  def test_active_record_should_respond_to_depends_on
16
12
  assert ActiveRecord::Base.respond_to?(:depends_on)
17
13
  end
@@ -57,5 +53,14 @@ class TestClassyInheritance < Test::Unit::TestCase
57
53
 
58
54
  assert @user.valid?
59
55
  end
56
+
57
+ def test_user_should_have_nice_error_message
58
+ @user = User.new(:first_name => "andy")
59
+ @user.valid?
60
+
61
+ assert @user.errors.full_messages.include?("Last name can't be blank")
62
+ assert @user.errors.full_messages.include?("Email can't be blank")
63
+ assert @user.errors.full_messages.include?("Login can't be blank")
64
+ end
60
65
 
61
66
  end
@@ -46,6 +46,8 @@ class SetupTestTables < ActiveRecord::Migration
46
46
  t.string :city
47
47
  t.string :state_code
48
48
  t.string :postal_code
49
+ t.string :owner_type
50
+ t.integer :owner_id
49
51
 
50
52
  t.timestamps
51
53
  end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestWithClassNameEndingWithSS < Test::Unit::TestCase
4
+ def test_should_be_able_to_set_class_names_ending_with_ss
5
+ assert_nothing_raised do
6
+ User.depends_on :address, :as => :owner, :attrs => [:city], :class_name => "Address"
7
+ end
8
+ end
9
+ end
10
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classy-inheritance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone
@@ -9,22 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-25 00:00:00 -04:00
12
+ date: 2009-02-06 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hoe
16
+ name: bones
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.7.0
23
+ version: 2.4.0
24
24
  version:
25
- description: Adds a depends_on class method to your ActiveRecord model so that you can define requisite objects.
26
- email:
27
- - andy@stonean.com
25
+ description: "Classy Inheritance adds a depends_on class method to your ActiveRecord model so that you can define requisite objects. This functionality is provided using the existing ActiveRecord methods without monkey patching any core code. Essentially, it provides an easy interface to generate code that anyone could add to their model to receive the same result. Depending on the parameters to your depends_on call, it may add some of the following methods: validates_presence_of, validates_associated, has_one or belongs_to."
26
+ email: andy@stonean.com
28
27
  executables: []
29
28
 
30
29
  extensions: []
@@ -33,39 +32,38 @@ extra_rdoc_files:
33
32
  - History.txt
34
33
  - License.txt
35
34
  - Manifest.txt
36
- - PostInstall.txt
37
35
  - README.txt
38
- - website/index.txt
39
36
  files:
37
+ - .gitignore
40
38
  - History.txt
41
39
  - License.txt
42
40
  - Manifest.txt
43
- - PostInstall.txt
44
- - README
45
41
  - README.txt
46
42
  - Rakefile
47
- - config/hoe.rb
48
- - config/requirements.rb
49
43
  - lib/classy-inheritance.rb
50
- - lib/classy-inheritance/version.rb
51
- - script/console
52
- - script/destroy
53
- - script/generate
54
- - script/txt2html
55
- - setup.rb
56
- - tasks/deployment.rake
57
- - tasks/environment.rake
58
- - tasks/website.rake
44
+ - tasks/ann.rake
45
+ - tasks/bones.rake
46
+ - tasks/gem.rake
47
+ - tasks/git.rake
48
+ - tasks/notes.rake
49
+ - tasks/post_load.rake
50
+ - tasks/rdoc.rake
51
+ - tasks/rubyforge.rake
52
+ - tasks/setup.rb
53
+ - tasks/spec.rake
54
+ - tasks/svn.rake
55
+ - tasks/test.rake
56
+ - test/database.sqlite3
59
57
  - test/test_classy-inheritance.rb
60
58
  - test/test_helper.rb
61
- - website/index.html
62
- - website/index.txt
63
- - website/javascripts/rounded_corners_lite.inc.js
64
- - website/stylesheets/screen.css
65
- - website/template.html.erb
59
+ - test/test_polymorphic_associations.rb
60
+ - test/test_with_class_name_ending_with_ss.rb
61
+ - test/test_with_optional_dependency.rb
62
+ - test/test_with_prefix_postfix.rb
63
+ - test/test_with_standard_attributes.rb
66
64
  has_rdoc: true
67
- homepage: http://classyinherit.rubyforge.org
68
- post_install_message: ""
65
+ homepage: http://stonean.com/wiki/classy-inheritance
66
+ post_install_message:
69
67
  rdoc_options:
70
68
  - --main
71
69
  - README.txt
@@ -86,14 +84,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
84
  requirements: []
87
85
 
88
86
  rubyforge_project: classyinherit
89
- rubygems_version: 1.2.0
87
+ rubygems_version: 1.3.1
90
88
  signing_key:
91
89
  specification_version: 2
92
- summary: Adds a depends_on class method to your ActiveRecord model so that you can define requisite objects.
90
+ summary: Classy Inheritance adds a depends_on class method to your ActiveRecord model so that you can define requisite objects
93
91
  test_files:
94
92
  - test/test_classy-inheritance.rb
95
93
  - test/test_helper.rb
96
94
  - test/test_polymorphic_associations.rb
95
+ - test/test_with_class_name_ending_with_ss.rb
97
96
  - test/test_with_optional_dependency.rb
98
97
  - test/test_with_prefix_postfix.rb
99
98
  - test/test_with_standard_attributes.rb
File without changes
data/README DELETED
File without changes
@@ -1,75 +0,0 @@
1
- require 'classy-inheritance/version'
2
-
3
- AUTHOR = 'Andrew Stone' # can also be an array of Authors
4
- EMAIL = "andy@stonean.com"
5
- DESCRIPTION = "Adds a depends_on class method to your ActiveRecord model so that you can define requisite objects."
6
- GEM_NAME = 'classy-inheritance' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'classyinherit' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
- EXTRA_DEPENDENCIES = [
11
- # ['activesupport', '>= 1.3.1']
12
- ] # An array of rubygem dependencies [name, version]
13
-
14
- @config_file = "~/.rubyforge/user-config.yml"
15
- @config = nil
16
- RUBYFORGE_USERNAME = "astone"
17
- def rubyforge_username
18
- unless @config
19
- begin
20
- @config = YAML.load(File.read(File.expand_path(@config_file)))
21
- rescue
22
- puts <<-EOS
23
- ERROR: No rubyforge config file found: #{@config_file}
24
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
- - See http://newgem.rubyforge.org/rubyforge.html for more details
26
- EOS
27
- exit
28
- end
29
- end
30
- RUBYFORGE_USERNAME.replace @config["username"]
31
- end
32
-
33
-
34
- REV = nil
35
- # UNCOMMENT IF REQUIRED:
36
- # REV = YAML.load(`svn info`)['Revision']
37
- VERS = ClassyInheritance::VERSION::STRING + (REV ? ".#{REV}" : "")
38
- RDOC_OPTS = ['--quiet', '--title', 'classy-inheritance documentation',
39
- "--opname", "index.html",
40
- "--line-numbers",
41
- "--main", "README",
42
- "--inline-source"]
43
-
44
- class Hoe
45
- def extra_deps
46
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
- @extra_deps
48
- end
49
- end
50
-
51
- # Generate all the Rake tasks
52
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
- $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
- p.developer(AUTHOR, EMAIL)
55
- p.description = DESCRIPTION
56
- p.summary = DESCRIPTION
57
- p.url = HOMEPATH
58
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
- p.test_globs = ["test/**/test_*.rb"]
60
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
-
62
- # == Optional
63
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
- #p.extra_deps = EXTRA_DEPENDENCIES
65
-
66
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
- end
68
-
69
- CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
- #PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
- PATH = RUBYFORGE_PROJECT
72
- $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
73
- #$hoe.rsync_args = '-av --delete --ignore-errors'
74
- $hoe.rsync_args = '-av --delete'
75
- $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -1,15 +0,0 @@
1
- require 'fileutils'
2
- include FileUtils
3
-
4
- require 'rubygems'
5
- %w[rake hoe newgem rubigen].each do |req_gem|
6
- begin
7
- require req_gem
8
- rescue LoadError
9
- puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
- puts "Installation: gem install #{req_gem} -y"
11
- exit
12
- end
13
- end
14
-
15
- $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -1,9 +0,0 @@
1
- module ClassyInheritance #:nodoc:
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 6
5
- TINY = 2
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/classy-inheritance.rb'}"
9
- puts "Loading classy-inheritance gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)