freeze-ray 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ pkg/*
2
+ spec/spec.opts
@@ -1,3 +1,10 @@
1
- === 0.4.0 :: 2009-05-29
1
+ === 0.0.2 :: 2009-06-02
2
+
3
+ * Add rails/init.rb, which was left out of the last release.
4
+ * Make freeze-ray actually play well with the way ActiveRecord defines
5
+ accessors. Things should work well enough to be useful now.
6
+
7
+
8
+ === 0.0.1 :: 2009-05-29
2
9
 
3
10
  * Initial release.
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |s|
4
+ s.name = "freeze-ray"
5
+ s.summary = "Fixes ActiveRecord's dirty tracking."
6
+ s.description = "Fixes ActiveRecord's dirty tracking. Provides an attr_frozen macro which causes an attribute to be returned frozen."
7
+ s.authors = ["Peter Jaros"]
8
+ s.email = "peter.a.jaros@gmail.com"
9
+ s.rubyforge_project = "freeze-ray"
10
+ end
11
+ rescue LoadError
12
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
13
+ end
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -0,0 +1,45 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{freeze-ray}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Peter Jaros"]
9
+ s.date = %q{2009-06-02}
10
+ s.description = %q{Fixes ActiveRecord's dirty tracking. Provides an attr_frozen macro which causes an attribute to be returned frozen.}
11
+ s.email = %q{peter.a.jaros@gmail.com}
12
+ s.extra_rdoc_files = [
13
+ "README.markdown"
14
+ ]
15
+ s.files = [
16
+ ".gitignore",
17
+ "History.txt",
18
+ "README.markdown",
19
+ "Rakefile",
20
+ "VERSION.yml",
21
+ "freeze-ray.gemspec",
22
+ "lib/freeze_ray.rb",
23
+ "rails/init.rb",
24
+ "spec/freeze_ray_spec.rb"
25
+ ]
26
+ s.has_rdoc = true
27
+ s.rdoc_options = ["--charset=UTF-8"]
28
+ s.require_paths = ["lib"]
29
+ s.rubyforge_project = %q{freeze-ray}
30
+ s.rubygems_version = %q{1.3.1}
31
+ s.summary = %q{Fixes ActiveRecord's dirty tracking.}
32
+ s.test_files = [
33
+ "spec/freeze_ray_spec.rb"
34
+ ]
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 2
39
+
40
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
41
+ else
42
+ end
43
+ else
44
+ end
45
+ end
@@ -1,8 +1,9 @@
1
1
  module FreezeRay
2
2
  def attr_frozen(*attrs)
3
3
  attrs.each do |attr|
4
+ old_getter = instance_method(attr)
4
5
  define_method(attr) do
5
- super.freeze
6
+ old_getter.bind(self).call.freeze
6
7
  end
7
8
  end
8
9
  end
@@ -0,0 +1,3 @@
1
+ require 'freeze_ray'
2
+
3
+ ActiveRecord::Base.extend FreezeRay
@@ -14,10 +14,16 @@ require File.dirname(__FILE__) + "/../rails/init"
14
14
  describe "attr_frozen" do
15
15
  before(:each) do
16
16
  build_model :things do
17
- string :string_attribute, :default => "foobar"
17
+ string :string_attribute
18
18
  string :serialized_attribute
19
+ string :overridden_attribute
20
+
19
21
  serialize :serialized_attribute
20
22
 
23
+ def overridden_attribute
24
+ [super]
25
+ end
26
+
21
27
  # Turn off acts_as_foo's method_missing extension for schema
22
28
  # definition. For some reason, it delegates #define_method to
23
29
  # the table definition.
@@ -25,17 +31,20 @@ describe "attr_frozen" do
25
31
  alias_method :method_missing, :method_missing_without_columns
26
32
  end
27
33
 
28
- attr_frozen :string_attribute, :serialized_attribute
34
+ define_attribute_methods
35
+ attr_frozen :string_attribute, :serialized_attribute, :overridden_attribute
29
36
  end
30
37
  end
31
38
 
32
39
  describe "freezes attributes which are" do
33
40
  before do
34
41
  @thing = Thing.new(:string_attribute => "foobar",
35
- :serialized_attribute => [:a, :b, :c])
42
+ :serialized_attribute => [:a, :b, :c],
43
+ :overridden_attribute => "bazbax")
36
44
  end
37
45
 
38
- specify("strings") { @thing.string_attribute.should be_frozen }
46
+ specify("strings") { @thing.string_attribute.should be_frozen }
39
47
  specify("serialized") { @thing.serialized_attribute.should be_frozen }
48
+ specify("overridden") { @thing.overridden_attribute.should be_frozen }
40
49
  end
41
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freeze-ray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Jaros
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-29 00:00:00 -04:00
12
+ date: 2009-06-02 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -19,19 +19,22 @@ executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files: []
23
-
22
+ extra_rdoc_files:
23
+ - README.markdown
24
24
  files:
25
+ - .gitignore
25
26
  - History.txt
26
27
  - README.markdown
28
+ - Rakefile
27
29
  - VERSION.yml
30
+ - freeze-ray.gemspec
28
31
  - lib/freeze_ray.rb
32
+ - rails/init.rb
29
33
  - spec/freeze_ray_spec.rb
30
34
  has_rdoc: true
31
35
  homepage:
32
36
  post_install_message:
33
37
  rdoc_options:
34
- - --inline-source
35
38
  - --charset=UTF-8
36
39
  require_paths:
37
40
  - lib
@@ -54,5 +57,5 @@ rubygems_version: 1.3.1
54
57
  signing_key:
55
58
  specification_version: 2
56
59
  summary: Fixes ActiveRecord's dirty tracking.
57
- test_files: []
58
-
60
+ test_files:
61
+ - spec/freeze_ray_spec.rb