mholling-active_url 0.1.2 → 0.1.3

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.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'yaml'
3
4
 
4
5
  begin
5
6
  require 'jeweler'
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :major: 0
4
4
  :minor: 1
@@ -9,11 +9,6 @@ module ActiveUrl
9
9
  def self.attribute(*attribute_names)
10
10
  options = attribute_names.extract_options!
11
11
  attribute_names.map(&:to_sym).each { |attribute_name| add_attribute(attribute_name, options) }
12
- # attribute_names.map(&:to_sym).each do |attribute_name|
13
- # attr_accessor attribute_name
14
- # self.attribute_names << attribute_name
15
- # self.accessible_attributes << attribute_name if options[:accessible]
16
- # end
17
12
  end
18
13
 
19
14
  def self.attr_accessible(*attribute_names)
@@ -60,7 +55,7 @@ module ActiveUrl
60
55
  raise RecordNotFound unless id.is_a?(String) && !id.blank?
61
56
  serialized = begin
62
57
  Crypto.decrypt(id)
63
- rescue OpenSSL::CipherError
58
+ rescue Crypto::CipherError
64
59
  raise RecordNotFound
65
60
  end
66
61
  type, attributes = YAML.load(serialized)
@@ -93,9 +88,10 @@ module ActiveUrl
93
88
  self.accessible_attributes = Set.new
94
89
 
95
90
  def self.add_attribute(attribute_name, options)
96
- attr_accessor attribute_name
97
91
  self.attribute_names << attribute_name
98
92
  self.accessible_attributes << attribute_name if options[:accessible]
93
+ public
94
+ attr_accessor attribute_name
99
95
  end
100
96
  end
101
97
 
@@ -4,6 +4,8 @@ require 'base64'
4
4
 
5
5
  module ActiveUrl
6
6
  module Crypto
7
+ CipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError
8
+
7
9
  PADDING = { 2 => "==", 3 => "=" }
8
10
 
9
11
  def self.encrypt(clear)
@@ -15,7 +15,7 @@ describe ActiveUrl do
15
15
  end
16
16
  end
17
17
 
18
- class Secret < ActiveUrl::Base
18
+ class ::Secret < ActiveUrl::Base
19
19
  belongs_to :user
20
20
  end
21
21
  end
@@ -39,7 +39,7 @@ describe ActiveUrl do
39
39
 
40
40
  context "derived" do
41
41
  before(:all) do
42
- class DerivedClass < ActiveUrl::Base
42
+ class ::DerivedClass < ActiveUrl::Base
43
43
  attribute :foo, :bar
44
44
  attribute :baz, :accessible => true
45
45
  attr_accessible :bar
@@ -50,6 +50,16 @@ describe ActiveUrl do
50
50
  end
51
51
 
52
52
  context "instance" do
53
+ it "should have individually accessible attribute readers" do
54
+ @url = DerivedClass.new
55
+ [ :foo, :bar, :baz ].each { |reader| @url.public_methods.map(&:to_sym).should include(reader) }
56
+ end
57
+
58
+ it "should have individually accessible attribute setters" do
59
+ @url = DerivedClass.new
60
+ [ :foo=, :bar=, :baz= ].each { |setter| @url.public_methods.map(&:to_sym).should include(setter) }
61
+ end
62
+
53
63
  it "should not mass-assign attributes by default" do
54
64
  @url = DerivedClass.new(:foo => "foo")
55
65
  @url.foo.should be_nil
@@ -89,7 +99,7 @@ describe ActiveUrl do
89
99
 
90
100
  context "equality" do
91
101
  before(:all) do
92
- class OtherClass < DerivedClass
102
+ class ::OtherClass < DerivedClass
93
103
  end
94
104
  end
95
105
 
@@ -7,7 +7,7 @@ describe ActiveUrl do
7
7
 
8
8
  context "instance with validations" do
9
9
  before(:all) do
10
- class Registration < ActiveUrl::Base
10
+ class ::Registration < ActiveUrl::Base
11
11
  attribute :name, :email, :password, :age, :accessible => true
12
12
  validates_presence_of :name
13
13
  validates_format_of :email, :with => /^[\w\.=-]+@[\w\.-]+\.[a-zA-Z]{2,4}$/ix
@@ -93,7 +93,7 @@ describe ActiveUrl do
93
93
  end
94
94
 
95
95
  it "should execute any after_save callbacks" do
96
- @registration.instance_variables.should include("@sent")
96
+ @registration.instance_variables.map(&:to_s).should include("@sent")
97
97
  end
98
98
 
99
99
  context "and re-found by its class" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mholling-active_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Hollingworth
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-25 00:00:00 -07:00
12
+ date: 2009-06-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency