descendants_describable 0.0.3 → 0.0.4

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: 570e2a661194ac0301464cfe6fcdf0c23c99d344
4
- data.tar.gz: 7df6c28fa47ca1bed47c159786dc3a3479a9b965
3
+ metadata.gz: 78b03898214e5b116c6901c22e91ea10f6fb2a04
4
+ data.tar.gz: 4357f9507a420055f5ccd3668221c4c88e2320bf
5
5
  SHA512:
6
- metadata.gz: f670e49f3ff21073f732e4c53bdb8841c50082e7aba6915cabe1dcad5731d0bc345ba0d1c2dc702774845cea39a5cd16ed341caa8f6c85ff9d08c8095f7d1159
7
- data.tar.gz: 5d49b9bfc1006b6c5fa8bf7f4cf14d7f20f4d7859f9b667f532203706bac2c7edaf92ddd7bfc53b4ba829a9a88daa6c86f1df21f12a88e9084a47f2e062542e6
6
+ metadata.gz: 80694bea36aaf587c583ea138878d96d3b174a2d7e22f991dbcd039a311db3dca776c6f1c4de8389bab9ab41b33c2533d6dda257971fb587dc920bc9fb7af567
7
+ data.tar.gz: 0ba02c0d5167fda0d53d723273415e67a4d2da33300fdd3401e339d2ef44ef60ea474f8e4cc1e4a21d0bfb47c600e32be0d4b7680d222d3d20a6ad7b4bc6e282
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm ruby-2.0.0@descendants_describable --create
1
+ rvm ruby-2.1.1@descendants_describable --create
data/README.md CHANGED
@@ -1,6 +1,29 @@
1
- # DescendantsDescribable
1
+ # descendants_describable.gem
2
2
 
3
- TODO: Write a gem description
3
+ This gem provides a shorthand DSL for including re-usable sets of mixin modules across a large set of STI models.
4
+ If you find yourself with a folder of subclasses full of boilerplate and shared functionality, this gem will let you replace
5
+ those files with one or a few small files that read more descriptively, like so:
6
+
7
+ ``` ruby
8
+
9
+ MySuperClass.describe_descendants_with(MySuperClassMixins) do
10
+ type :some_type
11
+ type :another_subtype do
12
+ email_addressable
13
+ end
14
+
15
+ type :some_domain_event do
16
+ email_addressable
17
+ payment_validatable
18
+ end
19
+ end
20
+ ```
21
+
22
+ ## Why?
23
+
24
+ My [blog post](http://winfred.nadeau.io/2014/03/22/taming-the-activities-table/) describes the evolution of this gem at [Hired](http://hired.com) pretty well.
25
+
26
+ TL;DR imagine the example in the [usage section](#usage) with a marketplace's domain described therein.
4
27
 
5
28
  ## Installation
6
29
 
@@ -18,7 +41,62 @@ Or install it yourself as:
18
41
 
19
42
  ## Usage
20
43
 
21
- TODO: Write usage instructions here
44
+ Here's the real-world example that gave life to this gem:
45
+
46
+ ```ruby
47
+
48
+ # config/initializers/activities.rb
49
+
50
+ Activity.describe_descendants_with(Activity::Descriptors) do
51
+ type :completed_survey do
52
+ user_required
53
+ end
54
+
55
+ type :bid_on_developer do
56
+ approved_employers_only
57
+ target_required
58
+ end
59
+
60
+ type :auction_membership_confirmed do
61
+ approved_developers_only
62
+ actor_unique_to_auction
63
+ target_required
64
+ end
65
+ # ... others omitted for brevity ...
66
+ end
67
+
68
+ ```
69
+
70
+ Given this example, one is describing the descendants of an Activity class (that also live on the activities table with a type column for STI), the following is happening.
71
+
72
+
73
+ 1. Each "type" declaration instantiates a new subclass by that name camelized.
74
+ 2. Each method called inside the block provided to a "type" declaration will include into that new subclass a module by that method name camelized in the provided *descriptor namespace*.
75
+
76
+ So the above is basically shorthand for this:
77
+
78
+ ```ruby
79
+
80
+ # in models/completed_survey.rb
81
+ class CompletedSurvey < Activity
82
+ include Activity::Descriptors::UserRequired
83
+ end
84
+
85
+ # in models/bid_on_developer.rb
86
+ class BidOnDeveloper < Activity
87
+ include Activity::Descriptors::ApprovedEmployersOnly
88
+ include Activity::Descriptors::TargetRequired
89
+ end
90
+
91
+ # in models/auction_membership_confirmed.rb
92
+ class AuctionMembershipConfirmed < Activity
93
+ include Activity::Descriptors::ApprovedEmployersOnly
94
+ include Activity::Descriptors::ActorUniqueToAuction
95
+ include Activity::Descriptors::TargetRequired
96
+ end
97
+
98
+ ```
99
+
22
100
 
23
101
  ## Contributing
24
102
 
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'activerecord', '~> 3.2.13'
22
- spec.add_dependency 'activesupport', '~> 3.2.13'
21
+ spec.add_dependency 'activerecord', '~> 4.1'
22
+ spec.add_dependency 'activesupport', '~> 4.1'
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec"
@@ -1,3 +1,3 @@
1
1
  module DescendantsDescribable
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: descendants_describable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - winfred
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.13
19
+ version: '4.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.13
26
+ version: '4.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.13
33
+ version: '4.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.2.13
40
+ version: '4.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sqlite3
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Turn a module of behavioral concerns into a DSL for describing a large
@@ -116,8 +116,8 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - .gitignore
120
- - .rvmrc
119
+ - ".gitignore"
120
+ - ".rvmrc"
121
121
  - Gemfile
122
122
  - LICENSE.txt
123
123
  - README.md
@@ -138,17 +138,17 @@ require_paths:
138
138
  - lib
139
139
  required_ruby_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - '>='
141
+ - - ">="
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - '>='
146
+ - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.0.14
151
+ rubygems_version: 2.2.2
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Turn a module of behavioral concerns into a DSL for describing a large set