web47core 0.0.2 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af1bad8d861e580ccbc908feec75cb5bed7dca82b71a8f297e6f502b33b343be
4
- data.tar.gz: 590cb3d1ae902d0599505a75362b56d5a947b024771a83183298f99efab14372
3
+ metadata.gz: 4fcbe8a6af006b83e043ed3a844a0204f2b48f1373c2403a3fbd823b20cadd8a
4
+ data.tar.gz: 65d2aebcd8a3b59742f7d01ccbe6aeebb612df2d187f1eb9e07ae475c9027d33
5
5
  SHA512:
6
- metadata.gz: dd1aa9e18ec6d833ccc1476edb7ab86281c6d5f604f38b94eb60570bda19ed8b6c6c2e50cb8e972ab5139a24f98e2decfd3a46934739c67f6914b719ca85e094
7
- data.tar.gz: 367b9a52a6c1ec773b00c21c01116a661b6d6fdec50bc093f33369d70caa74f253fda20cf6f2c69d53f663e041a6109bb8861b71441c9c258591f4c6d1508c8b
6
+ metadata.gz: e92b025b5e9d068db7a50c12af80081f131e71c5291853f6150ad0ed0ec0e9e4d1f4f172b197aa071068256a8226aaac42967377141dc3a8f571915102eff1a4
7
+ data.tar.gz: 0c21a7924482f948f40511c4575971d81387a84c88f214e8df039ffe1c0aa7980e8a025fc8efb0587e470a9ca5186362b9f400cad668b0c252d3ee950c1d59ea
@@ -0,0 +1,58 @@
1
+ #
2
+ # All-in-one
3
+ #
4
+ # This test configuration runs all tests in a single job.
5
+ #
6
+ version: 2.1
7
+
8
+ commands:
9
+ setup_environment:
10
+ description: Run the tests for a given directory in the test folder
11
+ steps:
12
+ - checkout
13
+ - restore_cache:
14
+ keys:
15
+ - app47-webcore-gem-cache-v2-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
16
+ - run:
17
+ name: Version information
18
+ shell: /bin/bash -l
19
+ command: |
20
+ mongod --version;
21
+ redis-server --version;
22
+ ruby --version;
23
+ gem --version;
24
+ bundle --version;
25
+ - run:
26
+ name: Setup environment
27
+ shell: /bin/bash -l
28
+ command: |
29
+ mkdir -p ./log;
30
+ bundle install --path=vendor --jobs=4 --retry=3;
31
+ redis-server --daemonize yes;
32
+ mongod -smallfiles -nojournal --fork --logpath /var/log/mongodb.log;
33
+ - save_cache:
34
+ key: app47-webcore-gem-cache-v2-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
35
+ paths:
36
+ - vendor
37
+
38
+ executors:
39
+ webcore_executor:
40
+ docker:
41
+ - image: app47/bionic:latest
42
+ environment:
43
+ - ENV: CI
44
+ - REDIS_URL: redis://localhost:6379
45
+ - MONGO_URL: localhost:27017
46
+ - RACK_ENV: test
47
+ - RAILS_ENV: test
48
+ - COVERAGE: 1
49
+
50
+ jobs:
51
+ build:
52
+ executor: webcore_executor
53
+ steps:
54
+ - setup_environment
55
+ - run:
56
+ name: Run tests
57
+ shell: /bin/bash -l
58
+ command: bundle exec rake test
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.rbc
2
+ *.gem
2
3
  capybara-*.html
3
4
  .rspec
