dbee 1.0.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +8 -0
  3. data/.gitignore +6 -0
  4. data/.rubocop.yml +23 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +26 -0
  7. data/CHANGELOG.md +7 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +5 -0
  10. data/Guardfile +16 -0
  11. data/LICENSE +7 -0
  12. data/README.md +368 -0
  13. data/Rakefile +15 -0
  14. data/bin/console +18 -0
  15. data/dbee.gemspec +33 -0
  16. data/lib/dbee/base.rb +109 -0
  17. data/lib/dbee/model/constraints/base.rb +36 -0
  18. data/lib/dbee/model/constraints/reference.rb +42 -0
  19. data/lib/dbee/model/constraints/static.rb +40 -0
  20. data/lib/dbee/model/constraints.rb +26 -0
  21. data/lib/dbee/model.rb +79 -0
  22. data/lib/dbee/providers/null_provider.rb +21 -0
  23. data/lib/dbee/providers.rb +10 -0
  24. data/lib/dbee/query/field.rb +41 -0
  25. data/lib/dbee/query/filters/base.rb +39 -0
  26. data/lib/dbee/query/filters/contains.rb +19 -0
  27. data/lib/dbee/query/filters/equals.rb +19 -0
  28. data/lib/dbee/query/filters/greater_than.rb +19 -0
  29. data/lib/dbee/query/filters/greater_than_or_equal_to.rb +19 -0
  30. data/lib/dbee/query/filters/less_than.rb +19 -0
  31. data/lib/dbee/query/filters/less_than_or_equal_to.rb +19 -0
  32. data/lib/dbee/query/filters/not_contain.rb +19 -0
  33. data/lib/dbee/query/filters/not_equals.rb +19 -0
  34. data/lib/dbee/query/filters/not_start_with.rb +19 -0
  35. data/lib/dbee/query/filters/starts_with.rb +19 -0
  36. data/lib/dbee/query/filters.rb +40 -0
  37. data/lib/dbee/query/key_path.rb +54 -0
  38. data/lib/dbee/query/sorter.rb +53 -0
  39. data/lib/dbee/query.rb +45 -0
  40. data/lib/dbee/version.rb +12 -0
  41. data/lib/dbee.rb +28 -0
  42. data/spec/dbee/base_spec.rb +35 -0
  43. data/spec/dbee/model/constraints/base_spec.rb +42 -0
  44. data/spec/dbee/model/constraints/reference_spec.rb +37 -0
  45. data/spec/dbee/model/constraints/static_spec.rb +29 -0
  46. data/spec/dbee/model/constraints_spec.rb +25 -0
  47. data/spec/dbee/model_spec.rb +113 -0
  48. data/spec/dbee/providers/null_provider_spec.rb +22 -0
  49. data/spec/dbee/query/field_spec.rb +42 -0
  50. data/spec/dbee/query/filters/base_spec.rb +42 -0
  51. data/spec/dbee/query/filters_spec.rb +33 -0
  52. data/spec/dbee/query/key_path_spec.rb +35 -0
  53. data/spec/dbee/query/sorter_spec.rb +72 -0
  54. data/spec/dbee/query_spec.rb +94 -0
  55. data/spec/dbee_spec.rb +60 -0
  56. data/spec/fixtures/models.rb +115 -0
  57. data/spec/fixtures/models.yaml +101 -0
  58. data/spec/spec_helper.rb +52 -0
  59. metadata +239 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e3da5072dedecfdcd75c8f1478c3a4f60bf477af59a48005044dc0e839e3a85d
