attr_pow 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff24535e335f5339430339f64f857cf53cd84914
4
- data.tar.gz: 8b762e6dfa289d233a8277695d27a42513bf29c3
3
+ metadata.gz: 444d640c544bd7ced939501f03746ea8ea93e623
4
+ data.tar.gz: 95f54176ad16f8517096166be03a171c305905cc
5
5
  SHA512:
6
- metadata.gz: 35a3e923b6cec3e7aa890a5241d88a3a4f807367d13b47aa7896fcee8b434d581bb06aa772405e181e61761b5e6ebbc2c400289db2efe104eaccb8b1526a1e7a
7
- data.tar.gz: c65bd7a001a42a33eefbaea5bd46261389ded1fedc2da203df55f0aaca60e0cdc7441a23fbf19bf12dd43ae844a37d6f3e2b5864459b74f58a9ac173853ed75d
6
+ metadata.gz: 831b4c525fa2139598c9d99449c8da2d0533365c8a672d5d8dd1a20200f462aefaf7937814a2823297347e80af5a303344e4c77b267ce04905c29a8f5286a9d5
7
+ data.tar.gz: d41be0fcb0388a9a2c5d41e35b7dbc7af6b16d5ea4a7055798edd7cffb230b3a35fee8d1d4271a4de995982d757818c65496b25df11b3e748291bfd901f371d1
data/.semver CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 1
4
+ :patch: 2
5
5
  :special: ''
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.5
4
+ - 2.3.1
5
+ - 2.4.0
6
+ - 2.4.1
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ gem "deep_dive", "~> 0"
6
6
 
7
7
  group :development do
8
8
  gem "awesome_print", "~> 1"
9
- gem "rspec", "~> 3"
10
9
  gem "yard", "~> 0"
11
10
  gem "rdoc", "~> 3"
12
11
  gem "bundler", "~> 1"
@@ -19,3 +18,8 @@ group :development do
19
18
  gem "pry-rescue", "~> 1"
20
19
  gem "pry-stack_explorer", "~> 0"
21
20
  end
21
+
22
+ group :test, :development do
23
+ gem "rspec", "~> 3"
24
+ gem 'rake'
25
+ end
data/Gemfile.lock CHANGED
@@ -3,7 +3,7 @@ GEM
3
3
  specs:
4
4
  addressable (2.4.0)
5
5
  aquarium (0.5.1)
6
- awesome_print (1.7.0)
6
+ awesome_print (1.8.0)
7
7
  binding_of_caller (0.7.2)
8
8
  debug_inspector (>= 0.0.1)
9
9
  builder (3.2.3)
@@ -29,31 +29,31 @@ GEM
29
29
  highline (1.7.8)
30
30
  interception (0.5)
31
31
  json (1.8.6)
32
- juwelier (2.4.1)
32
+ juwelier (2.4.7)
33
33
  builder
34
- bundler (>= 1.13)
35
- git (>= 1.2.5)
34
+ bundler
35
+ git
36
36
  github_api
37
- highline (>= 1.6.15)
37
+ highline
38
38
  kamelcase (~> 0)
39
- nokogiri (>= 1.5.10)
40
- psych (~> 2.2)
39
+ nokogiri
40
+ psych
41
41
  rake
42
42
  rdoc
43
43
  semver2
44
44
  jwt (1.5.6)
45
- kamelcase (0.0.0)
45
+ kamelcase (0.0.1)
46
46
  semver2 (~> 3)
47
47
  method_source (0.8.2)
48
48
  mime-types (2.99.3)
49
- mini_portile2 (2.1.0)
49
+ mini_portile2 (2.2.0)
50
50
  multi_json (1.12.1)
51
51
  multi_xml (0.6.0)
52
52
  multipart-post (2.0.0)
53
- nokogiri (1.7.2)
54
- mini_portile2 (~> 2.1.0)
55
- oauth2 (1.3.1)
56
- faraday (>= 0.8, < 0.12)
53
+ nokogiri (1.8.0)
54
+ mini_portile2 (~> 2.2.0)
55
+ oauth2 (1.4.0)
56
+ faraday (>= 0.8, < 0.13)
57
57
  jwt (~> 1.0)
58
58
  multi_json (~> 1.3)
59
59
  multi_xml (~> 0.5)
@@ -81,7 +81,7 @@ GEM
81
81
  queue_ding (0.1.3)
82
82
  aquarium (~> 0)
83
83
  semver (~> 1)
84
- rack (2.0.2)
84
+ rack (2.0.3)
85
85
  rake (12.0.0)
86
86
  rdoc (3.12.2)
87
87
  json (~> 1.4)
@@ -104,7 +104,7 @@ GEM
104
104
  docile (~> 1.1.0)
105
105
  json (>= 1.8, < 3)
106
106
  simplecov-html (~> 0.10.0)
107
- simplecov-html (0.10.0)
107
+ simplecov-html (0.10.1)
108
108
  slop (3.6.0)
109
109
  thread_safe (0.3.6)
110
110
  yard (0.9.9)
@@ -124,6 +124,7 @@ DEPENDENCIES
124
124
  pry-rescue (~> 1)
125
125
  pry-stack_explorer (~> 0)
126
126
  queue_ding (~> 0)
127
+ rake
127
128
  rdoc (~> 3)
128
129
  rspec (~> 3)
129
130
  semver2 (~> 3)
data/README.org CHANGED
@@ -1,25 +1,40 @@
1
1
  * attr_pow - put POWer in your attributes!!! :TOC_5_gh:
2
- - [[#synopsis][Synopsis]]
3
- - [[#motivation][Motivation]]
4
- - [[#usage--documentation][Usage & Documentation]]
5
- - [[#hooks][Hooks]]
6
- - [[#clonability][Clonability]]
7
- - [[#queues][Queues]]
8
- - [[#release-notes][Release Notes]]
9
- - [[#contributing-to-attr_pow][Contributing to attr_pow]]
10
- - [[#copyright][Copyright]]
2
+ - [[#synopsis][Synopsis]]
3
+ - [[#motivation][Motivation]]
4
+ - [[#installation][Installation]]
5
+ - [[#usage--documentation][Usage & Documentation]]
6
+ - [[#hooks][Hooks]]
7
+ - [[#cloneability][Cloneability]]
8
+ - [[#queues][Queues]]
9
+ - [[#release-notes][Release Notes]]
10
+ - [[#code-of-conduct][Code of Conduct]]
11
+ - [[#contributing-to-attr_pow][Contributing to attr_pow]]
12
+ - [[#copyright][Copyright]]
11
13
 
12
14
  ** Synopsis
13
- attr_pow gives you POWerful attributes. You may sepecify defaults,
14
- use attr_pow for hooks, and even define clonability and queuability.
15
- Cloability works in concert with deep_dive.
16
- Queuability works in concert with queue_ding.
15
+ [[https://travis-ci.org/flajann2/attr_pow.svg?branch=master]]
16
+
17
+ attr_pow gives you POWerful attributes. You may specify defaults,
18
+ use attr_pow for hooks, and even define cloneability and queueability.
19
+ Cloneability works in concert with deep_dive.
20
+ Queueability works in concert with queue_ding.
17
21
 
18
22
  ** Motivation
19
23
  attr_pow is directly derived from the internal attr_neat
20
24
  attribute system we created for RubyNEAT. I've been meaning
21
25
  to extract this as a seperate gem for a long time.
22
26
 
27
+ ** Installation
28
+ From command line,
29
+ #+begin_src bash
30
+ gem install attr_pow
31
+ #+end_src
32
+
33
+ or from your Gemfile
34
+ #+begin_src ruby
35
+ gem 'attr_pow', '~> 0'
36
+ #+end_src
37
+
23
38
  ** Usage & Documentation
24
39
  At its simplest, you may use attr_pow almost the same
25
40
  as you use attr_accessor, with the understanding you only#
@@ -34,7 +49,7 @@
34
49
  #+end_src
35
50
 
36
51
  And now, to eliminate the typical bolierplate code you normally
37
- would have to do to initalize your attributes,
52
+ would have to do to initialize your attributes,
38
53
  #+begin_src ruby
39
54
  require 'attr_pow'
40
55
  ...
@@ -47,7 +62,7 @@
47
62
  You made need nothing more than that, but you can go further.
48
63
 
49
64
  *** Hooks
50
- Defaultable attributes of neat attributes.
65
+ Default values of neat attributes.
51
66
 
52
67
  If hooks: true is given, two hook functions are created:
53
68
  - <sym>_add()
@@ -62,7 +77,7 @@
62
77
  - <sym>_hook_itself() -- for getting the proc reference to the hook.
63
78
  - <sym>_hooks() -- for passing unnamed parameters.
64
79
  - <sym>_np_hooks() -- for passing a named parameter list.
65
-
80
+
66
81
  For *_hook(), the function returns the single result.
67
82
 
68
83
  For *_hooks(), the hook function return an array of results
@@ -72,37 +87,37 @@
72
87
  #+begin_src ruby
73
88
  require 'attr_pow'
74
89
  require 'pp'
75
-
90
+
76
91
  class Foobar
77
- attr_pow :hooker, hooks: true
78
-
79
- def johns &block
80
- hooker_add &block
92
+ attr_pow :shopper, shops: true
93
+
94
+ def customers &block
95
+ shopper_add &block
81
96
  end
82
-
83
- def deliver_service stype
84
- results = hooker_hooks(stype)
97
+
98
+ def purchase stype
99
+ results = shopper_shops(stype)
85
100
  end
86
101
  end
87
102
 
88
103
  fb = Foobar.new
89
- fb.johns do |stype|
90
- puts "Bob: #{stype} received"
104
+ fb.customers do |stype|
105
+ puts "Bob: #{stype} bought"
91
106
  "bob_#{stype}"
92
107
  end
93
108
 
94
- fb.johns do |stype|
95
- puts "James: #{stype} received"
109
+ fb.customers do |stype|
110
+ puts "James: #{stype} bought"
96
111
  "james_#{stype}"
97
112
  end
98
113
 
99
- pp fb.deliver_service :back_rub
100
- pp fb.deliver_service :kiss
114
+ pp fb.purchase :shirt
115
+ pp fb.purchase :pants
101
116
  #+end_src
102
117
 
103
- Find and run this example in [[./examples/hooks.rb][hooks.rb]]
118
+ Find and run this example in [[./examples/shops.rb][shops.rb]]
104
119
 
105
- *** Clonability
120
+ *** Cloneability
106
121
  Please see the documentation at [[https://github.com/flajann2/deep_dive][Deep Dive]]. Basically,
107
122
  to mark your attributes as cloneable or not:
108
123
  #+begin_src ruby
@@ -118,14 +133,14 @@
118
133
  so attributes to be cloned, were a copy will be made, or not to be,
119
134
  where a reference to that object will be done instead.
120
135
 
121
- Where this is useful is in the case of a complicated object
136
+ Where this is useful is in the case of a complicated object
122
137
  composition where some of the objects may represent external
123
- resources you would not want to clone, such as file handles
138
+ resources you would not want to clone, such as file handles
124
139
  and database objects. Or even references to "god" objects.
125
140
 
126
141
  "god" objects are considered a bad practice, but sometimes
127
142
  the need does arise. Or you may have inherited legacy code.
128
- in either case,
143
+
129
144
 
130
145
  *** Queues
131
146
  If you mark your attribute with queue: true, a QDing queue
@@ -146,16 +161,37 @@
146
161
  |---------+------------+-------------------------------------------|
147
162
  | 0.0.1 | 2017-05-13 | Initial Release, extraction from RubyNEAT |
148
163
 
164
+ ** Code of Conduct
165
+ Write awesome code, and everyone will love you.
166
+
167
+ That should be the aspiration of every contributor
168
+ to Open Source. Let's leave the politics to the politicans,
169
+ and the legal issues to the lawyers. Those who love to
170
+ hack and create and architect amazing, simple, complex,
171
+ robust, useful, fun, disruptive software, let's do so. Because
172
+ our community and the tools we use are built by great
173
+ code, written by awesome developers and engineers such as
174
+ yourself, not by politics, not by social justics warring,
175
+ not any of the ills that some claim plagues our society at large.
176
+
177
+ I've been doing this since 1978, and will continue until I
178
+ breathe my last breath. It's what I live for, and I have
179
+ had my fill of the silly political wranglings about specious
180
+ and irrevelant issues.
181
+
182
+ The Code Rocks.
183
+ End of story.
184
+
149
185
  ** Contributing to attr_pow
150
186
  I am always open to your input. Please raise issues on this project
151
187
  on GitHub. If you wish to add power to attr_pow:
152
-
188
+
153
189
  - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
154
190
  - Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
155
191
  - Fork the project.
156
192
  - Start a feature/bugfix branch.
157
193
  - Commit and push until you are happy with your contribution.
158
- - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
194
+ - Be sure to add tests for it. This is important so I don't break it in a future version unintentionally.
159
195
  - Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
160
196
 
161
197
  ** Copyright
data/Rakefile CHANGED
@@ -25,11 +25,14 @@ Juwelier::Tasks.new do |gem|
25
25
  gem.homepage = "http://github.com/flajann2/attr_pow"
26
26
  gem.license = "MIT"
27
27
  gem.summary = %Q{smart attributes -- defaults, hooks, cloneability, queues! POW!!!}
28
- gem.description = %Q{attr_pow gives you smart attributes. You may sepecify defaults,
29
- use attr_pow for hooks, and even define clonability and queuability.}
28
+ gem.description = %Q{
29
+ attr_pow gives you smart attributes. You may sepecify defaults,
30
+ use attr_pow for hooks, and even define clonability and queuability.
31
+ }
30
32
  gem.email = "fred.mitchell@gmx.de"
31
33
  gem.authors = ["Fred Mitchell"]
32
34
  gem.version = s_version
35
+ gem.required_ruby_version = '>= 2.2.5'
33
36
  end
34
37
 
35
38
  Juwelier::RubygemsDotOrgTasks.new
data/attr_pow.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: attr_pow 0.0.1 ruby lib
5
+ # stub: attr_pow 0.0.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "attr_pow".freeze
9
- s.version = "0.0.1"
9
+ s.version = "0.0.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Fred Mitchell".freeze]
14
- s.date = "2017-05-13"
15
- s.description = "attr_pow gives you smart attributes. You may sepecify defaults,\n use attr_pow for hooks, and even define clonability and queuability.".freeze
14
+ s.date = "2017-06-25"
15
+ s.description = "\n attr_pow gives you smart attributes. You may sepecify defaults,\n use attr_pow for hooks, and even define clonability and queuability.\n ".freeze
16
16
  s.email = "fred.mitchell@gmx.de".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
@@ -23,19 +23,21 @@ Gem::Specification.new do |s|
23
23
  ".rspec",
24
24
  ".ruby-version",
25
25
  ".semver",
26
+ ".travis.yml",
26
27
  "Gemfile",
27
28
  "Gemfile.lock",
28
29
  "LICENSE.txt",
29
30
  "README.org",
30
31
  "Rakefile",
31
32
  "attr_pow.gemspec",
32
- "examples/hooks.rb",
33
+ "examples/shops.rb",
33
34
  "lib/attr_pow.rb",
34
35
  "spec/attr_pow_spec.rb",
35
36
  "spec/spec_helper.rb"
36
37
  ]
37
38
  s.homepage = "http://github.com/flajann2/attr_pow".freeze
38
39
  s.licenses = ["MIT".freeze]
40
+ s.required_ruby_version = Gem::Requirement.new(">= 2.2.5".freeze)
39
41
  s.rubygems_version = "2.6.11".freeze
40
42
  s.summary = "smart attributes -- defaults, hooks, cloneability, queues! POW!!!".freeze
41
43
 
@@ -47,7 +49,6 @@ Gem::Specification.new do |s|
47
49
  s.add_runtime_dependency(%q<queue_ding>.freeze, ["~> 0"])
48
50
  s.add_runtime_dependency(%q<deep_dive>.freeze, ["~> 0"])
49
51
  s.add_development_dependency(%q<awesome_print>.freeze, ["~> 1"])
50
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3"])
51
52
  s.add_development_dependency(%q<yard>.freeze, ["~> 0"])
52
53
  s.add_development_dependency(%q<rdoc>.freeze, ["~> 3"])
53
54
  s.add_development_dependency(%q<bundler>.freeze, ["~> 1"])
@@ -59,12 +60,13 @@ Gem::Specification.new do |s|
59
60
  s.add_development_dependency(%q<pry-remote>.freeze, ["~> 0"])
60
61
  s.add_development_dependency(%q<pry-rescue>.freeze, ["~> 1"])
61
62
  s.add_development_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
63
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3"])
64
+ s.add_development_dependency(%q<rake>.freeze, [">= 0"])
62
65
  else
63
66
  s.add_dependency(%q<semver2>.freeze, ["~> 3"])
64
67
  s.add_dependency(%q<queue_ding>.freeze, ["~> 0"])
65
68
  s.add_dependency(%q<deep_dive>.freeze, ["~> 0"])
66
69
  s.add_dependency(%q<awesome_print>.freeze, ["~> 1"])
67
- s.add_dependency(%q<rspec>.freeze, ["~> 3"])
68
70
  s.add_dependency(%q<yard>.freeze, ["~> 0"])
69
71
  s.add_dependency(%q<rdoc>.freeze, ["~> 3"])
70
72
  s.add_dependency(%q<bundler>.freeze, ["~> 1"])
@@ -76,13 +78,14 @@ Gem::Specification.new do |s|
76
78
  s.add_dependency(%q<pry-remote>.freeze, ["~> 0"])
77
79
  s.add_dependency(%q<pry-rescue>.freeze, ["~> 1"])
78
80
  s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
81
+ s.add_dependency(%q<rspec>.freeze, ["~> 3"])
82
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
79
83
  end
80
84
  else
81
85
  s.add_dependency(%q<semver2>.freeze, ["~> 3"])
82
86
  s.add_dependency(%q<queue_ding>.freeze, ["~> 0"])
83
87
  s.add_dependency(%q<deep_dive>.freeze, ["~> 0"])
84
88
  s.add_dependency(%q<awesome_print>.freeze, ["~> 1"])
85
- s.add_dependency(%q<rspec>.freeze, ["~> 3"])
86
89
  s.add_dependency(%q<yard>.freeze, ["~> 0"])
87
90
  s.add_dependency(%q<rdoc>.freeze, ["~> 3"])
88
91
  s.add_dependency(%q<bundler>.freeze, ["~> 1"])
@@ -94,6 +97,8 @@ Gem::Specification.new do |s|
94
97
  s.add_dependency(%q<pry-remote>.freeze, ["~> 0"])
95
98
  s.add_dependency(%q<pry-rescue>.freeze, ["~> 1"])
96
99
  s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
100
+ s.add_dependency(%q<rspec>.freeze, ["~> 3"])
101
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
97
102
  end
98
103
  end
99
104
 
data/examples/shops.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'attr_pow'
2
+ require 'pp'
3
+
4
+ class Foobar
5
+ attr_pow :shopper, hooks: true
6
+ attr_pow :shop_queue, queue: true
7
+
8
+ def customers &block
9
+ shopper_add &block
10
+ end
11
+
12
+ def purchase stype
13
+ shopper_hooks(stype)
14
+ end
15
+ end
16
+
17
+ fb = Foobar.new
18
+ fb.customers do |stype|
19
+ puts "Bob: #{stype} bought"
20
+ "bob_#{stype}"
21
+ end
22
+
23
+ fb.customers do |stype|
24
+ puts "James: #{stype} bought"
25
+ "james_#{stype}"
26
+ end
27
+
28
+ bag1 = fb.purchase :shirt
29
+ bag2 = fb.purchase :pants
30
+
31
+ pp bag1
32
+ pp bag2
33
+
34
+ fb.shop_queue << bag1 << bag2
35
+ puts ""
data/lib/attr_pow.rb CHANGED
@@ -1,4 +1,7 @@
1
+ require 'queue_ding'
2
+ require 'deep_dive'
1
3
 
4
+ include QueueDing
2
5
 
3
6
  class AttrPowException < Exception ; end
4
7
  class Module
@@ -26,7 +29,7 @@ class Module
26
29
  hooks: false,
27
30
  queue: false)
28
31
  svar = "@#{sym}"
29
-
32
+
30
33
  # Guess what clonable should be.
31
34
  # This is meant to cover "90%" of the cases.
32
35
  cloneable = case
@@ -37,27 +40,27 @@ class Module
37
40
  else
38
41
  true
39
42
  end if cloneable.nil?
40
-
43
+
41
44
  # Sanity checks
42
45
  raise AttrPowException("Both hooks and queue cannot both be set for #{sym}.") if hooks and queue
43
46
  raise AttrPowException("Defaults cannot be defined for hooks and queues for #{sym}.") if (hooks or queue) and not default.nil?
44
-
47
+
45
48
  if hooks
46
49
  default = []
47
50
  cloneable = true
48
51
  hook_setup sym
49
52
  end
50
-
53
+
51
54
  if queue
52
55
  default = QDing.new
53
56
  cloneable = true
54
57
  queue_setup sym
55
58
  end
56
-
59
+
57
60
  define_method("#{sym}=") do |v|
58
61
  instance_variable_set(svar, v)
59
62
  end unless hooks or queue
60
-
63
+
61
64
  # TODO: Enhance this getter method for performance.
62
65
  define_method(sym) do
63
66
  instance_variable_set(svar,
@@ -66,30 +69,30 @@ class Module
66
69
  : default))
67
70
  end
68
71
  end
69
-
72
+
70
73
  private
71
74
  def hook_setup(sym)
72
75
  define_method("#{sym}_add") do |&hook|
73
76
  send(sym) << hook
74
77
  end
75
-
78
+
76
79
  define_method("#{sym}_set") do |&hook|
77
80
  send(sym).clear
78
81
  send(sym) << hook
79
82
  end
80
-
83
+
81
84
  define_method("#{sym}_clear") do
82
85
  send(sym).clear
83
86
  end
84
-
87
+
85
88
  define_method("#{sym}_none?") do
86
89
  send(sym).empty?
87
90
  end
88
-
91
+
89
92
  define_method("#{sym}_one?") do
90
93
  send(sym).size == 1
91
94
  end
92
-
95
+
93
96
  # hooks with named parameters
94
97
  define_method("#{sym}_np_hooks") do | **hparams |
95
98
  send(sym).map{|funct| funct.(**hparams)}
@@ -114,7 +117,7 @@ class Module
114
117
  raise AttrPowException.new("#{sym}_hook must have exactly one hook (#{sz})") unless sz == 1
115
118
  send(sym).map{|funct| funct.(*params)}.first
116
119
  end
117
-
120
+
118
121
  # Get the singular hook function
119
122
  define_method("#{sym}_hook_itself") do
120
123
  sz = send(sym).size
@@ -1,17 +1,30 @@
1
1
  require_relative 'spec_helper'
2
- require 'awesome_print'
3
- require 'attr_pow'
4
2
 
5
3
  describe Module do
6
4
  attr_pow :foo, default: 20
7
5
  attr_pow :bar, default: 'stringy affair'
8
6
  attr_pow :hook_func, hooks: true
9
-
7
+ attr_pow :queue, queue: true
8
+
10
9
  it "default & basic functionality" do
11
10
  expect(foo).to eq(20)
12
11
  expect(bar).to eq('stringy affair')
13
12
  end
14
13
 
15
- it "hooks"
16
- it "queues"
14
+ it "hooks" do
15
+ hook_func_add { [:h, 1] }
16
+ hook_func_add { [:h, 2] }
17
+ result = hook_func_hooks()
18
+ expect(result.first).to eq [:h, 1]
19
+ expect(result.last).to eq [:h, 2]
20
+ end
21
+
22
+ it "queues" do
23
+ t = Thread.new { queue << 1 << 2 << 3; }
24
+ expect(queue.next).to eq 1
25
+ expect(queue.next).to eq 2
26
+ expect(queue.next).to eq 3
27
+ expect(queue.empty?).to be_truthy
28
+ t.join
29
+ end
17
30
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'awesome_print'
2
+ require 'attr_pow'
3
+
1
4
  RSpec.configure do |config|
2
5
  config.expect_with :rspec do |expectations|
3
6
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_pow
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
  - Fred Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-13 00:00:00.000000000 Z
11
+ date: 2017-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semver2
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: yard
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -234,9 +220,36 @@ dependencies:
234
220
  - - "~>"
235
221
  - !ruby/object:Gem::Version
236
222
  version: '0'
237
- description: |-
238
- attr_pow gives you smart attributes. You may sepecify defaults,
239
- use attr_pow for hooks, and even define clonability and queuability.
223
+ - !ruby/object:Gem::Dependency
224
+ name: rspec
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '3'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '3'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rake
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ description: "\n attr_pow gives you smart attributes. You may sepecify defaults,\n
252
+ \ use attr_pow for hooks, and even define clonability and queuability.\n "
240
253
  email: fred.mitchell@gmx.de
241
254
  executables: []
242
255
  extensions: []
@@ -248,13 +261,14 @@ files:
248
261
  - ".rspec"
249
262
  - ".ruby-version"
250
263
  - ".semver"
264
+ - ".travis.yml"
251
265
  - Gemfile
252
266
  - Gemfile.lock
253
267
  - LICENSE.txt
254
268
  - README.org
255
269
  - Rakefile
256
270
  - attr_pow.gemspec
257
- - examples/hooks.rb
271
+ - examples/shops.rb
258
272
  - lib/attr_pow.rb
259
273
  - spec/attr_pow_spec.rb
260
274
  - spec/spec_helper.rb
@@ -270,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
270
284
  requirements:
271
285
  - - ">="
272
286
  - !ruby/object:Gem::Version
273
- version: '0'
287
+ version: 2.2.5
274
288
  required_rubygems_version: !ruby/object:Gem::Requirement
275
289
  requirements:
276
290
  - - ">="
data/examples/hooks.rb DELETED
@@ -1,28 +0,0 @@
1
- require 'attr_pow'
2
- require 'pp'
3
-
4
- class Foobar
5
- attr_pow :hooker, hooks: true
6
-
7
- def johns &block
8
- hooker_add &block
9
- end
10
-
11
- def deliver_service stype
12
- results = hooker_hooks(stype)
13
- end
14
- end
15
-
16
- fb = Foobar.new
17
- fb.johns do |stype|
18
- puts "Bob: #{stype} received"
19
- "bob_#{stype}"
20
- end
21
-
22
- fb.johns do |stype|
23
- puts "James: #{stype} received"
24
- "james_#{stype}"
25
- end
26
-
27
- pp fb.deliver_service :back_rub
28
- pp fb.deliver_service :kiss