rails_ops 1.0.0.beta4 → 1.0.0.beta5
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 +4 -4
- data/.travis.yml +5 -3
- data/README.md +131 -45
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/rails_ops.rb +2 -2
- data/lib/rails_ops/log_subscriber.rb +8 -2
- data/lib/rails_ops/profiler.rb +9 -4
- data/lib/rails_ops/profiler/node.rb +10 -1
- data/rails_ops.gemspec +8 -5
- data/test/db/models.rb +2 -0
- data/test/db/schema.rb +9 -0
- data/test/rails_ops/operation/example_test.rb +14 -0
- data/test/test_helper.rb +17 -1
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46e7e8c4aec95a02b0db851c931203119eecc157
|
4
|
+
data.tar.gz: 2a6b11cb2f4059d200da3d6f3156dd02ec8529e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cdfac5b95544a4569543bdcebb2a8cc2d939805484d1df1b46ccc199e5ea1e0b2f6f2b1b8d861fdaada0f18da8ca2206c5e71acc3e3e057b0f44726e0420fe3
|
7
|
+
data.tar.gz: c7455c525dd4dafd1b64a09b23dd1b3dc828c76c75cb890fab797fc7f9bb478cfaf7132aa09e8cb43820dddcc593c73aa5e52e47ebcfdc88f944602dfeadb079
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
+
[](https://travis-ci.org/sitrox/rails_ops)
|
1
2
|
[](https://badge.fury.io/rb/rails_ops)
|
2
3
|
|
3
4
|
rails_ops
|
4
5
|
=========
|
5
6
|
|
6
|
-
**This Gem is still under development and is not to be used in production yet.**
|
7
|
-
|
8
7
|
This Gem introduces an additional service layer for Rails: *Operations*. An
|
9
8
|
operation is in most cases a *business action* or *use case* and may or may not
|
10
9
|
involve one or multiple models. Rails Ops allows creating more modular
|
@@ -18,6 +17,35 @@ To achieve this goal, this Gem provides the following building blocks:
|
|
18
17
|
|
19
18
|
- A way of abstracting model classes for a specific business action.
|
20
19
|
|
20
|
+
Requirements & Installation
|
21
|
+
---------------------------
|
22
|
+
|
23
|
+
### Requirements
|
24
|
+
|
25
|
+
- RailsOps only works with Rails applications and has been tested with Rails >=
|
26
|
+
5.0.
|
27
|
+
- Prior Rails versions may be supported but this has not been verified.
|
28
|
+
- Rails Ops' model operations require ActiveRecord but are database / adapter
|
29
|
+
agnostic
|
30
|
+
|
31
|
+
### Installation
|
32
|
+
|
33
|
+
1. Add the following to your Rails application's `Gemfile`:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'rails_ops'
|
37
|
+
```
|
38
|
+
|
39
|
+
2. Create an initializer file `config/initializers/rails_ops.rb` with the
|
40
|
+
following contents:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
RailsOps.configure do |config|
|
44
|
+
# Replace this with your authorization backend.
|
45
|
+
config.authorization_backend = 'RailsOps::AuthorizationBackend::CanCanCan'
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
21
49
|
Operation Basics
|
22
50
|
----------------
|
23
51
|
|
@@ -416,9 +444,6 @@ operations. Contexts can include the following data:
|
|
416
444
|
automatically generated when calling a sub-op or triggering an op using an
|
417
445
|
event (see chapter *Events* for more information on that).
|
418
446
|
|
419
|
-
TODO: This may induce memory issues. Is keeping the operation's chain worth
|
420
|
-
this trade-off?
|
421
|
-
|
422
447
|
- URL options
|
423
448
|
|
424
449
|
Rails uses a hash named `url_options` for generating URLs with correct prefix.
|
@@ -483,7 +508,7 @@ additional ones it's triggering:
|
|
483
508
|
using `Operations::Group::Create`. *This is an example for sub-ops*.
|
484
509
|
|
485
510
|
- `Operations::User::Create` creates a user. Whenever a user is created, another
|
486
|
-
part of the application needs to generate a
|
511
|
+
part of the application needs to generate a todo for the admin to approve this
|
487
512
|
user. *This would be an example for hooks*.
|
488
513
|
|
489
514
|
Hooks are pretty simple: Using the file `config/hookup.rb`, you can
|
@@ -712,8 +737,11 @@ Rails Ops offers multiple ways of disabling authorization:
|
|
712
737
|
end
|
713
738
|
```
|
714
739
|
|
715
|
-
|
716
|
-
|
740
|
+
If the operation is invoked using controller integration, this also disables
|
741
|
+
the controller-side check that makes sure an authorization method is called.
|
742
|
+
|
743
|
+
This does not disable authorization for any sub operations. See the next
|
744
|
+
section for information on how to disable sub operation authorization.
|
717
745
|
|
718
746
|
- By invoking one or more operations in a `RailsOps.without_authorization`
|
719
747
|
block:
|
@@ -769,7 +797,7 @@ inherit from {RailsOps::Operation::Model} (which in turn inherits from
|
|
769
797
|
The key principle behind these model classes is to associate *one model class*
|
770
798
|
and *one model instance* with a particular operation.
|
771
799
|
|
772
|
-
|
800
|
+
### Setting a model class
|
773
801
|
|
774
802
|
Using the static method `model`, you can assign a model class that is used in
|
775
803
|
the scope of this operation.
|
@@ -789,7 +817,7 @@ class SomeOperation < RailsOps::Operation::Model
|
|
789
817
|
model User do
|
790
818
|
# This code only runs in a dynamically created subclass of `User` and does
|
791
819
|
# not affect the original model class.
|
792
|
-
|
820
|
+
validates :name, presence: true
|
793
821
|
end
|
794
822
|
end
|
795
823
|
```
|
@@ -807,7 +835,7 @@ class SomeOperation < RailsOps::Operation::Model
|
|
807
835
|
end
|
808
836
|
```
|
809
837
|
|
810
|
-
|
838
|
+
### Obtaining a model instance
|
811
839
|
|
812
840
|
Model instances can be obtained using the *instance* method `model`, which is
|
813
841
|
not to be confused with the *class* method of the same name. Other than the
|
@@ -836,7 +864,7 @@ If no cached instance is found, one is built using the instance method
|
|
836
864
|
but only implemented in its subclasses. You can implement and override this
|
837
865
|
method to your liking though.
|
838
866
|
|
839
|
-
|
867
|
+
### Loading models
|
840
868
|
|
841
869
|
Using the base operation class {RailsOps::Operation::Model::Load}, a model can
|
842
870
|
be loaded. This is done by implementing the `build_model` mentioned above. In
|
@@ -866,7 +894,7 @@ op = Operations::User::Load.new(id: 5)
|
|
866
894
|
op.model.id # => 5
|
867
895
|
```
|
868
896
|
|
869
|
-
|
897
|
+
#### Specifying ID field
|
870
898
|
|
871
899
|
Per default, the model instance is looked up using the field `id` and the ID
|
872
900
|
obtained from the method params using `params[:id]`. However, you can customize
|
@@ -882,7 +910,7 @@ class Operations::User::Load < RailsOps::Operation::Model::Load
|
|
882
910
|
end
|
883
911
|
```
|
884
912
|
|
885
|
-
|
913
|
+
#### Locking
|
886
914
|
|
887
915
|
In most cases when you load a model, you might want to lock the corresponding
|
888
916
|
database record. RailsOps is configured to automatically perform this locking
|
@@ -899,7 +927,7 @@ class Operations::User::Load < RailsOps::Operation::Model::Load
|
|
899
927
|
end
|
900
928
|
```
|
901
929
|
|
902
|
-
|
930
|
+
### Creating models
|
903
931
|
|
904
932
|
For creating models, you can use the base class
|
905
933
|
{RailsOps::Operation::Model::Create}.
|
@@ -916,7 +944,7 @@ The `perform` method saves the record using `save!`.
|
|
916
944
|
As this base class is very minimalistic, it is recommended to fully read and
|
917
945
|
comprehend its source code.
|
918
946
|
|
919
|
-
|
947
|
+
### Updating models
|
920
948
|
|
921
949
|
For creating models, you can use the base class
|
922
950
|
{RailsOps::Operation::Model::Update} which is an extension of the `Load` base
|
@@ -934,7 +962,7 @@ The `perform` method saves the record using `save!`.
|
|
934
962
|
As this base class is very minimalistic, it is recommended to fully read and
|
935
963
|
comprehend its source code.
|
936
964
|
|
937
|
-
|
965
|
+
### Destroying models
|
938
966
|
|
939
967
|
For destroying models, you can use the base class
|
940
968
|
{RailsOps::Operation::Model::Destroy} which is an extension of the `Load` base
|
@@ -946,7 +974,7 @@ destroys the model using its `destroy!` method.
|
|
946
974
|
As this base class is very minimalistic, it is recommended to fully read and
|
947
975
|
comprehend its source code.
|
948
976
|
|
949
|
-
|
977
|
+
### Parameter extraction for create and update
|
950
978
|
|
951
979
|
As mentioned before, the `Create` and `Update` base classes provide an
|
952
980
|
implementation of `build_model` that assigns parameters to a model.
|
@@ -955,12 +983,12 @@ The attributes are determined by the operation instance method
|
|
955
983
|
`extract_attributes_from_params` - the name being self-explaining. See its
|
956
984
|
source code for implementation details.
|
957
985
|
|
958
|
-
|
986
|
+
### Model authorization
|
959
987
|
|
960
988
|
While you can use the standard `authorize!` method (see chapter *Authorization*)
|
961
989
|
for authorizing models, RailsOps provides a more convenient integration.
|
962
990
|
|
963
|
-
|
991
|
+
#### Basic authorization
|
964
992
|
|
965
993
|
Model authorization can be performed via the operation instance methods
|
966
994
|
`authorize_model!` and `authorize_model_with_authorize_only!` (see chapter
|
@@ -976,7 +1004,7 @@ methods instead of the basic authorization methods for authorizing models.
|
|
976
1004
|
If no model is given, the model authorization methods automatically obtain the
|
977
1005
|
model from the instance method `model`.
|
978
1006
|
|
979
|
-
|
1007
|
+
#### Automatic authorization
|
980
1008
|
|
981
1009
|
All model operation classes provide the operation instance method
|
982
1010
|
`model_authorization` which is automatically run at model instantiation (this is
|
@@ -1001,9 +1029,67 @@ end
|
|
1001
1029
|
Note that using the different model base classes, this is already set to a
|
1002
1030
|
sensible default. See the respective class' source code for details.
|
1003
1031
|
|
1004
|
-
|
1032
|
+
### Model nesting
|
1005
1033
|
|
1006
|
-
|
1034
|
+
Using active record, multiple nested models can be saved at once by using
|
1035
|
+
`accepts_nested_attributes_for`. While this is generally supported by RailsOps,
|
1036
|
+
you may want to consider saving nested models using their own operation.
|
1037
|
+
|
1038
|
+
For this case, RailsOps' create and update model operations provide the method
|
1039
|
+
`nest_model_op`.
|
1040
|
+
|
1041
|
+
```ruby
|
1042
|
+
class Operations::User::Create < RailsOps::Operation::Model::Create
|
1043
|
+
schema do
|
1044
|
+
opt :user do
|
1045
|
+
opt :name
|
1046
|
+
opt :group_attributes
|
1047
|
+
end
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
model ::User
|
1051
|
+
nest_model_op :group, Operations::Group::Create
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
class Operations::Group::Create < RailsOps::Operation::Model::Create
|
1055
|
+
schema :group do
|
1056
|
+
opt :name
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
model ::Group
|
1060
|
+
nest_model_op :group, Operations::Group::Create
|
1061
|
+
end
|
1062
|
+
```
|
1063
|
+
|
1064
|
+
In this example, the parent operation `Operations::User::Create` automatically
|
1065
|
+
instantiates a `Group::Create` operation and passes all the parameters to it
|
1066
|
+
that the parent operation received under `group_attributes`. The group is saved
|
1067
|
+
first. If this is successful, the user is saved.
|
1068
|
+
|
1069
|
+
Note that this feature only works with `belongs_to` associations with `autosave`
|
1070
|
+
set to `false` and is not compatible with `accepts_nested_attributes_for`:
|
1071
|
+
|
1072
|
+
```ruby
|
1073
|
+
class User
|
1074
|
+
belongs_to :group, autosave: false
|
1075
|
+
end
|
1076
|
+
```
|
1077
|
+
|
1078
|
+
#### Custom parameters
|
1079
|
+
|
1080
|
+
In the above examples, all `group_attributes` are automatically passed to the
|
1081
|
+
sub operation. To customize this further, provide a block to the `nest_model_op`
|
1082
|
+
method:
|
1083
|
+
|
1084
|
+
```ruby
|
1085
|
+
nest_model_op :group, Operations::Group::Create do |params|
|
1086
|
+
params.merge(custom_override: :some_value)
|
1087
|
+
end
|
1088
|
+
```
|
1089
|
+
|
1090
|
+
This block receives the params hash as it would be passed to the sub operation
|
1091
|
+
and allows to modify it. The block's return value is then passed to the
|
1092
|
+
sub-operation. Do not change the params inplace but instead return a new hash.
|
1007
1093
|
|
1008
1094
|
Record extension and virtual records
|
1009
1095
|
------------------------------------
|
@@ -1013,7 +1099,6 @@ Transactions
|
|
1013
1099
|
------------
|
1014
1100
|
|
1015
1101
|
|
1016
|
-
|
1017
1102
|
Controller Integration
|
1018
1103
|
----------------------
|
1019
1104
|
|
@@ -1021,7 +1106,7 @@ While RailsOps certainly does not have to be used from a controller, it
|
|
1021
1106
|
provides a mixin which extends controller classes with functionality that lets
|
1022
1107
|
you easily instantiate and run operations.
|
1023
1108
|
|
1024
|
-
|
1109
|
+
### Installing
|
1025
1110
|
|
1026
1111
|
Controller integration is designed to be non-intrusive and therefore has to be
|
1027
1112
|
installed manually. Add the following inclusion to the controllers in question
|
@@ -1033,7 +1118,7 @@ class ApplicationController
|
|
1033
1118
|
end
|
1034
1119
|
```
|
1035
1120
|
|
1036
|
-
|
1121
|
+
### Basic usage
|
1037
1122
|
|
1038
1123
|
The basic concept behind controller integration is to instantiate and
|
1039
1124
|
potentially run a single operation per request. Most of this guide refers to
|
@@ -1051,7 +1136,7 @@ class SomeController < ApplicationController
|
|
1051
1136
|
end
|
1052
1137
|
```
|
1053
1138
|
|
1054
|
-
|
1139
|
+
### Separating instantiation and execution
|
1055
1140
|
|
1056
1141
|
In the previous example, we instantiated and ran an operation in a single
|
1057
1142
|
statement. While this might be feasible for some "fire-and-forget" controller
|
@@ -1099,18 +1184,18 @@ def update_username
|
|
1099
1184
|
end
|
1100
1185
|
```
|
1101
1186
|
|
1102
|
-
|
1187
|
+
### Checking for operations
|
1103
1188
|
|
1104
1189
|
Using the method `op?`, you can check whether an operation has already been
|
1105
1190
|
instantiated (using `op`).
|
1106
1191
|
|
1107
|
-
|
1192
|
+
### Model shortcut
|
1108
1193
|
|
1109
1194
|
RailsOps conveniently provides you with a `model` instance method, which is a
|
1110
1195
|
shortcut for `op.model`. This is particularly useful since this is available as
|
1111
1196
|
a view helper method as well, see next section.
|
1112
1197
|
|
1113
|
-
|
1198
|
+
### View helper methods
|
1114
1199
|
|
1115
1200
|
The following controller methods are automatically provided as helper methods
|
1116
1201
|
which can be used in views:
|
@@ -1126,7 +1211,7 @@ It is very common to use `model` for your forms:
|
|
1126
1211
|
- # Form code goes here
|
1127
1212
|
```
|
1128
1213
|
|
1129
|
-
|
1214
|
+
### Parameters
|
1130
1215
|
|
1131
1216
|
As you've probably noticed in previous examples, we did not provide any
|
1132
1217
|
parameters to the operation.
|
@@ -1154,7 +1239,7 @@ You can also combine these two approaches:
|
|
1154
1239
|
op SomeOperation, some_param: op_params.slice(:some_param, :some_other_param)
|
1155
1240
|
```
|
1156
1241
|
|
1157
|
-
|
1242
|
+
### Authorization ensuring
|
1158
1243
|
|
1159
1244
|
For security reasons, RailsOps automatically checks after each action whether
|
1160
1245
|
authorization has been performed. This is to avoid serving an action's response
|
@@ -1168,7 +1253,7 @@ Note that this check also doesn't apply if the corresponding operation uses
|
|
1168
1253
|
`without_authorization` (see section *Disabling authorization* for more
|
1169
1254
|
information on this).
|
1170
1255
|
|
1171
|
-
|
1256
|
+
### Context
|
1172
1257
|
|
1173
1258
|
When using the `op` method to instantiate an operation, a context is
|
1174
1259
|
automatically created. The following fields are set automatically:
|
@@ -1179,7 +1264,7 @@ automatically created. The following fields are set automatically:
|
|
1179
1264
|
- `session` (uses the `session` controller method)
|
1180
1265
|
- `url_options` (uses the `url_options` controller method)
|
1181
1266
|
|
1182
|
-
|
1267
|
+
### Multiple operations per request
|
1183
1268
|
|
1184
1269
|
RailsOps does not currently support calling multiple operations in a single
|
1185
1270
|
controller action out-of-the-box. You need to instantiate and run it manually.
|
@@ -1193,7 +1278,7 @@ Operation Inheritance
|
|
1193
1278
|
Caveats
|
1194
1279
|
-------
|
1195
1280
|
|
1196
|
-
|
1281
|
+
### Eager loading in development mode
|
1197
1282
|
|
1198
1283
|
Eager loading operation classes containing models with nested models or
|
1199
1284
|
operations can be very slow in performance. In production mode, the same process
|
@@ -1202,18 +1287,12 @@ exclude your operation classes (i.e. `app/operations`) in your
|
|
1202
1287
|
`config.eager_load_paths` of `development.rb`. Make sure not to touch this
|
1203
1288
|
setting in production mode though.
|
1204
1289
|
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
## Load model authorization
|
1290
|
+
Change log
|
1291
|
+
----------
|
1209
1292
|
|
1210
|
-
|
1211
|
-
entirely. Operations using the `Load` base class can authorize using `:read`,
|
1212
|
-
while more specific operations can use `:update` or whatever. If we really need
|
1213
|
-
to check for `:read` when updating an object, it can be implemented in the
|
1214
|
-
ability class.
|
1293
|
+
### 1.0.0.beta5
|
1215
1294
|
|
1216
|
-
|
1295
|
+
* Fix #5 Measure for object_id ... not finished
|
1217
1296
|
|
1218
1297
|
### 1.0.0.beta4
|
1219
1298
|
|
@@ -1222,6 +1301,13 @@ ability class.
|
|
1222
1301
|
|
1223
1302
|
* Start of change log.
|
1224
1303
|
|
1304
|
+
## Contributors
|
1305
|
+
|
1306
|
+
This Gem is heavily inspired by the [trailblazer](http://trailblazer.to/) Gem
|
1307
|
+
which provides a wonderful, high-level architecture for Rails – beyond just
|
1308
|
+
operations. Be sure to check this out when trying to decide on an alternative
|
1309
|
+
Rails architecture.
|
1310
|
+
|
1225
1311
|
## Copyright
|
1226
1312
|
|
1227
1313
|
Copyright (c) 2017 Sitrox. See `LICENSE` for further details.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta5
|
data/lib/rails_ops.rb
CHANGED
@@ -58,7 +58,7 @@ require 'rails_ops/configuration.rb'
|
|
58
58
|
require 'rails_ops/context.rb'
|
59
59
|
require 'rails_ops/controller_mixin.rb'
|
60
60
|
require 'rails_ops/exceptions.rb'
|
61
|
-
require 'rails_ops/hooked_job.rb'
|
61
|
+
require 'rails_ops/hooked_job.rb' if defined?(ActiveJob)
|
62
62
|
require 'rails_ops/hookup.rb'
|
63
63
|
require 'rails_ops/hookup/dsl.rb'
|
64
64
|
require 'rails_ops/hookup/dsl_validator.rb'
|
@@ -91,6 +91,6 @@ require 'rails_ops/operation/model/destroy.rb'
|
|
91
91
|
require 'rails_ops/operation/model/update.rb'
|
92
92
|
require 'rails_ops/profiler.rb'
|
93
93
|
require 'rails_ops/profiler/node.rb'
|
94
|
-
require 'rails_ops/railtie.rb'
|
94
|
+
require 'rails_ops/railtie.rb' if defined?(Rails)
|
95
95
|
require 'rails_ops/scoped_env.rb'
|
96
96
|
require 'rails_ops/virtual_model.rb'
|
@@ -15,8 +15,14 @@ module RailsOps
|
|
15
15
|
message += " (#{profile.t_self_ms.round(1)}ms / #{profile.t_kids_ms.round(1)}ms)"
|
16
16
|
profile.free
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
if profile.erroneous?
|
19
|
+
message += ' (failed)'
|
20
|
+
end
|
21
|
+
|
22
|
+
color = profile.erroneous? ? RED : YELLOW
|
23
|
+
|
24
|
+
message = color(message, color, true)
|
25
|
+
message += color(" #{op.class.name}", color, false)
|
20
26
|
|
21
27
|
debug " #{message}"
|
22
28
|
end
|
data/lib/rails_ops/profiler.rb
CHANGED
@@ -3,10 +3,15 @@ module RailsOps
|
|
3
3
|
def self.profile(object_id, description = nil, &_block)
|
4
4
|
node = tstore_nodes[object_id] = ::RailsOps::Profiler::Node.new(object_id, description, tstore_current_parent)
|
5
5
|
self.tstore_current_parent = node
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
begin
|
7
|
+
res = yield
|
8
|
+
rescue
|
9
|
+
node.erroneous!
|
10
|
+
ensure
|
11
|
+
self.tstore_current_parent = node.parent
|
12
|
+
node.finish_measure
|
13
|
+
end
|
14
|
+
return res
|
10
15
|
end
|
11
16
|
|
12
17
|
def self.time(descr = nil, &_block)
|
@@ -6,6 +6,7 @@ module RailsOps
|
|
6
6
|
@parent = parent
|
7
7
|
parent&.add_child(self)
|
8
8
|
@children = []
|
9
|
+
@erroneous = false
|
9
10
|
@t_start = Time.now
|
10
11
|
end
|
11
12
|
|
@@ -16,6 +17,14 @@ module RailsOps
|
|
16
17
|
@t_stop = Time.now
|
17
18
|
end
|
18
19
|
|
20
|
+
def erroneous!
|
21
|
+
@erroneous = true
|
22
|
+
end
|
23
|
+
|
24
|
+
def erroneous?
|
25
|
+
@erroneous
|
26
|
+
end
|
27
|
+
|
19
28
|
def t_self
|
20
29
|
t_total - t_kids
|
21
30
|
end
|
@@ -25,7 +34,7 @@ module RailsOps
|
|
25
34
|
end
|
26
35
|
|
27
36
|
def t_total
|
28
|
-
|
37
|
+
return nil unless @t_stop
|
29
38
|
(@t_stop - @t_start).to_f
|
30
39
|
end
|
31
40
|
|
data/rails_ops.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rails_ops 1.0.0.
|
2
|
+
# stub: rails_ops 1.0.0.beta5 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rails_ops".freeze
|
6
|
-
s.version = "1.0.0.
|
6
|
+
s.version = "1.0.0.beta5"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Sitrox".freeze]
|
11
|
-
s.date = "2017-11-
|
12
|
-
s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, "Gemfile".freeze, "LICENSE.txt".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "lib/rails_ops.rb".freeze, "lib/rails_ops/authorization_backend/abstract.rb".freeze, "lib/rails_ops/authorization_backend/can_can_can.rb".freeze, "lib/rails_ops/configuration.rb".freeze, "lib/rails_ops/context.rb".freeze, "lib/rails_ops/controller_mixin.rb".freeze, "lib/rails_ops/exceptions.rb".freeze, "lib/rails_ops/hooked_job.rb".freeze, "lib/rails_ops/hookup.rb".freeze, "lib/rails_ops/hookup/dsl.rb".freeze, "lib/rails_ops/hookup/dsl_validator.rb".freeze, "lib/rails_ops/hookup/hook.rb".freeze, "lib/rails_ops/log_subscriber.rb".freeze, "lib/rails_ops/mixins.rb".freeze, "lib/rails_ops/mixins/authorization.rb".freeze, "lib/rails_ops/mixins/log_settings.rb".freeze, "lib/rails_ops/mixins/model.rb".freeze, "lib/rails_ops/mixins/model/authorization.rb".freeze, "lib/rails_ops/mixins/model/nesting.rb".freeze, "lib/rails_ops/mixins/policies.rb".freeze, "lib/rails_ops/mixins/require_context.rb".freeze, "lib/rails_ops/mixins/routes.rb".freeze, "lib/rails_ops/mixins/schema_validation.rb".freeze, "lib/rails_ops/mixins/sub_ops.rb".freeze, "lib/rails_ops/model_casting.rb".freeze, "lib/rails_ops/model_mixins.rb".freeze, "lib/rails_ops/model_mixins/ar_extension.rb".freeze, "lib/rails_ops/model_mixins/parent_op.rb".freeze, "lib/rails_ops/model_mixins/protected_attributes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes/virtual_column_wrapper.rb".freeze, "lib/rails_ops/model_mixins/virtual_has_one.rb".freeze, "lib/rails_ops/operation.rb".freeze, "lib/rails_ops/operation/model.rb".freeze, "lib/rails_ops/operation/model/create.rb".freeze, "lib/rails_ops/operation/model/destroy.rb".freeze, "lib/rails_ops/operation/model/load.rb".freeze, "lib/rails_ops/operation/model/update.rb".freeze, "lib/rails_ops/patches/active_type_patch.rb".freeze, "lib/rails_ops/profiler.rb".freeze, "lib/rails_ops/profiler/node.rb".freeze, "lib/rails_ops/railtie.rb".freeze, "lib/rails_ops/scoped_env.rb".freeze, "lib/rails_ops/virtual_model.rb".freeze, "rails_ops.gemspec".freeze, "test/test_helper.rb".freeze]
|
11
|
+
s.date = "2017-11-27"
|
12
|
+
s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, "Gemfile".freeze, "LICENSE.txt".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "lib/rails_ops.rb".freeze, "lib/rails_ops/authorization_backend/abstract.rb".freeze, "lib/rails_ops/authorization_backend/can_can_can.rb".freeze, "lib/rails_ops/configuration.rb".freeze, "lib/rails_ops/context.rb".freeze, "lib/rails_ops/controller_mixin.rb".freeze, "lib/rails_ops/exceptions.rb".freeze, "lib/rails_ops/hooked_job.rb".freeze, "lib/rails_ops/hookup.rb".freeze, "lib/rails_ops/hookup/dsl.rb".freeze, "lib/rails_ops/hookup/dsl_validator.rb".freeze, "lib/rails_ops/hookup/hook.rb".freeze, "lib/rails_ops/log_subscriber.rb".freeze, "lib/rails_ops/mixins.rb".freeze, "lib/rails_ops/mixins/authorization.rb".freeze, "lib/rails_ops/mixins/log_settings.rb".freeze, "lib/rails_ops/mixins/model.rb".freeze, "lib/rails_ops/mixins/model/authorization.rb".freeze, "lib/rails_ops/mixins/model/nesting.rb".freeze, "lib/rails_ops/mixins/policies.rb".freeze, "lib/rails_ops/mixins/require_context.rb".freeze, "lib/rails_ops/mixins/routes.rb".freeze, "lib/rails_ops/mixins/schema_validation.rb".freeze, "lib/rails_ops/mixins/sub_ops.rb".freeze, "lib/rails_ops/model_casting.rb".freeze, "lib/rails_ops/model_mixins.rb".freeze, "lib/rails_ops/model_mixins/ar_extension.rb".freeze, "lib/rails_ops/model_mixins/parent_op.rb".freeze, "lib/rails_ops/model_mixins/protected_attributes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes/virtual_column_wrapper.rb".freeze, "lib/rails_ops/model_mixins/virtual_has_one.rb".freeze, "lib/rails_ops/operation.rb".freeze, "lib/rails_ops/operation/model.rb".freeze, "lib/rails_ops/operation/model/create.rb".freeze, "lib/rails_ops/operation/model/destroy.rb".freeze, "lib/rails_ops/operation/model/load.rb".freeze, "lib/rails_ops/operation/model/update.rb".freeze, "lib/rails_ops/patches/active_type_patch.rb".freeze, "lib/rails_ops/profiler.rb".freeze, "lib/rails_ops/profiler/node.rb".freeze, "lib/rails_ops/railtie.rb".freeze, "lib/rails_ops/scoped_env.rb".freeze, "lib/rails_ops/virtual_model.rb".freeze, "rails_ops.gemspec".freeze, "test/db/models.rb".freeze, "test/db/schema.rb".freeze, "test/rails_ops/operation/example_test.rb".freeze, "test/test_helper.rb".freeze]
|
13
13
|
s.rubygems_version = "2.6.6".freeze
|
14
14
|
s.summary = "An operations service layer for rails projects.".freeze
|
15
|
-
s.test_files = ["test/test_helper.rb".freeze]
|
15
|
+
s.test_files = ["test/db/models.rb".freeze, "test/db/schema.rb".freeze, "test/rails_ops/operation/example_test.rb".freeze, "test/test_helper.rb".freeze]
|
16
16
|
|
17
17
|
if s.respond_to? :specification_version then
|
18
18
|
s.specification_version = 4
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_runtime_dependency(%q<minitest>.freeze, [">= 0"])
|
29
29
|
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 0"])
|
30
30
|
s.add_runtime_dependency(%q<activerecord>.freeze, [">= 0"])
|
31
|
+
s.add_runtime_dependency(%q<activejob>.freeze, [">= 0"])
|
31
32
|
s.add_runtime_dependency(%q<schemacop>.freeze, ["~> 2.0"])
|
32
33
|
else
|
33
34
|
s.add_dependency(%q<bundler>.freeze, ["~> 1.3"])
|
@@ -40,6 +41,7 @@ Gem::Specification.new do |s|
|
|
40
41
|
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
41
42
|
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
42
43
|
s.add_dependency(%q<activerecord>.freeze, [">= 0"])
|
44
|
+
s.add_dependency(%q<activejob>.freeze, [">= 0"])
|
43
45
|
s.add_dependency(%q<schemacop>.freeze, ["~> 2.0"])
|
44
46
|
end
|
45
47
|
else
|
@@ -53,6 +55,7 @@ Gem::Specification.new do |s|
|
|
53
55
|
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
54
56
|
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
55
57
|
s.add_dependency(%q<activerecord>.freeze, [">= 0"])
|
58
|
+
s.add_dependency(%q<activejob>.freeze, [">= 0"])
|
56
59
|
s.add_dependency(%q<schemacop>.freeze, ["~> 2.0"])
|
57
60
|
end
|
58
61
|
end
|
data/test/db/models.rb
ADDED
data/test/db/schema.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RailsOps::Operation::ExampleTest < Minitest::Test
|
4
|
+
include TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
self.class.setup_db
|
8
|
+
self.class.setup_base_data
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_group_create
|
12
|
+
Group.create name: 'Test', color: 'blue'
|
13
|
+
end
|
14
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
-
require '
|
2
|
+
require 'active_record'
|
3
3
|
require 'minitest/autorun'
|
4
|
+
require 'rails_ops'
|
5
|
+
require 'db/models'
|
6
|
+
|
7
|
+
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
|
8
|
+
|
9
|
+
module TestHelper
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def setup_db
|
14
|
+
load File.dirname(__FILE__) + '/db/schema.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup_base_data; end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: activejob
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: schemacop
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,6 +239,9 @@ files:
|
|
225
239
|
- lib/rails_ops/scoped_env.rb
|
226
240
|
- lib/rails_ops/virtual_model.rb
|
227
241
|
- rails_ops.gemspec
|
242
|
+
- test/db/models.rb
|
243
|
+
- test/db/schema.rb
|
244
|
+
- test/rails_ops/operation/example_test.rb
|
228
245
|
- test/test_helper.rb
|
229
246
|
homepage:
|
230
247
|
licenses: []
|
@@ -250,4 +267,7 @@ signing_key:
|
|
250
267
|
specification_version: 4
|
251
268
|
summary: An operations service layer for rails projects.
|
252
269
|
test_files:
|
270
|
+
- test/db/models.rb
|
271
|
+
- test/db/schema.rb
|
272
|
+
- test/rails_ops/operation/example_test.rb
|
253
273
|
- test/test_helper.rb
|