4
+ data.tar.gz: 13bcece761321e1690907a05a87c257ad2829b9607152eab5d0f74f2b64605fa
5
+ SHA512:
6
+ metadata.gz: 266465af7710306656ff8dc171a89c4f1f190c6d20e1959072a50bbead4e508ab4740f4c047ee187908a4414ee5b7e6f3fba66bbba8a0f2868a449165f4a1ff2
7
+ data.tar.gz: '09f63b6d657888cbc33d637422632345980f44cd53a56995cdc470585291aa7f77d38c877e7fa6a9c654f3f3f61890ee7a88fddf53d9b349bdddac3d7ef80f89'
data/.editorconfig ADDED
@@ -0,0 +1,8 @@
1
+ # See http://editorconfig.org/
2
+
3
+ [*]
4
+ trim_trailing_whitespace = true
5
+ indent_style = space
6
+ indent_size = 2
7
+ insert_final_newline = true
8
+ end_of_line = lf
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ *.gem
3
+ /tmp
4
+ /coverage
5
+ Gemfile.lock
6
+ /pkg
data/.rubocop.yml ADDED
@@ -0,0 +1,23 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+
4
+ Metrics/BlockLength:
5
+ ExcludedMethods:
6
+ - let
7
+ - it
8
+ - describe
9
+ - context
10
+ - specify
11
+ - define
12
+
13
+ Metrics/MethodLength:
14
+ Max: 25
15
+
16
+ AllCops:
17
+ TargetRubyVersion: 2.3
18
+
19
+ Metrics/AbcSize:
20
+ Max: 16
21
+
22
+ Metrics/ClassLength:
23
+ Max: 125
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/.travis.yml ADDED
@@ -0,0 +1,26 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=e7db23dad7560a076e48357331b0362db3741b62dbdd537bc30de27fa9cab69b
4
+ language: ruby
5
+ rvm:
6
+ # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
7
+ - 2.3.8
8
+ - 2.4.5
9
+ - 2.5.3
10
+ - 2.6.0
11
+ - 2.6.3
12
+ cache: bundler
13
+ before_script:
14
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
+ - chmod +x ./cc-test-reporter
16
+ - ./cc-test-reporter before-build
17
+ script:
18
+ - bundle exec rubocop
19
+ - bundle exec rspec spec --format documentation
20
+ after_script:
21
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
22
+ addons:
23
+ # https://docs.travis-ci.com/user/uploading-artifacts/
24
+ artifacts:
25
+ paths:
26
+ - Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 1.0.0-alpha (August 18th, 2019)
2
+
3
+ Added initial implementation.
4
+
5
+ # 0.0.1 (August 18th, 2019)
6
+
7
+ Created Repo Shell
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at oss@bluemarblepayroll.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
4
+ require 'guard/rspec/dsl'
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2019 Blue Marble Payroll, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,368 @@
1
+ # Dbee
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/dbee.svg)](https://badge.fury.io/rb/dbee) [![Build Status](https://travis-ci.org/bluemarblepayroll/dbee.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/dbee) [![Maintainability](https://api.codeclimate.com/v1/badges/208b36a1d13751687df9/maintainability)](https://codeclimate.com/github/bluemarblepayroll/dbee/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/208b36a1d13751687df9/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/dbee/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+
5
+ Dbee arose out of a need for an ad-hoc reporting solution that included:
6
+
7
+ * serializable queries
8
+ * serializable data modeling
9
+ * de-coupling from our main ORM (ActiveRecord)
10
+ * Rails 5.2.1 and above compatibility
11
+
12
+ Dbee provides a very simple Data Modeling and Query API's and as such it is not meant to replace a traditional ORM or your data persistence layer, but compliment them. This library's goal is to output the SQL statement needed and **nothing** more.
13
+
14
+ Other solutions considered included:
15
+
16
+ * [Squeel](https://github.com/activerecord-hackery/squeel) - Was in production use up until Rails 5, then saw compatibility issues.
17
+ * [BabySqueel](https://github.com/rzane/baby_squeel) - Tested with some success up until Rails 5.2.1, then saw compatibility issues.
18
+
19
+ Both of these solutions ended up closely coupling our domain data layer to ad-hoc reporting layer. One of the primary motivations for this library was to completely de-couple the data modeling from persistence modeling.
20
+
21
+ ## Installation
22
+
23
+ This specific library is the core modeling component of the Dbee framework, but by itself, it not completely usable. You will need to provide a SQL generator which understands how to convert the data and query modeling to actual SQL. This library comes with a stub: Dbee::Providers::NullProvider, while the main reference implementation is split out into its own library: [dbee-active_record](https://github.com/bluemarblepayroll/dbee-active_record). Together these two libraries comprise a complete solution. Refer to the other library for more information on installation.
24
+
25
+ To install through Rubygems:
26
+
27
+ ````
28
+ gem install install dbee
29
+ ````
30
+
31
+ You can also add this to your Gemfile:
32
+
33
+ ````
34
+ bundle add dbee
35
+ ````
36
+
37
+ ## Examples
38
+
39
+ ### The Data Model API
40
+
41
+ Consider the following simple pseudo-schema:
42
+
43
+ ```
44
+ TABLE practices (
45
+ id:integer,
46
+ active:boolean (nullable),
47
+ name:string
48
+ )
49
+
50
+ TABLE patients (
51
+ id:integer,
52
+ practice_id:integer,
53
+ first:string,
54
+ middle:string,
55
+ last:string,
56
+ chart_number:string
57
+ )
58
+
59
+ TABLE notes (
60
+ id:integer,
61
+ patient_id:integer,
62
+ note_type:string,
63
+ contents:string
64
+ )
65
+
66
+ TABLE phones (
67
+ id:integer,
68
+ patient_id:integer,
69
+ phone_number_type:string,
70
+ number:string
71
+ )
72
+ ```
73
+
74
+ *Note: Do not think too much into the merits of the above schema, it is a contrived and simplified example.*
75
+
76
+ In this example: a practice has many patients, a patient has many notes, and a patient also has many phones. It is important to note, though, that a patient can only have one unique phone number per phone number type (such as home, cell, fax, work, etc.)
77
+
78
+ There are two ways to model this schema using Dbee:
79
+
80
+ 1. code-first
81
+ 2. configuration-first
82
+
83
+ #### Code-First Data Modeling
84
+
85
+ Code-first data modeling involves creating sub-classes of Dbee::Base that describes the tables, columns, and associations. We could model the above example as:
86
+
87
+ ````ruby
88
+ module ReadmeDataModels
89
+ class PhoneNumbers < Dbee::Base
90
+ table :phones
91
+ end
92
+
93
+ class Notes < Dbee::Base
94
+ end
95
+
96
+ class Patients < Dbee::Base
97
+ association :notes, model: Notes, constraints: {
98
+ type: :reference, name: :patient_id, parent: :id
99
+ }
100
+
101
+ association :work_phone_number, model: PhoneNumbers, constraints: [
102
+ { type: :reference, name: :patient_id, parent: :id },
103
+ { type: :static, name: :phone_number_type, value: 'work' }
104
+ ]
105
+
106
+ association :cell_phone_number, model: PhoneNumbers, constraints: [
107
+ { type: :reference, name: :patient_id, parent: :id },
108
+ { type: :static, name: :phone_number_type, value: 'cell' }
109
+ ]
110
+
111
+ association :fax_phone_number, model: PhoneNumbers, constraints: [
112
+ { type: :reference, name: :patient_id, parent: :id },
113
+ { type: :static, name: :phone_number_type, value: 'fax' }
114
+ ]
115
+ end
116
+
117
+ class Practices < Dbee::Base
118
+ association :patients, model: Patients, constraints: {
119
+ type: :reference, name: :practice_id, parent: :id
120
+ }
121
+ end
122
+ end
123
+
124
+ ````
125
+
126
+ *Note: the 'table' directive is optional, and if omitted, the classes name will be turned into snake_case and used. In the above example you can see we wanted the class name of PhoneNumbers but the table is actually 'phones'*
127
+
128
+ #### Configuration-First Data Modeling
129
+
130
+ You can choose to alternatively describe your data model using configuration. The YAML below is equivalent to the Ruby sub-classes above:
131
+
132
+ ````yaml
133
+ name: practices
134
+ models:
135
+ - name: patients
136
+ constraints:
137
+ - type: reference
138
+ name: practice_id
139
+ parent: id
140
+ models:
141
+ - name: notes
142
+ constraints:
143
+ - type: reference
144
+ name: patient_id
145
+ parent: id
146
+ - name: work_phone_number
147
+ table: phones
148
+ constraints:
149
+ - type: reference
150
+ name: patient_id
151
+ parent: id
152
+ - type: static
153
+ name: phone_number_type
154
+ value: work
155
+ - name: cell_phone_number
156
+ table: phones
157
+ constraints:
158
+ - type: reference
159
+ name: patient_id
160
+ parent: id
161
+ - type: static
162
+ name: phone_number_type
163
+ value: cell
164
+ - name: fax_phone_number
165
+ table: phones
166
+ constraints:
167
+ - type: reference
168
+ name: patient_id
169
+ parent: id
170
+ - type: static
171
+ name: phone_number_type
172
+ value: fax
173
+ ````
174
+
175
+ It is up to you to determine which modeling technique to use as both are equivalent. Technically speaking, the code-first DSL is nothing more than syntactic sugar on top of Dbee::Model.
176
+
177
+ ### The Query API
178
+
179
+ The Query API (Dbee::Query) is a simplified and abstract way to model an SQL query. A Query has the following components:
180
+
181
+ * fields (SELECT)
182
+ * filters (WHERE)
183
+ * sorters (ORDER BY)
184
+ * limit (LIMIT/TAKE)
185
+
186
+ One very important concept is that all joins are `LEFT OUTER JOIN's`. This is an intentional simplification for our key application domain: configurable custom reporting.
187
+
188
+ #### Key Paths
189
+
190
+ You use key paths in order to identify columns. All key paths are relative to the main data model.
191
+
192
+ #### Sample Queries
193
+
194
+ Get all practices:
195
+
196
+ ````ruby
197
+ query = {
198
+ fields: [
199
+ { key_path: 'id' },
200
+ { key_path: 'active' },
201
+ { key_path: 'name' }
202
+ ]
203
+ }
204
+ ````
205
+
206
+ Get all practices, limit to 10, and sort by name (descending) then id (ascending):
207
+
208
+ ````ruby
209
+ query = {
210
+ fields: [
211
+ { key_path: 'id' },
212
+ { key_path: 'active' },
213
+ { key_path: 'name' }
214
+ ],
215
+ sorters: [
216
+ { key_path: 'name', direction: :descending },
217
+ { key_path: 'id' }
218
+ ],
219
+ limit: 10
220
+ }
221
+ ````
222
+
223
+ Get top 5 active practices and patient whose name start with 'Sm':
224
+
225
+ ````ruby
226
+ query = {
227
+ fields: [
228
+ { key_path: 'name', display: 'Practice Name' },
229
+ { key_path: 'patients.first', display: 'Patient First Name' },
230
+ { key_path: 'patients.middle', display: 'Patient Middle Name' },
231
+ { key_path: 'patients.last', display: 'Patient Last Name' },
232
+ ],
233
+ filters: [
234
+ { type: :equals, key_path: 'active', value: true },
235
+ { type: :starts_with, key_path: 'patients.last', value: 'Sm' },
236
+ ],
237
+ limit: 5
238
+ }
239
+ ````
240
+
241
+ Get practice IDs, patient IDs, names, and cell phone numbers that starts with '555':
242
+
243
+ ````ruby
244
+ query = {
245
+ fields: [
246
+ { key_path: 'id', display: 'Practice ID #' },
247
+ { key_path: 'patients.id', display: 'Patient ID #' },
248
+ { key_path: 'patients.first', display: 'Patient First Name' },
249
+ { key_path: 'patients.middle', display: 'Patient Middle Name' },
250
+ { key_path: 'patients.last', display: 'Patient Last Name' },
251
+ { key_path: 'patients.cell_phone_numbers.phone_number', display: 'Patient Cell #' },
252
+ ],
253
+ filters: [
254
+ { type: :equals, key_path: 'active', value: true },
255
+ {
256
+ type: :starts_with,
257
+ key_path: 'patients.cell_phone_numbers.phone_number',
258
+ value: '555'
259
+ },
260
+ ]
261
+ }
262
+ ````
263
+
264
+ #### Executing a Query
265
+
266
+ You execute a Query against a Data Model, using a Provider. The sample provider: Dbee::Providers::NullProvider is just meant as a stand-in. You will need to plug in a custom provider for real-world use. [See the reference ActiveRecord plugin implementation here.](https://github.com/bluemarblepayroll/dbee-active_record)
267
+
268
+ Here are some sample executions based off the preceding examples:
269
+
270
+ ##### Code-First Execution
271
+
272
+ ````ruby
273
+ require 'dbee'
274
+ require 'dbee/providers/active_record_provider'
275
+
276
+ class Practices < Dbee::Base; end
277
+
278
+ provider = Dbee::Providers::ActiveRecordProvider.new
279
+
280
+ query = {
281
+ fields: [
282
+ { key_path: 'id' },
283
+ { key_path: 'active' },
284
+ { key_path: 'name' }
285
+ ]
286
+ }
287
+
288
+ sql = Dbee.sql(Practices, query, provider)
289
+ ````
290
+
291
+ ##### Configuration-First Execution
292
+
293
+ ````ruby
294
+ require 'dbee'
295
+ require 'dbee/providers/active_record_provider'
296
+
297
+ provider = Dbee::Providers::ActiveRecordProvider.new
298
+
299
+ model = {
300
+ name: :practices
301
+ }
302
+
303
+ query = {
304
+ fields: [
305
+ { key_path: 'id' },
306
+ { key_path: 'active' },
307
+ { key_path: 'name' }
308
+ ]
309
+ }
310
+
311
+ sql = Dbee.sql(model, query, provider)
312
+ ````
313
+
314
+ The above examples showed how to use a plugin provider, see the plugin provider's documentation for more information about its options and use.
315
+
316
+
317
+ ## Contributing
318
+
319
+ ### Development Environment Configuration
320
+
321
+ Basic steps to take to get this repository compiling:
322
+
323
+ 1. Install [Ruby](https://www.ruby-lang.org/en/documentation/installation/) (check dbee.gemspec for versions supported)
324
+ 2. Install bundler (gem install bundler)
325
+ 3. Clone the repository (git clone git@github.com:bluemarblepayroll/dbee.git)
326
+ 4. Navigate to the root folder (cd dbee)
327
+ 5. Install dependencies (bundle)
328
+
329
+ ### Running Tests
330
+
331
+ To execute the test suite run:
332
+
333
+ ````bash
334
+ bundle exec rspec spec --format documentation
335
+ ````
336
+
337
+ Alternatively, you can have Guard watch for changes:
338
+
339
+ ````bash
340
+ bundle exec guard
341
+ ````
342
+
343
+ Also, do not forget to run Rubocop:
344
+
345
+ ````bash
346
+ bundle exec rubocop
347
+ ````
348
+
349
+ ### Publishing
350
+
351
+ Note: ensure you have proper authorization before trying to publish new versions.
352
+
353
+ After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
354
+
355
+ 1. Merge Pull Request into master
356
+ 2. Update `lib/dbee/version.rb` using [semantic versioning](https://semver.org/)
357
+ 3. Install dependencies: `bundle`
358
+ 4. Update `CHANGELOG.md` with release notes
359
+ 5. Commit & push master to remote and ensure CI builds master successfully
360
+ 6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
361
+
362
+ ## Code of Conduct
363
+
364
+ Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/dbee/blob/master/CODE_OF_CONDUCT.md).
365
+
366
+ ## License
367
+
368
+ This project is MIT Licensed.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2019-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ require 'bundler/gem_tasks'
11
+ require 'rspec/core/rake_task'
12
+
13
+ RSpec::Core::RakeTask.new(:spec)
14
+
15
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # Copyright (c) 2018-present, Blue Marble Payroll, LLC
6
+ #
7
+ # This source code is licensed under the MIT license found in the
8
+ # LICENSE file in the root directory of this source tree.
9
+ #
10
+
11
+ require 'bundler/setup'
12
+ require 'dbee'
13
+
14
+ # You can add fixtures and/or initialization code here to make experimenting
15
+ # with your gem easier. You can also use a different console, if you like.
16
+
17
+ require 'pry'
18
+ Pry.start
data/dbee.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require './lib/dbee/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'dbee'
7
+ s.version = Dbee::VERSION
8
+ s.summary = 'Adhoc Reporting SQL Generator'
9
+
10
+ s.description = <<-DESCRIPTION
11
+ Dbee provides a simple-to-use data modeling and query API. The query API can produce SQL using other ORMs, such as Arel/ActiveRecord. The targeted use-case for Dbee is ad-hoc reporting, so the total SQL feature-set that Dbee supports is rather limited.
12
+ DESCRIPTION
13
+
14
+ s.authors = ['Matthew Ruggio']
15
+ s.email = ['mruggio@bluemarblepayroll.com']
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
+ s.homepage = 'https://github.com/bluemarblepayroll/dbee'
20
+ s.license = 'MIT'
21
+
22
+ s.required_ruby_version = '>= 2.3.8'
23
+
24
+ s.add_dependency('acts_as_hashable', '~>1', '>=1.1.0')
25
+
26
+ s.add_development_dependency('guard-rspec', '~>4.7')
27
+ s.add_development_dependency('pry', '~>0')
28
+ s.add_development_dependency('rake', '~> 12')
29
+ s.add_development_dependency('rspec')
30
+ s.add_development_dependency('rubocop', '~>0.63.1')
31
+ s.add_development_dependency('simplecov', '~>0.16.1')
32
+ s.add_development_dependency('simplecov-console', '~>0.4.2')
33
+ end