4
5
  /db/*.sqlite3
@@ -6,6 +7,8 @@ capybara-*.html
6
7
  /db/*.sqlite3-[0-9]*
7
8
  /public/system
8
9
  /coverage/
10
+ /vendor/
11
+ /.idea/
9
12
  /spec/tmp
10
13
  *.orig
11
14
  rerun.txt
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'test/**/*'
4
+ - 'vendor/**/*'
5
+ - 'bin/**/*'
6
+
7
+ Metrics/LineLength:
8
+ Max: 120
9
+
10
+ Metrics/ClassLength:
11
+ Max: 600
12
+
13
+ Metrics/ModuleLength:
14
+ Max: 600
15
+
16
+ Metrics/MethodLength:
17
+ Max: 40
18
+
19
+ Metrics/AbcSize:
20
+ Max: 40
21
+
22
+ Metrics/CyclomaticComplexity:
23
+ Max: 15
24
+
25
+ Metrics/PerceivedComplexity:
26
+ Max: 15
27
+
28
+ Style/FrozenStringLiteralComment:
29
+ Enabled: false
30
+
31
+ Naming/RescuedExceptionsVariableName:
32
+ PreferredName: error
33
+
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'https://rubygems.org'
2
+ ruby '2.4.1'
3
+
4
+ git_source(:github) do |repo_name|
5
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
6
+ "https://github.com/#{repo_name}.git"
7
+ end
8
+
9
+ # Specify your gem's dependencies
10
+ gemspec
11
+
12
+ gem 'aws-sdk-ec2'
13
+ gem 'jwt'
14
+ gem 'mongoid', '~> 6.4'
15
+
16
+ group :test do
17
+ gem 'simplecov'
18
+ gem 'simplecov-lcov'
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,277 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ web47core (0.0.7)
5
+ activesupport (~> 5.0)
6
+ aws-sdk-ec2 (>= 1.60, <= 1.151)
7
+ delayed_job_mongoid (~> 2.3)
8
+ jwt
9
+ mongoid (> 6, < 7)
10
+ rails (>= 4.2, < 5.3)
11
+ redis (~> 4.1)
12
+ redis-rails (> 5, < 6)
13
+
14
+ GEM
15
+ remote: https://rubygems.org/
16
+ specs:
17
+ actioncable (5.2.4.2)
18
+ actionpack (= 5.2.4.2)
19
+ nio4r (~> 2.0)
20
+ websocket-driver (>= 0.6.1)
21
+ actionmailer (5.2.4.2)
22
+ actionpack (= 5.2.4.2)
23
+ actionview (= 5.2.4.2)
24
+ activejob (= 5.2.4.2)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
27
+ actionpack (5.2.4.2)
28
+ actionview (= 5.2.4.2)
29
+ activesupport (= 5.2.4.2)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
34
+ actionview (5.2.4.2)
35
+ activesupport (= 5.2.4.2)
36
+ builder (~> 3.1)
37
+ erubi (~> 1.4)
38
+ rails-dom-testing (~> 2.0)
39
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
40
+ activejob (5.2.4.2)
41
+ activesupport (= 5.2.4.2)
42
+ globalid (>= 0.3.6)
43
+ activemodel (5.2.4.2)
44
+ activesupport (= 5.2.4.2)
45
+ activerecord (5.2.4.2)
46
+ activemodel (= 5.2.4.2)
47
+ activesupport (= 5.2.4.2)
48
+ arel (>= 9.0)
49
+ activestorage (5.2.4.2)
50
+ actionpack (= 5.2.4.2)
51
+ activerecord (= 5.2.4.2)
52
+ marcel (~> 0.3.1)
53
+ activesupport (5.2.4.2)
54
+ concurrent-ruby (~> 1.0, >= 1.0.2)
55
+ i18n (>= 0.7, < 2)
56
+ minitest (~> 5.1)
57
+ tzinfo (~> 1.1)
58
+ addressable (2.7.0)
59
+ public_suffix (>= 2.0.2, < 5.0)
60
+ ansi (1.5.0)
61
+ arel (9.0.0)
62
+ aws-eventstream (1.0.3)
63
+ aws-partitions (1.286.0)
64
+ aws-sdk-core (3.92.0)
65
+ aws-eventstream (~> 1.0, >= 1.0.2)
66
+ aws-partitions (~> 1, >= 1.239.0)
67
+ aws-sigv4 (~> 1.1)
68
+ jmespath (~> 1.0)
69
+ aws-sdk-ec2 (1.151.0)
70
+ aws-sdk-core (~> 3, >= 3.71.0)
71
+ aws-sigv4 (~> 1.1)
72
+ aws-sigv4 (1.1.1)
73
+ aws-eventstream (~> 1.0, >= 1.0.2)
74
+ bson (4.8.2)
75
+ builder (3.2.4)
76
+ capybara (2.18.0)
77
+ addressable
78
+ mini_mime (>= 0.1.3)
79
+ nokogiri (>= 1.3.3)
80
+ rack (>= 1.0.0)
81
+ rack-test (>= 0.5.4)
82
+ xpath (>= 2.0, < 4.0)
83
+ codacy-coverage (2.1.5)
84
+ simplecov
85
+ concurrent-ruby (1.1.6)
86
+ crack (0.4.3)
87
+ safe_yaml (~> 1.0.0)
88
+ crass (1.0.6)
89
+ database_cleaner (1.8.3)
90
+ delayed_job (4.1.8)
91
+ activesupport (>= 3.0, < 6.1)
92
+ delayed_job_mongoid (2.3.1)
93
+ delayed_job (>= 3.0, < 5)
94
+ mongoid (>= 3.0, < 8)
95
+ mongoid-compatibility (>= 0.4.0)
96
+ docile (1.3.2)
97
+ erubi (1.9.0)
98
+ factory_bot (5.1.1)
99
+ activesupport (>= 4.2.0)
100
+ factory_bot_rails (5.1.1)
101
+ factory_bot (~> 5.1.0)
102
+ railties (>= 4.2.0)
103
+ ffi (1.12.2)
104
+ globalid (0.4.2)
105
+ activesupport (>= 4.2.0)
106
+ hashdiff (1.0.1)
107
+ i18n (1.8.2)
108
+ concurrent-ruby (~> 1.0)
109
+ jmespath (1.4.0)
110
+ json (2.3.0)
111
+ jwt (2.2.1)
112
+ listen (3.2.1)
113
+ rb-fsevent (~> 0.10, >= 0.10.3)
114
+ rb-inotify (~> 0.9, >= 0.9.10)
115
+ loofah (2.4.0)
116
+ crass (~> 1.0.2)
117
+ nokogiri (>= 1.5.9)
118
+ mail (2.7.1)
119
+ mini_mime (>= 0.1.1)
120
+ marcel (0.3.3)
121
+ mimemagic (~> 0.3.2)
122
+ method_source (1.0.0)
123
+ mimemagic (0.3.4)
124
+ mini_mime (1.0.2)
125
+ mini_portile2 (2.4.0)
126
+ minitest (5.10.3)
127
+ minitest-capybara (0.9.0)
128
+ capybara
129
+ minitest (~> 5.0)
130
+ rake
131
+ minitest-metadata (0.6.0)
132
+ minitest (>= 4.7, < 6.0)
133
+ minitest-rails (3.0.0)
134
+ minitest (~> 5.8)
135
+ railties (~> 5.0)
136
+ minitest-rails-capybara (3.0.1)
137
+ capybara (~> 2.7)
138
+ minitest-capybara (~> 0.8)
139
+ minitest-metadata (~> 0.6)
140
+ minitest-rails (~> 3.0)
141
+ minitest-reporters (1.4.2)
142
+ ansi
143
+ builder
144
+ minitest (>= 5.0)
145
+ ruby-progressbar
146
+ mocha (1.11.2)
147
+ mongo (2.11.4)
148
+ bson (>= 4.4.2, < 5.0.0)
149
+ mongoid (6.4.4)
150
+ activemodel (>= 5.1, < 6.0.0)
151
+ mongo (>= 2.5.1, < 3.0.0)
152
+ mongoid-compatibility (0.5.1)
153
+ activesupport
154
+ mongoid (>= 2.0)
155
+ nio4r (2.5.2)
156
+ nokogiri (1.10.9)
157
+ mini_portile2 (~> 2.4.0)
158
+ power_assert (1.1.7)
159
+ public_suffix (4.0.3)
160
+ rack (2.2.2)
161
+ rack-test (1.1.0)
162
+ rack (>= 1.0, < 3)
163
+ rails (5.2.4.2)
164
+ actioncable (= 5.2.4.2)
165
+ actionmailer (= 5.2.4.2)
166
+ actionpack (= 5.2.4.2)
167
+ actionview (= 5.2.4.2)
168
+ activejob (= 5.2.4.2)
169
+ activemodel (= 5.2.4.2)
170
+ activerecord (= 5.2.4.2)
171
+ activestorage (= 5.2.4.2)
172
+ activesupport (= 5.2.4.2)
173
+ bundler (>= 1.3.0)
174
+ railties (= 5.2.4.2)
175
+ sprockets-rails (>= 2.0.0)
176
+ rails-dom-testing (2.0.3)
177
+ activesupport (>= 4.2.0)
178
+ nokogiri (>= 1.6)
179
+ rails-html-sanitizer (1.3.0)
180
+ loofah (~> 2.3)
181
+ railties (5.2.4.2)
182
+ actionpack (= 5.2.4.2)
183
+ activesupport (= 5.2.4.2)
184
+ method_source
185
+ rake (>= 0.8.7)
186
+ thor (>= 0.19.0, < 2.0)
187
+ rake (13.0.1)
188
+ rb-fsevent (0.10.3)
189
+ rb-inotify (0.10.1)
190
+ ffi (~> 1.0)
191
+ redis (4.1.3)
192
+ redis-actionpack (5.2.0)
193
+ actionpack (>= 5, < 7)
194
+ redis-rack (>= 2.1.0, < 3)
195
+ redis-store (>= 1.1.0, < 2)
196
+ redis-activesupport (5.2.0)
197
+ activesupport (>= 3, < 7)
198
+ redis-store (>= 1.3, < 2)
199
+ redis-rack (2.1.2)
200
+ rack (>= 2.0.8, < 3)
201
+ redis-store (>= 1.2, < 2)
202
+ redis-rails (5.0.2)
203
+ redis-actionpack (>= 5.0, < 6)
204
+ redis-activesupport (>= 5.0, < 6)
205
+ redis-store (>= 1.2, < 2)
206
+ redis-store (1.8.2)
207
+ redis (>= 4, < 5)
208
+ ruby-progressbar (1.10.1)
209
+ safe_yaml (1.0.5)
210
+ shoulda (3.6.0)
211
+ shoulda-context (~> 1.0, >= 1.0.1)
212
+ shoulda-matchers (~> 3.0)
213
+ shoulda-context (1.2.2)
214
+ shoulda-matchers (3.1.2)
215
+ activesupport (>= 4.0.0)
216
+ simplecov (0.16.1)
217
+ docile (~> 1.1)
218
+ json (>= 1.8, < 3)
219
+ simplecov-html (~> 0.10.0)
220
+ simplecov-html (0.10.2)
221
+ simplecov-lcov (0.8.0)
222
+ sprockets (3.7.2)
223
+ concurrent-ruby (~> 1.0)
224
+ rack (> 1, < 3)
225
+ sprockets-rails (3.2.1)
226
+ actionpack (>= 4.0)
227
+ activesupport (>= 4.0)
228
+ sprockets (>= 3.0.0)
229
+ test-unit (3.3.5)
230
+ power_assert
231
+ thor (1.0.1)
232
+ thread_safe (0.3.6)
233
+ tzinfo (1.2.6)
234
+ thread_safe (~> 0.1)
235
+ vcr (5.1.0)
236
+ webmock (3.8.3)
237
+ addressable (>= 2.3.6)
238
+ crack (>= 0.3.2)
239
+ hashdiff (>= 0.4.0, < 2.0.0)
240
+ websocket-driver (0.7.1)
241
+ websocket-extensions (>= 0.1.0)
242
+ websocket-extensions (0.1.4)
243
+ xpath (3.2.0)
244
+ nokogiri (~> 1.8)
245
+
246
+ PLATFORMS
247
+ ruby
248
+
249
+ DEPENDENCIES
250
+ aws-sdk-ec2
251
+ bundler
252
+ codacy-coverage (~> 2.1.0)
253
+ database_cleaner
254
+ factory_bot
255
+ factory_bot_rails
256
+ jwt
257
+ listen
258
+ minitest (= 5.10.3)
259
+ minitest-rails (= 3.0.0)
260
+ minitest-rails-capybara (= 3.0.1)
261
+ minitest-reporters
262
+ mocha
263
+ mongoid (~> 6.4)
264
+ shoulda (= 3.6.0)
265
+ shoulda-matchers (= 3.1.2)
266
+ simplecov
267
+ simplecov-lcov
268
+ test-unit
269
+ vcr
270
+ web47core!
271
+ webmock
272
+
273
+ RUBY VERSION
274
+ ruby 2.4.1p111
275
+
276
+ BUNDLED WITH
277
+ 1.17.3
data/README.md CHANGED
@@ -1,2 +1,40 @@
1
1
  # web47core
