repository-base 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.rubocop.yml +27 -0
- data/.travis.yml +6 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +128 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +132 -0
- data/Rakefile +33 -0
- data/bin/bundle +105 -0
- data/bin/htmldiff +29 -0
- data/bin/kramdown +29 -0
- data/bin/ldiff +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/bin/ruby-parse +29 -0
- data/bin/ruby-rewrite +29 -0
- data/bin/setup +43 -0
- data/bin/yard +29 -0
- data/bin/yardoc +29 -0
- data/bin/yri +29 -0
- data/doc/Repository.html +128 -0
- data/doc/Repository/Base.html +1248 -0
- data/doc/Repository/Base/Internals.html +133 -0
- data/doc/Repository/Base/Internals/RecordDeleter.html +687 -0
- data/doc/Repository/Base/Internals/RecordSaver.html +816 -0
- data/doc/Repository/Base/Internals/RecordUpdater.html +1026 -0
- data/doc/Repository/Base/Internals/SlugFinder.html +986 -0
- data/doc/_index.html +176 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +499 -0
- data/doc/file.CHANGELOG.html +240 -0
- data/doc/file.README.html +218 -0
- data/doc/file_list.html +61 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +218 -0
- data/doc/js/app.js +248 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +363 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/repository/base.rb +115 -0
- data/lib/repository/base/internals/internals.rb +6 -0
- data/lib/repository/base/internals/record_deleter.rb +46 -0
- data/lib/repository/base/internals/record_saver.rb +58 -0
- data/lib/repository/base/internals/record_updater.rb +54 -0
- data/lib/repository/base/internals/slug_finder.rb +70 -0
- data/lib/repository/base/version.rb +12 -0
- data/repository-base.gemspec +37 -0
- data/spec/repository/base_spec.rb +398 -0
- data/spec/spec_helper.rb +14 -0
- metadata +281 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2769d07ba1f7cb1de214818a131ff6743a56c93254278d2f4fdbba87d5e15845
|
4
|
+
data.tar.gz: f41460497cb374c7eec66a1440ba7509a61371b92d71b49dc1d550cf1ee2996a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73d5aad44196d642b1ab3f4e3d496569d79cc004f819c893bea69d0280e8ad52c33d73fba7549ddaba7821ec670c64b4abd2c37e52185f619f26a8b5e7ee6227
|
7
|
+
data.tar.gz: 3ab7d049341d50c94dce4b51b2a0b015470e3f6dfc9975e563d8aa04e0cc53620b0ad4090babd661d746a7234963bf4f89ac90d68a7d18c3cfbe02e57bb93d4e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.5
|
4
|
+
|
5
|
+
Metrics/BlockLength:
|
6
|
+
Max: 500
|
7
|
+
Include:
|
8
|
+
- 'spec/**/*_spec.rb'
|
9
|
+
|
10
|
+
Metrics/ModuleLength:
|
11
|
+
Max: 500
|
12
|
+
Include:
|
13
|
+
- 'spec/**/*_spec.rb'
|
14
|
+
|
15
|
+
Style/CommentedKeyword:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
# This silences 'Missing top-level class documentation comment.', which we
|
19
|
+
# particularly want to do on (initially-)generated files.
|
20
|
+
Style/Documentation:
|
21
|
+
Enabled: false
|
22
|
+
Include:
|
23
|
+
- 'apps/**/*.rb'
|
24
|
+
- 'lib/**/*.rb'
|
25
|
+
|
26
|
+
Rails/DynamicFindBy:
|
27
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--private --protected lib/repository/base.rb lib/repository/base/internals/internals.rb lib/repository/base/internals/record_deleter.rb lib/repository/base/internals/record_saver.rb lib/repository/base/internals/record_updater.rb lib/repository/base/internals/slug_finder.rb lib/repository/base/version.rb - CHANGELOG.md README.md
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.4.0](https://github.com/jdickey/repository-base/tree/v0.3.0) (2018-02-03)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.2.0...v0.3.0)
|
6
|
+
|
7
|
+
* Added [YARD-generated documentation](./doc/index.html)
|
8
|
+
* Updated Ruby version to 2.5.0;
|
9
|
+
* Updated developer dependencies to now-current versions;
|
10
|
+
* Made trivial code changes to satisfy static-analysis tools. Tests still green.
|
11
|
+
|
12
|
+
## [v0.3.0](https://github.com/jdickey/repository-base/tree/v0.3.0) (2015-03-30)
|
13
|
+
|
14
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.2.0...v0.3.0)
|
15
|
+
|
16
|
+
**Fixed bugs:**
|
17
|
+
|
18
|
+
- Adding an entity? Its attributes may not always be a Hash. [\#19](https://github.com/jdickey/repository-base/issues/19)
|
19
|
+
|
20
|
+
**Merged pull requests:**
|
21
|
+
|
22
|
+
- Support entity attributes conversion. Also, merge fixed Travis into master. [\#20](https://github.com/jdickey/repository-base/pull/20) ([jdickey](https://github.com/jdickey))
|
23
|
+
|
24
|
+
## [v0.2.0](https://github.com/jdickey/repository-base/tree/v0.2.0) (2015-02-22)
|
25
|
+
|
26
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.1.2...v0.2.0)
|
27
|
+
|
28
|
+
**Fixed bugs:**
|
29
|
+
|
30
|
+
- Public methods should return entities, not DAO records. [\#18](https://github.com/jdickey/repository-base/issues/18)
|
31
|
+
|
32
|
+
## [v0.1.2](https://github.com/jdickey/repository-base/tree/v0.1.2) (2015-02-20)
|
33
|
+
|
34
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.1.1...v0.1.2)
|
35
|
+
|
36
|
+
**Fixed bugs:**
|
37
|
+
|
38
|
+
- The \#update method should return an entity, not a record. [\#17](https://github.com/jdickey/repository-base/issues/17)
|
39
|
+
|
40
|
+
## [v0.1.1](https://github.com/jdickey/repository-base/tree/v0.1.1) (2015-02-19)
|
41
|
+
|
42
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.1.0...v0.1.1)
|
43
|
+
|
44
|
+
**Implemented enhancements:**
|
45
|
+
|
46
|
+
- Add Inch badge \(and prodded docs\). [\#14](https://github.com/jdickey/repository-base/issues/14)
|
47
|
+
|
48
|
+
**Fixed bugs:**
|
49
|
+
|
50
|
+
- The `\#add` method should return an entity on success, NOT a record. [\#16](https://github.com/jdickey/repository-base/issues/16)
|
51
|
+
|
52
|
+
**Merged pull requests:**
|
53
|
+
|
54
|
+
- \[Close \#14\] Added Inch CI badge and internal docs. [\#15](https://github.com/jdickey/repository-base/pull/15) ([jdickey](https://github.com/jdickey))
|
55
|
+
|
56
|
+
## [v0.1.0](https://github.com/jdickey/repository-base/tree/v0.1.0) (2015-02-18)
|
57
|
+
|
58
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.0.5...v0.1.0)
|
59
|
+
|
60
|
+
**Closed issues:**
|
61
|
+
|
62
|
+
- Integrate `repository-support` Gem in place of `lib/repository/support/\*` sources. [\#13](https://github.com/jdickey/repository-base/issues/13)
|
63
|
+
|
64
|
+
## [v0.0.5](https://github.com/jdickey/repository-base/tree/v0.0.5) (2015-02-17)
|
65
|
+
|
66
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.0.4...v0.0.5)
|
67
|
+
|
68
|
+
**Closed issues:**
|
69
|
+
|
70
|
+
- Implement \#delete method. [\#11](https://github.com/jdickey/repository-base/issues/11)
|
71
|
+
|
72
|
+
**Merged pull requests:**
|
73
|
+
|
74
|
+
- Implement \#delete method. [\#12](https://github.com/jdickey/repository-base/pull/12) ([jdickey](https://github.com/jdickey))
|
75
|
+
|
76
|
+
## [v0.0.4](https://github.com/jdickey/repository-base/tree/v0.0.4) (2015-02-17)
|
77
|
+
|
78
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.0.3...v0.0.4)
|
79
|
+
|
80
|
+
**Closed issues:**
|
81
|
+
|
82
|
+
- Implement \#update method. [\#9](https://github.com/jdickey/repository-base/issues/9)
|
83
|
+
|
84
|
+
**Merged pull requests:**
|
85
|
+
|
86
|
+
- Implement \#update method. [\#10](https://github.com/jdickey/repository-base/pull/10) ([jdickey](https://github.com/jdickey))
|
87
|
+
|
88
|
+
## [v0.0.3](https://github.com/jdickey/repository-base/tree/v0.0.3) (2015-02-17)
|
89
|
+
|
90
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.0.2...v0.0.3)
|
91
|
+
|
92
|
+
**Closed issues:**
|
93
|
+
|
94
|
+
- Implement \#find\_by\_slug method. [\#7](https://github.com/jdickey/repository-base/issues/7)
|
95
|
+
|
96
|
+
**Merged pull requests:**
|
97
|
+
|
98
|
+
- Implement `\#find\_by\_slug` method. [\#8](https://github.com/jdickey/repository-base/pull/8) ([jdickey](https://github.com/jdickey))
|
99
|
+
|
100
|
+
## [v0.0.2](https://github.com/jdickey/repository-base/tree/v0.0.2) (2015-02-16)
|
101
|
+
|
102
|
+
[Full Changelog](https://github.com/jdickey/repository-base/compare/v0.0.1...v0.0.2)
|
103
|
+
|
104
|
+
**Closed issues:**
|
105
|
+
|
106
|
+
- Implement \#all method. [\#5](https://github.com/jdickey/repository-base/issues/5)
|
107
|
+
|
108
|
+
- Badges! [\#2](https://github.com/jdickey/repository-base/issues/2)
|
109
|
+
|
110
|
+
**Merged pull requests:**
|
111
|
+
|
112
|
+
- Implement \#all method. [\#6](https://github.com/jdickey/repository-base/pull/6) ([jdickey](https://github.com/jdickey))
|
113
|
+
|
114
|
+
## [v0.0.1](https://github.com/jdickey/repository-base/tree/v0.0.1) (2015-02-16)
|
115
|
+
|
116
|
+
**Closed issues:**
|
117
|
+
|
118
|
+
- Implement \#add method [\#3](https://github.com/jdickey/repository-base/issues/3)
|
119
|
+
|
120
|
+
**Merged pull requests:**
|
121
|
+
|
122
|
+
- \[Close \#3\] Implement `\#add` method. [\#4](https://github.com/jdickey/repository-base/pull/4) ([jdickey](https://github.com/jdickey))
|
123
|
+
|
124
|
+
- Add a Gitter chat badge to README.md [\#1](https://github.com/jdickey/repository-base/pull/1) ([gitter-badger](https://github.com/gitter-badger))
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Jeff Dickey
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
<h1>Repository::Base</h1>
|
2
|
+
|
3
|
+
[![Join the chat at https://gitter.im/jdickey/repository-base](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jdickey/repository-base?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/repository-base.svg)](http://badge.fury.io/rb/repository-base)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/jdickey/repository-base.png)](https://codeclimate.com/github/jdickey/repository-base)
|
6
|
+
[ ![Codeship Status for jdickey/repository-base](https://codeship.com/projects/ae57fed0-969f-0132-1faa-76c54edd661d/status?branch=master)](https://codeship.com/projects/63061)
|
7
|
+
[![security](https://hakiri.io/github/jdickey/repository-base/master.svg)](https://hakiri.io/github/jdickey/repository-base/master)
|
8
|
+
[![Dependency Status](https://gemnasium.com/jdickey/repository-base.svg)](https://gemnasium.com/jdickey/repository-base)
|
9
|
+
[![Inline docs](http://inch-ci.org/github/jdickey/repository-base.svg?style=shields)](http://inch-ci.org/github/jdickey/repository-base)
|
10
|
+
|
11
|
+
This Gem supplies a class, `Repository::Base`, which can be used as a base class
|
12
|
+
for Repositories in an application that uses the
|
13
|
+
[Data Mapper pattern](http://martinfowler.com/eaaCatalog/dataMapper.html).
|
14
|
+
As described by Fowler, Data Mapper "moves data between objects and a database
|
15
|
+
while keeping them independent of each other and the mapper itself".
|
16
|
+
|
17
|
+
This was originally developed within the structure of an R&D test-bed application,
|
18
|
+
[`new_poc`](https://github.com/jdickey/new_poc). That app has a fairly wide-ranging
|
19
|
+
history; after browsing its README and
|
20
|
+
[commit history](https://github.com/jdickey/new_poc/commits), you may find Pull
|
21
|
+
Requests [#153](https://github.com/jdickey/new_poc/pull/153) and
|
22
|
+
[#200](https://github.com/jdickey/new_poc/pull/153) informative as to the
|
23
|
+
historical basis of this code.
|
24
|
+
|
25
|
+
<h2>Contents</h2>
|
26
|
+
|
27
|
+
- [Installation](#installation)
|
28
|
+
- [Usage](#usage)
|
29
|
+
* [IMPORTANT LEGACY NOTICE](#important-legacy-notice)
|
30
|
+
* [Concepts](#concepts)
|
31
|
+
+ [Entities](#entities)
|
32
|
+
+ [Entity Factories](#entity-factories)
|
33
|
+
+ [StoreResult](#storeresult)
|
34
|
+
+ [`Repository::Base` Instance Methods](#repositorybase-instance-methods)
|
35
|
+
* [More Details](#more-details)
|
36
|
+
- [Contributing](#contributing)
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
Add this line to your application's Gemfile:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
gem 'repository-base'
|
44
|
+
```
|
45
|
+
|
46
|
+
And then execute:
|
47
|
+
|
48
|
+
$ bundle
|
49
|
+
|
50
|
+
Or install it yourself as:
|
51
|
+
|
52
|
+
$ gem install repository-base
|
53
|
+
|
54
|
+
## Usage
|
55
|
+
|
56
|
+
### IMPORTANT LEGACY NOTICE
|
57
|
+
|
58
|
+
**_NOTICE!_** This Gem was created to support a solo, ad-hoc, early learning experience in what is now known as Clean Architecture. It was part of our first attempt to build an alternative to the ActiveRecord/ActiveModel scheme native to Ruby on Rails.
|
59
|
+
|
60
|
+
As such, it has been superseded and far outshone by other, team efforts, notably [ROM](http://rom-rb.org/) as used with [Hanami](http://hanamirb.org/) and [Trailblazer](http://trailblazer.to/). You are *strongly advised* to examine these and other tools rather than to use this for *any* new development. The Gem is being republished as an 0.4.0 release purely for internal archaeological purposes.
|
61
|
+
|
62
|
+
### Concepts
|
63
|
+
|
64
|
+
As mentioned at the top of this file, `Repository::Base` is intended to serve as
|
65
|
+
the base class for your app's Repositories. As with most Data Mapper
|
66
|
+
implementations, it makes use of a database access object, or DAO, which you
|
67
|
+
specify as one of the two parameters to `#initialize`. The other parameter is an
|
68
|
+
"entity factory", whose `.create` class method hands back an "entity" reflecting
|
69
|
+
the content of an individual record in the underlying DAO.
|
70
|
+
|
71
|
+
#### Entities
|
72
|
+
|
73
|
+
What is an "entity"? It's a domain object in your application, with methods
|
74
|
+
expressing the business logic applicable to the object represented by the underlying
|
75
|
+
database record. This is distinct from an ActiveRecord-style *model*, in that
|
76
|
+
more than one variation of entity may exist in your application for a given DAO.
|
77
|
+
Most applications have Users, for example; some applications may have distinct
|
78
|
+
variation of User *entities* (ordinary punters, admins, a "guest user" entity
|
79
|
+
representing a user who has not authenticated as a more-privileged user, etc),
|
80
|
+
that all share a common persistence layer (the underlying DAO) and an entity
|
81
|
+
factory that *knows* how to create the correct type of entity for a given DAO
|
82
|
+
record.
|
83
|
+
|
84
|
+
An entity is uniquely identified by a *slug* rather than a numeric ID. Generally,
|
85
|
+
a slug encodes textual, relatively SEO-friendly information corresponding to an
|
86
|
+
individual record (the title of an article, the name of a user, etc) such that
|
87
|
+
the corresponding record may be uniquely identified by the DAO. This is in
|
88
|
+
preference to a "traditional" numeric record ID number; `Repository::Base` has
|
89
|
+
no knowledge of nor direct support for numeric record IDs.
|
90
|
+
|
91
|
+
#### Entity Factories
|
92
|
+
|
93
|
+
Again, the entity factory, one of the parameters to this class' `#initialize`
|
94
|
+
method, is responsible for creating an entity from a DAO instance (record). The
|
95
|
+
`Repository::Base` class knows nothing of the details of how that is done; it
|
96
|
+
simply calls methods on the DAO and/or entity factory to accomplish the tasks
|
97
|
+
encapsulated by its own individual methods.
|
98
|
+
|
99
|
+
#### StoreResult
|
100
|
+
|
101
|
+
What is a `StoreResult`? It is a simple value object which communicates the
|
102
|
+
result of a call to a method on the underlying DAO *as reported by the DAO*,
|
103
|
+
with the following properties:
|
104
|
+
|
105
|
+
* `success?` (accessible as `result.success?` or as `result[:success?]`), has the value `true` after a successful operation or `false` after an unsuccessful one;
|
106
|
+
* `entity` (`result.entity` or `result[:entity]`) is the instance or enumeration of instances of your domain entity resulting from a successful operation. After an unsuccessful operation, this property will be `nil`;
|
107
|
+
* `errors` (`result.errors` or `result[:errors]`) is an Array-like object which is empty after a successful operation. After an unsuccessful operation, it will contain an Array of Hash instances, with each Hash having a key identifying the field or similar concept for which an individual error is being reported, and a value of the specific error message. For example, to report that a `:name` field was empty or blank, you might have a Hash of `{ name: 'is empty or blank' }. Your application domain logic should then understand how to deal with that convention.
|
108
|
+
|
109
|
+
#### `Repository::Base` Instance Methods
|
110
|
+
|
111
|
+
* `#add` adds a new record to the underlying *DAO* (data-access object; see above) using the field values specified by the *entity* passed as the only parameter. Returns a `StoreResult` (see above) which indicates the success or failure of the operation. On success, the `StoreResult` contains a *new* entity that represents the state of the record added to the underlying DAO;
|
112
|
+
* `#all` returns a collection of entities matching all records as reported by the underlying DAO, with entities created by the appropriate entity factory;
|
113
|
+
* `#delete` instructs the DAO to delete the record corresponding to the specified `slug`. Returns a `StoreResult` with an entity corresponding to the deleted record on success, or with appropriate error message(s) on failure;
|
114
|
+
* `#find_by_slug` instructs the DAO to retrieve the record whose unique slug value matches the supplied parameter. On success, returns a `StoreResult` with an entity corresponding to the selected record; on failure, the `StoreResult` has an `entity` value of `nil` and appropriate error messages in `errors`;
|
115
|
+
* `update` causes the DAO to attempt to update the record identified by the passed-in slug using the passed-in field values. On success, returns a `StoreResult` whose `entity` value mirrors the updated DAO record; on failure, has appropriate error indications in the `StoreResult`'s `errors` property.
|
116
|
+
|
117
|
+
### More Details
|
118
|
+
|
119
|
+
This Gem now has [full documentation available](./doc/index.html). (No, this isn't 1990s-era `rdoc`.)
|
120
|
+
|
121
|
+
This Gem was built with **MRI Ruby 2.5.0**. It **is likely to** work when rebuilt with any version after 2.0.0; however, as it makes use of [keyword arguments](http://ruby-doc.org//core-2.1.0/doc/syntax/methods_rdoc.html#label-Keyword+Arguments) for various methods, it is *incompatible* with Ruby 1.9 or earlier.
|
122
|
+
|
123
|
+
## Contributing
|
124
|
+
|
125
|
+
1. Fork it ( https://github.com/jdickey/repository-base/fork )
|
126
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
127
|
+
1. Ensure that your changes are completely covered by *passing* specs, and comply with the [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide) as enforced by [RuboCop](https://github.com/bbatsov/rubocop). To verify this, run `bundle exec rake`, noting and repairing any lapses in coverage or style violations;
|
128
|
+
1. Commit your changes (`git commit -a`). Please *do not* use a single-line commit message (`git commit -am "some message"`). A good commit message notes what was changed and why in sufficient detail that a relative newcomer to the code can understand your reasoning and your code;
|
129
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
130
|
+
1. Create a new Pull Request. Describe at some length the rationale for your new feature; your implementation strategy at a higher level than each individual commit message; anything future maintainers should be aware of; and so on. *If this is a modification to existing code, reference the open issue being addressed*.
|
131
|
+
1. Don't be discouraged if the PR generates a discussion that leads to further refinement of your PR through additional commits. These should *generally* be discussed in comments on the PR itself; discussion in the Gitter room (see below) may also be useful;
|
132
|
+
1. If you've comments, questions, or just want to talk through your ideas, don't hesitate to hang out in the project's [room on Gitter](https://gitter.im/jdickey/repository-base). Ask away!
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'rubocop/rake_task'
|
5
|
+
|
6
|
+
require 'kramdown'
|
7
|
+
require 'yard'
|
8
|
+
require 'yard/rake/yardoc_task'
|
9
|
+
|
10
|
+
|
11
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
12
|
+
task.patterns = [
|
13
|
+
'lib/**/*.rb',
|
14
|
+
'spec/spec_helper.rb',
|
15
|
+
'spec/**/*_spec.rb'
|
16
|
+
]
|
17
|
+
task.formatters = ['simple', 'd']
|
18
|
+
task.fail_on_error = true
|
19
|
+
task.options << '--rails'
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec::Core::RakeTask.new :spec
|
23
|
+
|
24
|
+
YARD::Rake::YardocTask.new
|
25
|
+
|
26
|
+
# YARD::Rake::YardocTask.new do |t|
|
27
|
+
# OTHER_PATHS = %w(CHANGELOG.md README.md)
|
28
|
+
# t.files = ['lib/**/*.rb', OTHER_PATHS]
|
29
|
+
# t.options = %w(--private --protected -m markdown --main=README.md)
|
30
|
+
# end
|
31
|
+
|
32
|
+
task(:default).clear
|
33
|
+
task default: [:spec, :rubocop]
|
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|