hooks 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.textile ADDED
@@ -0,0 +1,4 @@
1
+ h2. 0.1.4
2
+
3
+ h3. Bugfixes
4
+ * An uninitialized @inheritable_attr@ doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception.
data/Gemfile CHANGED
@@ -1,8 +1 @@
1
- # A sample Gemfile
2
- source :gemcutter
3
-
4
- gem "activesupport", "~>2.3"
5
-
6
- group :test do
7
- gem "shoulda"
8
- end
1
+ gemspec
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
4
3
 
5
4
  desc 'Default: run unit tests.'
6
5
  task :default => :test
@@ -11,21 +10,3 @@ Rake::TestTask.new(:test) do |test|
11
10
  test.test_files = FileList['test/*_test.rb']
12
11
  test.verbose = true
13
12
  end
14
-
15
- require 'jeweler'
16
- $:.unshift File.dirname(__FILE__)+"/lib" # add current dir to LOAD_PATHS
17
- require 'hooks'
18
-
19
- Jeweler::Tasks.new do |spec|
20
- spec.name = "hooks"
21
- spec.version = ::Hooks::VERSION
22
- spec.summary = %{Generic hooks with callbacks for Ruby. }
23
- spec.description = "Declaratively define hooks, add callbacks and run them with the options you like."
24
- spec.homepage = "http://nicksda.apotomo.de/category/hooks"
25
- spec.authors = ["Nick Sutterer"]
26
- spec.email = "apotonick@gmail.com"
27
-
28
- spec.files = FileList["[A-Z]*", File.join(*%w[{lib} ** *]).to_s]
29
- end
30
-
31
- Jeweler::GemcutterTasks.new
data/hooks.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path('../lib/', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require 'hooks'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "hooks"
8
+ s.version = Hooks::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Nick Sutterer"]
11
+ s.email = ["apotonick@gmail.com"]
12
+ s.homepage = "http://nicksda.apotomo.de/tag/hooks"
13
+ s.summary = %q{Generic hooks with callbacks for Ruby.}
14
+ s.description = %q{Declaratively define hooks, add callbacks and run them with the options you like.}
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_development_dependency "shoulda"
21
+ end
data/lib/hooks.rb CHANGED
@@ -16,7 +16,7 @@ require "hooks/inheritable_attribute"
16
16
  #
17
17
  # cat.run_hook :after_dinner
18
18
  module Hooks
19
- VERSION = "0.1.3"
19
+ VERSION = "0.1.4"
20
20
 
21
21
  def self.included(base)
22
22
  base.extend InheritableAttribute
@@ -75,8 +75,7 @@ module Hooks
75
75
  def define_hook_writer(hook, accessor_name)
76
76
  instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
77
77
  def #{hook}(method=nil, &block)
78
- callback = block_given? ? block : method
79
- #{accessor_name} << callback
78
+ #{accessor_name} << (block || method)
80
79
  end
81
80
  RUBY_EVAL
82
81
  end
@@ -24,8 +24,8 @@ module Hooks
24
24
  end
25
25
 
26
26
  def #{name}
27
- return @#{name} unless superclass.respond_to?(:#{name})
28
- @#{name} ||= superclass.#{name}.clone # only do this once.
27
+ return @#{name} unless superclass.respond_to?(:#{name}) and value = superclass.#{name}
28
+ @#{name} ||= value.clone # only do this once.
29
29
  end
30
30
  }
31
31
  end
data/test/hooks_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class HooksTest < ActiveSupport::TestCase
3
+ class HooksTest < Test::Unit::TestCase
4
4
  context "Hooks.define_hook" do
5
5
  setup do
6
6
  @klass = Class.new(Object) do
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class HooksTest < ActiveSupport::TestCase
3
+ class HooksTest < Test::Unit::TestCase
4
4
  context "Hooks.define_hook" do
5
5
  setup do
6
6
  @klass = Class.new(Object) do
@@ -11,10 +11,16 @@ class HooksTest < ActiveSupport::TestCase
11
11
  @klass.inheritable_attr :drinks
12
12
  end
13
13
 
14
- should "provide a reader with inherited attributes, already" do
14
+ should "provide a reader with empty inherited attributes, already" do
15
15
  assert_equal nil, @klass.drinks
16
16
  end
17
17
 
18
+ should "provide a reader with empty inherited attributes in a derived class" do
19
+ assert_equal nil, Class.new(@klass).drinks
20
+ #@klass.drinks = true
21
+ #Class.new(@klass).drinks # TODO: crashes.
22
+ end
23
+
18
24
  should "provide an attribute copy in subclasses" do
19
25
  @klass.drinks = []
20
26
  assert @klass.drinks.object_id != Class.new(@klass).drinks.object_id
data/test/test_helper.rb CHANGED
@@ -5,7 +5,6 @@ require 'bundler'
5
5
  Bundler.setup
6
6
  require 'test/unit'
7
7
  require 'shoulda'
8
- require 'active_support/test_case'
9
8
  require 'hooks'
10
9
 
11
10
  $:.unshift File.dirname(__FILE__) # add current dir to LOAD_PATHS
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nick Sutterer
@@ -14,35 +14,49 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-21 00:00:00 +02:00
17
+ date: 2011-05-16 00:00:00 +02:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: shoulda
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
21
33
  description: Declaratively define hooks, add callbacks and run them with the options you like.
22
- email: apotonick@gmail.com
34
+ email:
35
+ - apotonick@gmail.com
23
36
  executables: []
24
37
 
25
38
  extensions: []
26
39
 
27
- extra_rdoc_files:
28
- - README.rdoc
40
+ extra_rdoc_files: []
41
+
29
42
  files:
43
+ - CHANGES.textile
30
44
  - Gemfile
31
- - Gemfile.lock
32
45
  - README.rdoc
33
46
  - Rakefile
47
+ - hooks.gemspec
34
48
  - lib/hooks.rb
35
49
  - lib/hooks/inheritable_attribute.rb
36
50
  - test/hooks_test.rb
37
- - test/test_helper.rb
38
51
  - test/inheritable_attribute_test.rb
52
+ - test/test_helper.rb
39
53
  has_rdoc: true
40
- homepage: http://nicksda.apotomo.de/category/hooks
54
+ homepage: http://nicksda.apotomo.de/tag/hooks
41
55
  licenses: []
42
56
 
43
57
  post_install_message:
44
- rdoc_options:
45
- - --charset=UTF-8
58
+ rdoc_options: []
59
+
46
60
  require_paths:
47
61
  - lib
48
62
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -68,7 +82,5 @@ rubygems_version: 1.3.7
68
82
  signing_key:
69
83
  specification_version: 3
70
84
  summary: Generic hooks with callbacks for Ruby.
71
- test_files:
72
- - test/hooks_test.rb
73
- - test/test_helper.rb
74
- - test/inheritable_attribute_test.rb
85
+ test_files: []
86
+
data/Gemfile.lock DELETED
@@ -1,12 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activesupport (2.3.9)
5
- shoulda (2.11.3)
6
-
7
- PLATFORMS
8
- ruby
9
-
10
- DEPENDENCIES
11
- activesupport (~> 2.3)
12
- shoulda