2
2
  Core components used commonly among all web apps for both App47 and RedMonocle
3
+
4
+ ## Requirements
5
+
6
+ * Ruby 2.4.1
7
+
8
+ ### Working with Bundler and RVM
9
+
10
+ This project manages Ruby versions via [RVM](http://rvm.beginrescueend.com/) and manages dependencies via [Bundler](http://gembundler.com/).
11
+
12
+ You must first [install RVM](http://rvm.beginrescueend.com/rvm/install/).
13
+ Then install Ruby 2.4.1 ([version 2.4.1-p111](http://rvm.beginrescueend.com/interpreters/ruby/)) via RVM.
14
+ ```
15
+ rvm install 2.4.1
16
+ ```
17
+ You'll now notice that this project (as well as other App47 ones) contains a .rvmc file, which is executed upon opening the project's root directory in a terminal (and IDE's like RubyMine). The .rvmc file simply states `rvm ruby-2.4.1` which tells RVM to ensure the Ruby version to use for this project is 2.4.1.
18
+
19
+ Please note, your Ruby `2.4.1` version might need bundler installed:
20
+ ```
21
+ gem install bundler -v 1.17.3
22
+ ```
23
+
24
+ To set up this project's dependencies, which are defined in the file, `Gemfile`, you should first run
25
+ ```
26
+ bundle install --path vendor
27
+ ```
28
+ The `--path vendor` simply puts all gem files in a `vendor` directory.
29
+
30
+ # Development
31
+
32
+ Your `RubyMine` environment should be setup now, however to verify all is well, please run the test suite
33
+ ```
34
+ bundle exec rake test
35
+ ```
36
+
37
+ # Deployment
38
+ The `web47core` project is a gem that will be deployed via [Ruby Gems](https://rubygems.org). When an update is ready, the following steps should be followed
39
+
40
+ 1. Build the gem `gem build`
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative 'test/test_helper'
7
+ Rails.application.load_tasks
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Clear the Rails.cache when this object is saved. This prevents a number of
5
+ # caching issues over time where we've put it in cache, but the update doesn't appear
6
+ # until that cache expires.
7
+ #
8
+ module AutoClearCache
9
+ extend ActiveSupport::Concern
10
+
11
+ #
12
+ # Add the call backs to the class being included.
13
+ #
14
+ def self.included(base)
15
+ base.class_eval do
16
+ # Add the call back to the class
17
+ after_save :clear_cache
18
+ before_destroy :clear_cache
19
+ end
20
+ end
21
+
22
+ #
23
+ # Clear the cache
24
+ #
25
+ def clear_cache
26
+ Rails.cache.delete_matched "*#{id}*"
27
+ return unless respond_to?(:account) && account.present? && account.is_a?(Account)
28
+
29
+ Rails.cache.delete_matched "*#{account.id}*"
30
+ true # Force a return of true so that we don't break the callback chain.
31
+ rescue StandardError
32
+ false
33
+ end
34
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Take an existing either paperclip object or database field and return
5
+ # a fully qualified cdn url for that file.
6
+ #
7
+ # If the system configuration parameter for the url is not set, then simply return the value.
8
+ #
9
+ # If it is set, then replace the prefix of the URL defined by the boundry of class name, so account_report will be
10
+ # https://original.amazon.com/account_report/id/report.xlsx
11
+ #
12
+ # will be transposed to:
13
+ # https://cnd.apazon.com/account_report/id/report.xlsx
14
+ #
15
+ # To use this, first include CdnUrl in your class and then when you want the URL of an object call
16
+ # report.cdn_file_url instead of report.file_url.
17
+ #
18
+ module CdnUrl
19
+ extend ActiveSupport::Concern
20
+
21
+ def method_missing(method, *args)
22
+ if method.to_s.start_with? 'cdn_'
23
+ url = if args.blank?
24
+ send method.to_s.sub(/^cdn_/, '').to_sym
25
+ else
26
+ send method.to_s.sub(/^cdn_/, '').to_sym, *args
27
+ end
28
+
29
+ cdn_url = SystemConfiguration.cdn_url
30
+ if [cdn_url.present?, url.present?].all?
31
+ model_name = "#{self.class.to_s.underscore}s"
32
+ if url.include? "/#{model_name}/"
33
+ "#{cdn_url}/#{model_name}/#{url.split("/#{model_name}/").last}"
34
+ else
35
+ url
36
+ end
37
+ else
38
+ url
39
+ end
40
+ else
41
+ super
42
+ end
43
+ end
44
+
45
+ def respond_to_missing?(method_name, include_private = false)
46
+ super || method_name.to_s.start_with?('cdn_')
47
+ end
48
+
49
+ def respond_to?(method, include_private = false)
50
+ super || method.to_s.start_with?('cdn_')
51
+ end
52
+ end