attr_immutable 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,31 @@
1
+ = Description
2
+
3
+ A simple class method to create immutable attributes in the style or attr_attributes, attr_reader, attr_writer, etc.
4
+
5
+ = Requirements
6
+
7
+ JRuby
8
+
9
+ = Usage
10
+
11
+ Install the gem:
12
+
13
+ gem install attr_immutable
14
+
15
+ Run the code:
16
+
17
+ class ImmutableFoo
18
+ attr_immutable :foo
19
+
20
+ end
21
+
22
+ foo = Foo.new
23
+ foo.foo = 'Set the value'
24
+ foo.foo = 'Oops! This will raise an error' # <= This will raise a runtime error.
25
+
26
+ = History
27
+
28
+ SimpleWorkQueue is a fork of WorkQueue by Miguel Fonseca. SimpleWorkQueue removes the time out and bounded task queue.
29
+ The timeout created issues under the concurrency implementation in JRuby. The time out mechanism was replaced using a
30
+ non-blocking queue from the java.util.concurrent library. If a worker thread attempts to remove a task from the task queue
31
+ and it is empty it will exit the worker thread.
@@ -17,4 +17,5 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
+ s.add_development_dependency "rspec", "~> 2.6"
20
21
  end
@@ -1,3 +1,3 @@
1
1
  module AttrImmutable
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'attr_immutable'
2
+
3
+ class TestClass
4
+ include AttrImmutable
5
+ attr_immutable :immutable_attr
6
+ end
7
+
8
+ describe 'attr_immutable' do
9
+ it "attributes should be nil unless set" do
10
+ test_object = TestClass.new
11
+ test_object.immutable_attr.should be_nil
12
+ end
13
+
14
+ it "can be set once and read" do
15
+ test_object = TestClass.new
16
+ test_object.immutable_attr = 'foo'
17
+ test_object.immutable_attr.should == 'foo'
18
+ end
19
+
20
+ it "should raise an exception if an attr_immutable is set a second time" do
21
+ test_object = TestClass.new
22
+ test_object.immutable_attr = 'foo'
23
+ lambda { test_object.immutable_attr = 'foo' }.should raise_error
24
+ end
25
+ end
metadata CHANGED
@@ -1,60 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: attr_immutable
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
4
5
  prerelease:
5
- version: 0.0.1
6
6
  platform: ruby
7
- authors:
8
- - Mark Menard
7
+ authors:
8
+ - Mark Menard
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-04 00:00:00 Z
14
- dependencies: []
15
-
16
- description: AttrImmutable add the attr_immutable class method to create immutable properties on Ruby classes. The attribute are only accessible using the accessor/mutator pair by hiding the attribute value using a closure. (ie. the immutable attribute is not stored in an instance variable and therefore can't accessed in any other way.)
17
- email:
18
- - mark@mjm.net
12
+ date: 2011-09-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &2161552580 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.6'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2161552580
25
+ description: AttrImmutable add the attr_immutable class method to create immutable
26
+ properties on Ruby classes. The attribute are only accessible using the accessor/mutator
27
+ pair by hiding the attribute value using a closure. (ie. the immutable attribute
28
+ is not stored in an instance variable and therefore can't accessed in any other
29
+ way.)
30
+ email:
31
+ - mark@mjm.net
19
32
  executables: []
20
-
21
33
  extensions: []
22
-
23
34
  extra_rdoc_files: []
24
-
25
- files:
26
- - .gitignore
27
- - Gemfile
28
- - Rakefile
29
- - attr_immutable.gemspec
30
- - lib/attr_immutable.rb
31
- - lib/attr_immutable/version.rb
32
- homepage: ""
35
+ files:
36
+ - .gitignore
37
+ - Gemfile
38
+ - README.rdoc
39
+ - Rakefile
40
+ - attr_immutable.gemspec
41
+ - lib/attr_immutable.rb
42
+ - lib/attr_immutable/version.rb
43
+ - spec/attr_immuable_spec.rb
44
+ homepage: ''
33
45
  licenses: []
34
-
35
46
  post_install_message:
36
47
  rdoc_options: []
37
-
38
- require_paths:
39
- - lib
40
- required_ruby_version: !ruby/object:Gem::Requirement
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
41
51
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
46
- required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
57
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
52
62
  requirements: []
53
-
54
63
  rubyforge_project: attr_immutable
55
64
  rubygems_version: 1.8.7
56
65
  signing_key:
57
66
  specification_version: 3
58
- summary: Add attr_immutable to create immutable protected attributes on your Ruby classes.
59
- test_files: []
60
-
67
+ summary: Add attr_immutable to create immutable protected attributes on your Ruby
68
+ classes.
69
+ test_files:
70
+ - spec/attr_immuable_spec.rb