attribute_predicates 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  == master
2
2
 
3
+ == 0.2.1 / 2010-03-07
4
+
5
+ * Release gems via rake-gemcutter instead of rubyforge
6
+ * Fix define_method usage causing all attributes to be private in Ruby 1.9+
7
+
3
8
  == 0.2.0 / 2008-12-14
4
9
 
5
10
  * Remove the PluginAWeek namespace
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2008 Aaron Pfeifer
1
+ Copyright (c) 2006-2010 Aaron Pfeifer
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,13 +1,15 @@
1
+ require 'rubygems'
2
+ require 'rake'
1
3
  require 'rake/testtask'
2
4
  require 'rake/rdoctask'
3
5
  require 'rake/gempackagetask'
4
- require 'rake/contrib/sshpublisher'
5
6
 
6
7
  spec = Gem::Specification.new do |s|
7
8
  s.name = 'attribute_predicates'
8
- s.version = '0.2.0'
9
+ s.version = '0.2.1'
9
10
  s.platform = Gem::Platform::RUBY
10
- s.summary = 'Adds automatic generation of predicate methods for attributes.'
11
+ s.summary = 'Adds automatic generation of predicate methods for attributes'
12
+ s.description = s.summary
11
13
 
12
14
  s.files = FileList['{lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc)
13
15
  s.require_path = 'lib'
@@ -49,23 +51,30 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
49
51
  rdoc.rdoc_dir = 'rdoc'
50
52
  rdoc.title = spec.name
51
53
  rdoc.template = '../rdoc_template.rb'
52
- rdoc.options << '--line-numbers'
54
+ rdoc.options << '--line-numbers' << '--inline-source'
53
55
  rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb')
54
56
  end
55
-
57
+
58
+ desc 'Generate a gemspec file.'
59
+ task :gemspec do
60
+ File.open("#{spec.name}.gemspec", 'w') do |f|
61
+ f.write spec.to_ruby
62
+ end
63
+ end
64
+
56
65
  Rake::GemPackageTask.new(spec) do |p|
57
66
  p.gem_spec = spec
58
- p.need_tar = true
59
- p.need_zip = true
60
67
  end
61
68
 
62
69
  desc 'Publish the beta gem.'
63
70
  task :pgem => [:package] do
71
+ require 'rake/contrib/sshpublisher'
64
72
  Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{spec.name}-#{spec.version}.gem").upload
65
73
  end
66
74
 
67
75
  desc 'Publish the API documentation.'
68
76
  task :pdoc => [:rdoc] do
77
+ require 'rake/contrib/sshpublisher'
69
78
  Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{spec.name}", 'rdoc').upload
70
79
  end
71
80
 
@@ -74,15 +83,8 @@ task :publish => [:pgem, :pdoc, :release]
74
83
 
75
84
  desc 'Publish the release files to RubyForge.'
76
85
  task :release => [:gem, :package] do
77
- require 'rubyforge'
78
-
79
- ruby_forge = RubyForge.new.configure
80
- ruby_forge.login
86
+ require 'rake/gemcutter'
81
87
 
82
- %w(gem tgz zip).each do |ext|
83
- file = "pkg/#{spec.name}-#{spec.version}.#{ext}"
84
- puts "Releasing #{File.basename(file)}..."
85
-
86
- ruby_forge.add_release(spec.rubyforge_project, spec.name, spec.version, file)
87
- end
88
+ Rake::Gemcutter::Tasks.new(spec)
89
+ Rake::Task['gem:push'].invoke
88
90
  end
@@ -55,21 +55,21 @@ module AttributePredicates
55
55
  end
56
56
  end
57
57
 
58
- private
59
- # Returns true if the specified variable is not blank, otherwise false
60
- def attr_predicate(symbol)
61
- define_method("#{symbol}?") do
62
- value = instance_variable_get("@#{symbol}")
63
- if value.respond_to?(:blank?)
64
- # Use ActiveSupport's implementation
65
- !value.blank?
66
- elsif value.respond_to?(:empty?)
67
- !value.empty?
68
- else
69
- !!value
70
- end
58
+ # Returns true if the specified variable is not blank, otherwise false
59
+ def attr_predicate(symbol)
60
+ define_method("#{symbol}?") do
61
+ value = instance_variable_get("@#{symbol}")
62
+ if value.respond_to?(:blank?)
63
+ # Use ActiveSupport's implementation
64
+ !value.blank?
65
+ elsif value.respond_to?(:empty?)
66
+ !value.empty?
67
+ else
68
+ !!value
71
69
  end
72
70
  end
71
+ end
72
+ private :attr_predicate
73
73
  end
74
74
  end
75
75
  end
@@ -16,18 +16,18 @@ class ModuleAttrTest < Test::Unit::TestCase
16
16
  def test_should_create_predicate_for_readonly_attr
17
17
  @module.attr(:foo)
18
18
  %w(foo foo?).each do |method|
19
- assert @module.instance_methods.include?(method), "#{method} does not exist"
19
+ assert @module.method_defined?(method), "#{method} does not exist"
20
20
  end
21
21
 
22
22
  %w(foo=).each do |method|
23
- assert !@module.instance_methods.include?(method), "#{method} exists"
23
+ assert !@module.method_defined?(method), "#{method} exists"
24
24
  end
25
25
  end
26
26
 
27
27
  def test_should_create_predicate_for_readwrite_attr
28
28
  @module.attr(:foo, true)
29
29
  %w(foo foo= foo?).each do |method|
30
- assert @module.instance_methods.include?(method), "#{method} does not exist"
30
+ assert @module.method_defined?(method), "#{method} does not exist"
31
31
  end
32
32
  end
33
33
  end
@@ -40,22 +40,22 @@ class ModuleAttrReaderTest < Test::Unit::TestCase
40
40
  def test_should_create_predicate
41
41
  @module.attr_reader(:foo)
42
42
  %w(foo foo?).each do |method|
43
- assert @module.instance_methods.include?(method), "#{method} does not exist"
43
+ assert @module.method_defined?(method), "#{method} does not exist"
44
44
  end
45
45
 
46
46
  %w(foo=).each do |method|
47
- assert !@module.instance_methods.include?(method), "#{method} exists"
47
+ assert !@module.method_defined?(method), "#{method} exists"
48
48
  end
49
49
  end
50
50
 
51
51
  def test_should_create_predicate_for_multiple_attributes
52
52
  @module.attr_reader(:foo, :bar)
53
53
  %w(foo foo? bar bar?).each do |method|
54
- assert @module.instance_methods.include?(method), "#{method} does not exist"
54
+ assert @module.method_defined?(method), "#{method} does not exist"
55
55
  end
56
56
 
57
57
  %w(foo= bar=).each do |method|
58
- assert !@module.instance_methods.include?(method), "#{method} exists"
58
+ assert !@module.method_defined?(method), "#{method} exists"
59
59
  end
60
60
  end
61
61
  end
@@ -68,14 +68,14 @@ class ModuleAttrAccessorTest < Test::Unit::TestCase
68
68
  def test_should_create_predicate
69
69
  @module.attr_accessor(:foo)
70
70
  %w(foo foo= foo?).each do |method|
71
- assert @module.instance_methods.include?(method), "#{method} does not exist"
71
+ assert @module.method_defined?(method), "#{method} does not exist"
72
72
  end
73
73
  end
74
74
 
75
75
  def test_should_create_predicate_for_multiple_attributes
76
76
  @module.attr_accessor(:foo, :bar)
77
77
  %w(foo foo= foo? bar bar= bar?).each do |method|
78
- assert @module.instance_methods.include?(method), "#{method} does not exist"
78
+ assert @module.method_defined?(method), "#{method} does not exist"
79
79
  end
80
80
  end
81
81
  end
@@ -88,22 +88,22 @@ class ModuleAttrWriterTest < Test::Unit::TestCase
88
88
  def test_should_create_predicate
89
89
  @module.attr_writer(:foo)
90
90
  %w(foo= foo?).each do |method|
91
- assert @module.instance_methods.include?(method), "#{method} does not exist"
91
+ assert @module.method_defined?(method), "#{method} does not exist"
92
92
  end
93
93
 
94
94
  %w(foo).each do |method|
95
- assert !@module.instance_methods.include?(method), "#{method} exists"
95
+ assert !@module.method_defined?(method), "#{method} exists"
96
96
  end
97
97
  end
98
98
 
99
99
  def test_should_create_predicate_for_multiple_attributes
100
100
  @module.attr_writer(:foo, :bar)
101
101
  %w(foo= foo? bar= bar?).each do |method|
102
- assert @module.instance_methods.include?(method), "#{method} does not exist"
102
+ assert @module.method_defined?(method), "#{method} does not exist"
103
103
  end
104
104
 
105
105
  %w(foo bar).each do |method|
106
- assert !@module.instance_methods.include?(method), "#{method} exists"
106
+ assert !@module.method_defined?(method), "#{method} exists"
107
107
  end
108
108
  end
109
109
  end
@@ -115,7 +115,7 @@ class ModuleAttrPredicateTest < Test::Unit::TestCase
115
115
 
116
116
  def test_should_create_predicate
117
117
  @module.attr_predicate(:foo)
118
- assert @module.instance_methods.include?('foo?'), 'foo? does not exist'
118
+ assert @module.method_defined?('foo?'), 'foo? does not exist'
119
119
  end
120
120
  end
121
121
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute_predicates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-14 00:00:00 -05:00
12
+ date: 2010-03-07 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description:
16
+ description: Adds automatic generation of predicate methods for attributes
17
17
  email: aaron@pluginaweek.org
18
18
  executables: []
19
19
 
@@ -22,14 +22,12 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - lib/attribute_predicates.rb
26
- - lib/attribute_predicates
27
- - lib/attribute_predicates/extensions
28
25
  - lib/attribute_predicates/extensions/module.rb
29
26
  - lib/attribute_predicates/extensions/active_record.rb
27
+ - lib/attribute_predicates.rb
28
+ - test/active_record_test.rb
30
29
  - test/test_helper.rb
31
30
  - test/module_test.rb
32
- - test/active_record_test.rb
33
31
  - CHANGELOG.rdoc
34
32
  - init.rb
35
33
  - LICENSE
@@ -37,6 +35,8 @@ files:
37
35
  - README.rdoc
38
36
  has_rdoc: true
39
37
  homepage: http://www.pluginaweek.org
38
+ licenses: []
39
+
40
40
  post_install_message:
41
41
  rdoc_options: []
42
42
 
@@ -57,10 +57,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  requirements: []
58
58
 
59
59
  rubyforge_project: pluginaweek
60
- rubygems_version: 1.2.0
60
+ rubygems_version: 1.3.5
61
61
  signing_key:
62
- specification_version: 2
63
- summary: Adds automatic generation of predicate methods for attributes.
62
+ specification_version: 3
63
+ summary: Adds automatic generation of predicate methods for attributes
64
64
  test_files:
65
- - test/module_test.rb
66
65
  - test/active_record_test.rb
66
+ - test/module_test.rb