eddy-rails 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 854caab65b490c3de6940d909a8fe7ad21912a107816e1db0118ee78e62db0b0
4
+ data.tar.gz: e7eeb3dd168f9b6e891994176c26b8fbd69effd5ce5e1a242a7d4c2f9ae974e2
5
+ SHA512:
6
+ metadata.gz: d15045f76e0d8741e52a970637777c5f95b9b16d222a9a0a4d7573aeaa39a2cde7bb09b3ac698833196ff2be64463260c97639d11eafb88a642eb97974ebcde5
7
+ data.tar.gz: 17b26efeb0528e52b0835965e8eefdcfca71e8b52bc2dd08e019f4735787601d715dc651dda0c6261e68f672b422248796d594d8997a62c402d75d32603a1636
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/log/*.log
5
+ test/dummy/storage/
6
+ test/dummy/tmp/
7
+ coverage
8
+ .yardoc
data/.rubocop.yml ADDED
@@ -0,0 +1,226 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3.0
3
+
4
+ # Don't leave calls to pry lying around.
5
+ Lint/Debugger:
6
+ Enabled: true
7
+
8
+ # ==============================================================================
9
+ # Documentation
10
+ # ==============================================================================
11
+
12
+ Style/Documentation:
13
+ Enabled: true
14
+ Exclude:
15
+ - 'test/**/*.rb'
16
+ - 'db/**/*.rb'
17
+
18
+ Style/DocumentationMethod:
19
+ Enabled: true
20
+ Exclude:
21
+ - 'test/**/*.rb'
22
+ - 'db/**/*.rb'
23
+
24
+ # ==============================================================================
25
+ # Naming
26
+ # ==============================================================================
27
+
28
+ Naming/MethodParameterName:
29
+ AllowedNames:
30
+ - el
31
+ - id
32
+
33
+ Naming/MethodName:
34
+ Enabled: true
35
+ Exclude:
36
+ - 'lib/definitions/**/*.rb'
37
+ - 'build/**/*.rb'
38
+
39
+ Naming/ClassAndModuleCamelCase:
40
+ Enabled: true
41
+ Exclude:
42
+ - 'lib/definitions/**/*.rb'
43
+ - 'build/**/*.rb'
44
+
45
+ # ==============================================================================
46
+ # Layout
47
+ # ==============================================================================
48
+
49
+ Metrics/LineLength:
50
+ Max: 150
51
+
52
+ Layout/EmptyLineAfterGuardClause:
53
+ Enabled: false
54
+
55
+ Layout/EmptyLinesAroundModuleBody:
56
+ Enabled: false
57
+
58
+ Layout/EmptyLinesAroundClassBody:
59
+ Enabled: false
60
+
61
+ Layout/EmptyLinesAroundBlockBody:
62
+ Enabled: false
63
+
64
+ # https://unix.stackexchange.com/a/18789
65
+ Layout/TrailingEmptyLines:
66
+ EnforcedStyle: final_newline
67
+
68
+ # ==============================================================================
69
+ # Strings
70
+ # ==============================================================================
71
+
72
+ Style/StringLiterals:
73
+ EnforcedStyle: double_quotes
74
+
75
+ Style/FrozenStringLiteralComment:
76
+ Enabled: false
77
+
78
+ Naming/HeredocDelimiterNaming:
79
+ Enabled: false
80
+
81
+ Style/FormatString:
82
+ EnforcedStyle: sprintf
83
+
84
+ # ==============================================================================
85
+ # Numbers
86
+ # ==============================================================================
87
+
88
+ Style/ZeroLengthPredicate:
89
+ Enabled: false
90
+
91
+ Style/NumericPredicate:
92
+ Enabled: false
93
+
94
+ # preferably `EnforcedStyle: snake_case`, but it varies.
95
+ Naming/VariableNumber:
96
+ Enabled: false
97
+
98
+ # ==============================================================================
99
+ # Braces, Brackets, and Parentheses
100
+ # ==============================================================================
101
+
102
+ Style/DefWithParentheses:
103
+ Enabled: false
104
+
105
+ Style/MethodCallWithoutArgsParentheses:
106
+ Enabled: false
107
+
108
+ # Only use braces if the function expects a hash argument. [different in Ruby 2.7+](https://blog.saeloun.com/2019/10/07/ruby-2-7-keyword-arguments-redesign.html)
109
+ Style/BracesAroundHashParameters:
110
+ Enabled: false
111
+
112
+ Style/WordArray:
113
+ EnforcedStyle: brackets
114
+
115
+ Style/SymbolArray:
116
+ EnforcedStyle: brackets
117
+
118
+ # ==============================================================================
119
+ # Trailing Commas
120
+ # ==============================================================================
121
+
122
+ Style/TrailingCommaInArguments:
123
+ EnforcedStyleForMultiline: comma
124
+
125
+ Style/TrailingCommaInArrayLiteral:
126
+ EnforcedStyleForMultiline: comma
127
+
128
+ Style/TrailingCommaInHashLiteral:
129
+ EnforcedStyleForMultiline: comma
130
+
131
+ # ==============================================================================
132
+ # Fewer lines doesn't mean better code
133
+ # ==============================================================================
134
+
135
+ Metrics/ModuleLength:
136
+ Enabled: false
137
+
138
+ Metrics/ClassLength:
139
+ Enabled: false
140
+
141
+ Metrics/MethodLength:
142
+ Enabled: false
143
+
144
+ Metrics/BlockLength:
145
+ Enabled: false
146
+
147
+ # TODO: Look into adding an `EnforcedStyle` to not use guard clauses.
148
+ Style/GuardClause:
149
+ Enabled: false
150
+
151
+ # TODO: Look into adding an `EnforcedStyle` to not use if/unless modifiers.
152
+ Style/IfUnlessModifier:
153
+ Enabled: false
154
+
155
+ Style/Next:
156
+ Enabled: false
157
+
158
+ # ==============================================================================
159
+ # Explicit, not redundant
160
+ # ==============================================================================
161
+
162
+ Style/RedundantReturn:
163
+ Enabled: false
164
+
165
+ Style/RedundantSelf:
166
+ Enabled: false
167
+
168
+ # ==============================================================================
169
+ # Exceptions
170
+ # ==============================================================================
171
+
172
+ Lint/SuppressedException:
173
+ AllowComments: true
174
+
175
+ Style/RaiseArgs:
176
+ EnforcedStyle: exploded
177
+
178
+ # ==============================================================================
179
+ # Unsorted
180
+ # ==============================================================================
181
+
182
+ # Default value (special_inside_parentheses) is ridiculous.
183
+ # Look for yourself: https://www.rubydoc.info/gems/rubocop/0.69.0/RuboCop/Cop/Layout/IndentFirstHashElement
184
+ Layout/FirstHashElementIndentation:
185
+ EnforcedStyle: consistent
186
+
187
+ # Default value (special_inside_parentheses) is ridiculous.
188
+ # Look for yourself: https://www.rubydoc.info/gems/rubocop/0.69.0/RuboCop/Cop/Layout/IndentFirstArrayElement
189
+ Layout/FirstArrayElementIndentation:
190
+ EnforcedStyle: consistent
191
+
192
+ Layout/HashAlignment:
193
+ Enabled: false
194
+
195
+ # `x&.y&.[](:argument)` isn't what I'd call "readable".
196
+ # https://stackoverflow.com/questions/34794697/using-with-the-safe-navigation-operator-in-ruby
197
+ Style/SafeNavigation:
198
+ Enabled: false
199
+
200
+ Style/NegatedIf:
201
+ EnforcedStyle: postfix
202
+
203
+ # TODO: File issue to ignore enums when using `EnforcedStyle: assign_inside_condition`.
204
+ Style/ConditionalAssignment:
205
+ Enabled: false
206
+
207
+ Style/TernaryParentheses:
208
+ EnforcedStyle: require_parentheses_when_complex
209
+
210
+ Metrics/AbcSize:
211
+ Enabled: false
212
+
213
+ Metrics/CyclomaticComplexity:
214
+ Enabled: false
215
+
216
+ Metrics/PerceivedComplexity:
217
+ Enabled: false
218
+
219
+ Style/CommentedKeyword:
220
+ Enabled: False
221
+
222
+ Lint/EmptyWhen:
223
+ Enabled: false
224
+
225
+ Gemspec/OrderedDependencies:
226
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 2.0.2
8
+ services:
9
+ - postgresql
10
+ before_script:
11
+ - psql -c 'create database dummy_test;' -U postgres
12
+ - bundle exec rails db:migrate RAILS_ENV=test
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## 0.1.0 (2020-01-05)
9
+
10
+ Initial release.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,186 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eddy-rails (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (6.0.2.1)
10
+ actionpack (= 6.0.2.1)
11
+ nio4r (~> 2.0)
12
+ websocket-driver (>= 0.6.1)
13
+ actionmailbox (6.0.2.1)
14
+ actionpack (= 6.0.2.1)
15
+ activejob (= 6.0.2.1)
16
+ activerecord (= 6.0.2.1)
17
+ activestorage (= 6.0.2.1)
18
+ activesupport (= 6.0.2.1)
19
+ mail (>= 2.7.1)
20
+ actionmailer (6.0.2.1)
21
+ actionpack (= 6.0.2.1)
22
+ actionview (= 6.0.2.1)
23
+ activejob (= 6.0.2.1)
24
+ mail (~> 2.5, >= 2.5.4)
25
+ rails-dom-testing (~> 2.0)
26
+ actionpack (6.0.2.1)
27
+ actionview (= 6.0.2.1)
28
+ activesupport (= 6.0.2.1)
29
+ rack (~> 2.0, >= 2.0.8)
30
+ rack-test (>= 0.6.3)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
33
+ actiontext (6.0.2.1)
34
+ actionpack (= 6.0.2.1)
35
+ activerecord (= 6.0.2.1)
36
+ activestorage (= 6.0.2.1)
37
+ activesupport (= 6.0.2.1)
38
+ nokogiri (>= 1.8.5)
39
+ actionview (6.0.2.1)
40
+ activesupport (= 6.0.2.1)
41
+ builder (~> 3.1)
42
+ erubi (~> 1.4)
43
+ rails-dom-testing (~> 2.0)
44
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
45
+ activejob (6.0.2.1)
46
+ activesupport (= 6.0.2.1)
47
+ globalid (>= 0.3.6)
48
+ activemodel (6.0.2.1)
49
+ activesupport (= 6.0.2.1)
50
+ activerecord (6.0.2.1)
51
+ activemodel (= 6.0.2.1)
52
+ activesupport (= 6.0.2.1)
53
+ activestorage (6.0.2.1)
54
+ actionpack (= 6.0.2.1)
55
+ activejob (= 6.0.2.1)
56
+ activerecord (= 6.0.2.1)
57
+ marcel (~> 0.3.1)
58
+ activesupport (6.0.2.1)
59
+ concurrent-ruby (~> 1.0, >= 1.0.2)
60
+ i18n (>= 0.7, < 2)
61
+ minitest (~> 5.1)
62
+ tzinfo (~> 1.1)
63
+ zeitwerk (~> 2.2)
64
+ builder (3.2.4)
65
+ coderay (1.1.2)
66
+ concurrent-ruby (1.1.5)
67
+ coolkit (0.2.2)
68
+ coveralls (0.8.23)
69
+ json (>= 1.8, < 3)
70
+ simplecov (~> 0.16.1)
71
+ term-ansicolor (~> 1.3)
72
+ thor (>= 0.19.4, < 2.0)
73
+ tins (~> 1.6)
74
+ crass (1.0.5)
75
+ docile (1.3.2)
76
+ dry-inflector (0.2.0)
77
+ ecma-re-validator (0.2.0)
78
+ regexp_parser (~> 1.2)
79
+ eddy (0.5.0)
80
+ ginny (~> 0.6.3)
81
+ json_schemer (~> 0.2.8)
82
+ thor (~> 1.0.1)
83
+ erubi (1.9.0)
84
+ ginny (0.6.3)
85
+ coolkit (~> 0.2.2)
86
+ dry-inflector (~> 0.2.0)
87
+ globalid (0.4.2)
88
+ activesupport (>= 4.2.0)
89
+ hana (1.3.5)
90
+ i18n (1.7.0)
91
+ concurrent-ruby (~> 1.0)
92
+ json (2.3.0)
93
+ json_schemer (0.2.8)
94
+ ecma-re-validator (~> 0.2)
95
+ hana (~> 1.3)
96
+ regexp_parser (~> 1.5)
97
+ uri_template (~> 0.7)
98
+ loofah (2.4.0)
99
+ crass (~> 1.0.2)
100
+ nokogiri (>= 1.5.9)
101
+ mail (2.7.1)
102
+ mini_mime (>= 0.1.1)
103
+ marcel (0.3.3)
104
+ mimemagic (~> 0.3.2)
105
+ method_source (0.9.2)
106
+ mimemagic (0.3.3)
107
+ mini_mime (1.0.2)
108
+ mini_portile2 (2.4.0)
109
+ minitest (5.13.0)
110
+ nio4r (2.5.2)
111
+ nokogiri (1.10.7)
112
+ mini_portile2 (~> 2.4.0)
113
+ pg (1.2.1)
114
+ pry (0.12.2)
115
+ coderay (~> 1.1.0)
116
+ method_source (~> 0.9.0)
117
+ rack (2.0.8)
118
+ rack-test (1.1.0)
119
+ rack (>= 1.0, < 3)
120
+ rails (6.0.2.1)
121
+ actioncable (= 6.0.2.1)
122
+ actionmailbox (= 6.0.2.1)
123
+ actionmailer (= 6.0.2.1)
124
+ actionpack (= 6.0.2.1)
125
+ actiontext (= 6.0.2.1)
126
+ actionview (= 6.0.2.1)
127
+ activejob (= 6.0.2.1)
128
+ activemodel (= 6.0.2.1)
129
+ activerecord (= 6.0.2.1)
130
+ activestorage (= 6.0.2.1)
131
+ activesupport (= 6.0.2.1)
132
+ bundler (>= 1.3.0)
133
+ railties (= 6.0.2.1)
134
+ sprockets-rails (>= 2.0.0)
135
+ rails-dom-testing (2.0.3)
136
+ activesupport (>= 4.2.0)
137
+ nokogiri (>= 1.6)
138
+ rails-html-sanitizer (1.3.0)
139
+ loofah (~> 2.3)
140
+ railties (6.0.2.1)
141
+ actionpack (= 6.0.2.1)
142
+ activesupport (= 6.0.2.1)
143
+ method_source
144
+ rake (>= 0.8.7)
145
+ thor (>= 0.20.3, < 2.0)
146
+ rake (13.0.1)
147
+ regexp_parser (1.6.0)
148
+ simplecov (0.16.1)
149
+ docile (~> 1.1)
150
+ json (>= 1.8, < 3)
151
+ simplecov-html (~> 0.10.0)
152
+ simplecov-html (0.10.2)
153
+ sprockets (4.0.0)
154
+ concurrent-ruby (~> 1.0)
155
+ rack (> 1, < 3)
156
+ sprockets-rails (3.2.1)
157
+ actionpack (>= 4.0)
158
+ activesupport (>= 4.0)
159
+ sprockets (>= 3.0.0)
160
+ term-ansicolor (1.7.1)
161
+ tins (~> 1.0)
162
+ thor (1.0.1)
163
+ thread_safe (0.3.6)
164
+ tins (1.22.2)
165
+ tzinfo (1.2.6)
166
+ thread_safe (~> 0.1)
167
+ uri_template (0.7.0)
168
+ websocket-driver (0.7.1)
169
+ websocket-extensions (>= 0.1.0)
170
+ websocket-extensions (0.1.4)
171
+ zeitwerk (2.2.2)
172
+
173
+ PLATFORMS
174
+ ruby
175
+
176
+ DEPENDENCIES
177
+ coveralls (~> 0.8.23)
178
+ eddy (~> 0.5.0)
179
+ eddy-rails!
180
+ pg
181
+ pry
182
+ rails (~> 6.0.2, >= 6.0.2.1)
183
+ simplecov (~> 0.16)
184
+
185
+ BUNDLED WITH
186
+ 2.0.2
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Clay Dunston
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Eddy::Rails
2
+
3
+ [![Gem](https://img.shields.io/gem/v/eddy-rails)][rubygems]
4
+ [![Build Status](https://travis-ci.org/tcd/eddy-rails.svg?branch=master)][travis-ci]
5
+ [![Coverage Status](https://coveralls.io/repos/github/tcd/eddy-rails/badge.svg?branch=master)][coveralls]
6
+ [![License](https://img.shields.io/github/license/tcd/eddy)][license]
7
+ [![Documentation](http://img.shields.io/badge/docs-rubydoc.info-blue.svg)][docs]
8
+
9
+ [rubygems]: https://rubygems.org/gems/eddy-rails
10
+ [travis-ci]: https://travis-ci.org/tcd/eddy-rails
11
+ [coveralls]: https://coveralls.io/github/tcd/eddy-rails?branch=master
12
+ [license]: https://github.com/tcd/eddy-rails/blob/master/LICENSE
13
+ [docs]: https://www.rubydoc.info/gems/eddy-rails/1.0.0
14
+
15
+ Rails integration for [Eddy](https://github.com/tcd/eddy).
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem "eddy"
23
+ gem "eddy-rails"
24
+ ```
25
+
26
+ Next, you need to copy & run the migration:
27
+
28
+ ```sh
29
+ $ rails eddy:install # This will do both
30
+ ```
31
+
32
+ Then, optionally, generate an initializer file:
33
+
34
+ ```sh
35
+ $ rails generate eddy:initializer # This will do both
36
+ ```
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+ require "rdoc/task"
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = "rdoc"
11
+ rdoc.title = "Eddy::Rails"
12
+ rdoc.options << "--line-numbers"
13
+ rdoc.rdoc_files.include("README.md")
14
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load "rails/tasks/engine.rake"
19
+
20
+ load "rails/tasks/statistics.rake"
21
+
22
+ require "bundler/gem_tasks"
23
+
24
+ require "rake/testtask"
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << "test"
28
+ t.pattern = "test/**/*_test.rb"
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,7 @@
1
+ module Eddy
2
+ module Rails
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,41 @@
1
+ module Eddy::Rails
2
+ # Functional Group Control Number
3
+ class FGroupControlNumber < ApplicationRecord
4
+ # @!attribute number [rw]
5
+ # @return [Integer]
6
+ # @!attribute f_group [rw]
7
+ # @return [String]
8
+ # @!attribute sent [rw]
9
+ # @return [Boolean]
10
+ # @!attribute received [rw]
11
+ # @return [Boolean]
12
+ validates(
13
+ :f_group,
14
+ presence: true,
15
+ format: {
16
+ with: /\A[A-Z0-9]{2}\z/,
17
+ message: "%{value} is not a valid Functional Group",
18
+ },
19
+ # inclusion: {
20
+ # in: Eddy::Rails.functional_groups(),
21
+ # message: "%{value} is not a valid Functional Group",
22
+ # },
23
+ )
24
+ validates(
25
+ :number,
26
+ presence: true,
27
+ uniqueness: {
28
+ scope: :f_group,
29
+ message: "Functional Group Control Numbers must be unique within a Functional Group",
30
+ },
31
+ )
32
+
33
+ # @!method self.create!()
34
+ # @param number [Integer]
35
+ # @param f_group [String]
36
+ # @param sent [Boolean] (false)
37
+ # @param received [Boolean] (false)
38
+ # @return [self]
39
+
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ module Eddy::Rails
2
+ # Interchange Control Number
3
+ class InterchangeControlNumber < ApplicationRecord
4
+ # @!attribute number [rw]
5
+ # @return [Integer]
6
+ # @!attribute sent [rw]
7
+ # @return [Boolean]
8
+ # @!attribute received [rw]
9
+ # @return [Boolean]
10
+ validates(:number, uniqueness: true)
11
+
12
+ # @!method self.create!()
13
+ # @param number [Integer]
14
+ # @param sent [Boolean] (false)
15
+ # @param received [Boolean] (false)
16
+ # @return [self]
17
+
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ module Eddy::Rails
2
+ # Transaction Set Control Number
3
+ class TSetControlNumber < ApplicationRecord
4
+ # @!attribute number [rw]
5
+ # @return [Integer]
6
+ # @!attribute t_set [rw]
7
+ # @return [String]
8
+ # @!attribute sent [rw]
9
+ # @return [Boolean]
10
+ # @!attribute received [rw]
11
+ # @return [Boolean]
12
+ validates(
13
+ :t_set,
14
+ presence: true,
15
+ format: {
16
+ with: /\A[1-9][0-9]{2}\z/,
17
+ message: "%{value} is not a valid Transaction Set",
18
+ },
19
+ # inclusion: {
20
+ # in: Eddy::Rails.valid_transaction_sets(),
21
+ # message: "%{value} is not a valid Transaction Set",
22
+ # },
23
+ )
24
+ validates(
25
+ :number,
26
+ uniqueness: {
27
+ scope: :t_set,
28
+ message: "Transaction Set Control Numbers must be unique within a Transaction Set",
29
+ },
30
+ )
31
+
32
+ # @!method self.create!()
33
+ # @param number [Integer]
34
+ # @param t_set [String]
35
+ # @param sent [Boolean] (false)
36
+ # @param received [Boolean] (false)
37
+ # @return [self]
38
+
39
+ end
40
+ end
data/bin/rails ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path("..", __dir__)
6
+ ENGINE_PATH = File.expand_path("../lib/eddy/rails/engine", __dir__)
7
+ APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
11
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
12
+
13
+ require "rails"
14
+ # Pick the frameworks you want:
15
+ require "active_model/railtie"
16
+ # require "active_job/railtie"
17
+ require "active_record/railtie"
18
+ require "active_storage/engine"
19
+ # require "action_controller/railtie"
20
+ # require "action_mailer/railtie"
21
+ # require "action_view/railtie"
22
+ # require "action_cable/engine"
23
+ require "sprockets/railtie"
24
+ require "rails/test_unit/railtie"
25
+ require "rails/engine/commands"
@@ -0,0 +1,37 @@
1
+ class AddEddyTables < ActiveRecord::Migration[6.0]
2
+
3
+ def self.up
4
+ create_table :eddy_rails_interchange_control_numbers do |t|
5
+ t.integer(:number, null: false)
6
+ t.boolean(:received, default: false)
7
+ t.boolean(:sent, default: false)
8
+ t.timestamps(null: false)
9
+ end
10
+ add_index(:eddy_rails_interchange_control_numbers, :number, unique: true)
11
+
12
+ create_table :eddy_rails_f_group_control_numbers do |t|
13
+ t.integer(:number, null: false)
14
+ t.string(:f_group, null: false)
15
+ t.boolean(:received, default: false)
16
+ t.boolean(:sent, default: false)
17
+ t.timestamps(null: false)
18
+ end
19
+ add_index(:eddy_rails_f_group_control_numbers, [:number, :f_group], unique: true)
20
+
21
+ create_table :eddy_rails_t_set_control_numbers do |t|
22
+ t.integer(:number, null: false)
23
+ t.string(:t_set, null: false)
24
+ t.boolean(:received, default: false)
25
+ t.boolean(:sent, default: false)
26
+ t.timestamps(null: false)
27
+ end
28
+ add_index(:eddy_rails_t_set_control_numbers, [:number, :t_set], unique: true)
29
+ end
30
+
31
+ def self.down
32
+ drop_table(:eddy_interchange_control_numbers)
33
+ drop_table(:eddy_f_group_control_numbers)
34
+ drop_table(:eddy_t_set_control_numbers)
35
+ end
36
+
37
+ end
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "eddy-rails"
5
+ spec.version = "1.0.0"
6
+ spec.authors = ["Clay Dunston"]
7
+ spec.email = ["dunstontc@gmail.com"]
8
+ spec.homepage = "https://github.com/tcd/eddy-rails"
9
+ spec.summary = "Rails integration for Eddy"
10
+ spec.description = spec.summary
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = ">= 2.3.0"
13
+ spec.metadata = {
14
+ "homepage_uri" => spec.homepage,
15
+ "source_code_uri" => spec.homepage,
16
+ "changelog_uri" => "#{spec.homepage}/blob/master/CHANGELOG.md",
17
+ "documentation_uri" => "https://www.rubydoc.info/gems/#{spec.name}/#{spec.version}",
18
+ "yard.run" => "yri", # use "yard" to build full HTML docs.
19
+ }
20
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.add_development_dependency "coveralls", "~> 0.8.23"
24
+ spec.add_development_dependency "eddy", "~> 0.5.0"
25
+ spec.add_development_dependency "pg"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "rails", "~> 6.0.2", ">= 6.0.2.1"
28
+ spec.add_development_dependency "simplecov", "~> 0.16"
29
+ end
@@ -0,0 +1,77 @@
1
+ module Eddy
2
+ module Data
3
+ module Persistence
4
+ # Persist data to a database using Active Record.
5
+ class ActiveRecord
6
+
7
+ # @return [void]
8
+ def initialize()
9
+ unless defined?(Rails) && defined?(Eddy::Rails)
10
+ raise Eddy::Errors::Error, "ActiveRecord persistence method can currently only be used with Ruby on Rails"
11
+ end
12
+ end
13
+
14
+ # @return [Array<Integer>]
15
+ def interchange_control_numbers()
16
+ return Eddy::Rails::InterchangeControlNumber.select(:number).collect(&:number)
17
+ end
18
+
19
+ # @param functional_group [String]
20
+ # @return [Array<Integer>]
21
+ def functional_group_control_numbers(functional_group)
22
+ Eddy::Rails::FGroupControlNumber.where(f_group: functional_group).select(:number).collect(&:number)
23
+ end
24
+
25
+ # @param transaction_set_id [String]
26
+ # @return [Array<Integer>]
27
+ def transaction_set_control_numbers(transaction_set_id)
28
+ Eddy::Rails::TSetControlNumber.where(t_set: transaction_set_id).select(:number).collect(&:number)
29
+ end
30
+
31
+ # @param new_ctrl_num [Integer]
32
+ # @param sent [Boolean] (false)
33
+ # @param received [Boolean] (false)
34
+ # @return [Array<Integer>]
35
+ def add_interchange_control_number(new_ctrl_num, sent: false, received: false)
36
+ Eddy::Rails::InterchangeControlNumber.create!(
37
+ number: new_ctrl_num,
38
+ sent: sent,
39
+ received: received,
40
+ )
41
+ return self.interchange_control_numbers()
42
+ end
43
+
44
+ # @param functional_group [String]
45
+ # @param new_ctrl_num [Integer]
46
+ # @param sent [Boolean] (false)
47
+ # @param received [Boolean] (false)
48
+ # @return [Array<Integer>]
49
+ def add_functional_group_control_number(functional_group, new_ctrl_num, sent: false, received: false)
50
+ Eddy::Rails::FGroupControlNumber.create!(
51
+ number: new_ctrl_num,
52
+ f_group: functional_group,
53
+ sent: sent,
54
+ received: received,
55
+ )
56
+ return self.functional_group_control_numbers(functional_group)
57
+ end
58
+
59
+ # @param transaction_set_id [String]
60
+ # @param new_ctrl_num [Integer]
61
+ # @param sent [Boolean] (false)
62
+ # @param received [Boolean] (false)
63
+ # @return [Array<Integer>]
64
+ def add_transaction_set_control_number(transaction_set_id, new_ctrl_num, sent: false, received: false)
65
+ Eddy::Rails::TSetControlNumber.create!(
66
+ number: new_ctrl_num,
67
+ t_set: transaction_set_id,
68
+ sent: sent,
69
+ received: received,
70
+ )
71
+ return transaction_set_control_numbers(transaction_set_id)
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,10 @@
1
+ require "eddy"
2
+
3
+ module Eddy
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace(Eddy::Rails)
7
+ config.generators.api_only = true
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Eddy
2
+ module Rails
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
data/lib/eddy/rails.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "eddy/rails/engine"
2
+ require "eddy/rails/version"
3
+ require "eddy/data/persistence/active_record"
4
+
5
+ module Eddy
6
+ # Rails integration for Eddy
7
+ module Rails; end
8
+ end
@@ -0,0 +1,11 @@
1
+ # Generate an initializer file for Eddy.
2
+ class InitializerGenerator < Rails::Generators::Base
3
+ desc("This generator creates an initializer file at config/initializers/eddy.rb for Eddy")
4
+ source_root(File.expand_path("templates", __dir__))
5
+
6
+ # @return [void]
7
+ def copy_initializer
8
+ template("eddy.rb.erb", "config/initializers/eddy.rb")
9
+ end
10
+
11
+ end
@@ -0,0 +1,6 @@
1
+ Eddy.configure do |config|
2
+ config.env = Rails.env
3
+ config.persistence_method = :active_record
4
+ config.tmp_dir = Rails.root.join('tmp')
5
+ config.tmp_dir = Rails.root.join('tmp', 'build')
6
+ end
@@ -0,0 +1,13 @@
1
+ namespace :eddy do
2
+
3
+ desc "Copy & run migrations; copy initializer."
4
+ task :install, [] => :environment do
5
+ Rake::Task["eddy_rails:install:migrations"].invoke
6
+ Rake::Task["db:migrate"].invoke
7
+ end
8
+
9
+ # desc "Roll back & remove migrations; remove initializer."
10
+ # task :uninstall, [] => :environment do
11
+ # end
12
+
13
+ end
data/todo.txt ADDED
@@ -0,0 +1,2 @@
1
+ 2019-12-20 Add a DB persistence_method.
2
+ 2019-12-20 Check for conflicts in Rails generators.
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eddy-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Clay Dunston
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coveralls
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.23
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.23
27
+ - !ruby/object:Gem::Dependency
28
+ name: eddy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pg
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 6.0.2
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 6.0.2.1
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: 6.0.2
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 6.0.2.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: simplecov
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.16'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.16'
103
+ description: Rails integration for Eddy
104
+ email:
105
+ - dunstontc@gmail.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rubocop.yml"
112
+ - ".travis.yml"
113
+ - CHANGELOG.md
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - LICENSE
117
+ - README.md
118
+ - Rakefile
119
+ - app/models/eddy/rails/application_record.rb
120
+ - app/models/eddy/rails/f_group_control_number.rb
121
+ - app/models/eddy/rails/interchange_control_number.rb
122
+ - app/models/eddy/rails/t_set_control_number.rb
123
+ - bin/rails
124
+ - db/migrate/20200106002448_add_eddy_tables.rb
125
+ - eddy-rails.gemspec
126
+ - lib/eddy/data/persistence/active_record.rb
127
+ - lib/eddy/rails.rb
128
+ - lib/eddy/rails/engine.rb
129
+ - lib/eddy/rails/version.rb
130
+ - lib/generators/eddy/initializer/initializer_generator.rb
131
+ - lib/generators/eddy/initializer/templates/eddy.rb.erb
132
+ - lib/tasks/eddy.rake
133
+ - todo.txt
134
+ homepage: https://github.com/tcd/eddy-rails
135
+ licenses:
136
+ - MIT
137
+ metadata:
138
+ homepage_uri: https://github.com/tcd/eddy-rails
139
+ source_code_uri: https://github.com/tcd/eddy-rails
140
+ changelog_uri: https://github.com/tcd/eddy-rails/blob/master/CHANGELOG.md
141
+ documentation_uri: https://www.rubydoc.info/gems/eddy-rails/1.0.0
142
+ yard.run: yri
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: 2.3.0
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubygems_version: 3.0.3
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Rails integration for Eddy
162
+ test_files: []