unidom-common 1.6 → 1.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 +4 -4
- data/README.md +3 -0
- data/Rakefile +2 -2
- data/app/assets/config/unidom-common_manifest.js +2 -0
- data/app/assets/javascripts/unidom/common/application.js +1 -1
- data/app/assets/stylesheets/unidom/common/application.css +3 -3
- data/app/controllers/unidom/common/application_controller.rb +1 -0
- data/app/jobs/unidom/common/application_job.rb +2 -0
- data/app/mailers/unidom/common/application_mailer.rb +4 -0
- data/app/models/unidom/common/application_record.rb +3 -0
- data/app/models/unidom/common/concerns/aes256_cryptor.rb +4 -0
- data/app/models/unidom/common/concerns/model_extension.rb +7 -3
- data/app/models/unidom/common/concerns/secure_column.rb +4 -2
- data/lib/unidom/common.rb +2 -0
- data/lib/unidom/common/version.rb +1 -1
- data/lib/unidom/common/yaml_helper.rb +20 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e320e5e90fd5fc0f4d5a89fc873887e6be8ee99c
|
4
|
+
data.tar.gz: bcf811c16e6dc629b18809935f1323a6ff6fdc7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5fd79dc8b1908c83bc7e762423ddda6c4f606d838e7cd093991e6984b1c65d6b646bbe217bbd14f3cfee280d1296febc01767f9b97caa53fc57dcf617eb7f7
|
7
|
+
data.tar.gz: fd0ab0632d930873c4df54d8f14bad5a8f31a2200f0dbe6e60c7f354b69194559da1683f2d5b6ebfeadab3dccb0cd222899b7d1a4f91f108019fb14cccc7f2e8
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
10
|
rdoc.rdoc_dir = 'rdoc'
|
11
11
|
rdoc.title = 'Unidom::Common'
|
12
12
|
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
@@ -20,5 +20,5 @@ load 'rails/tasks/statistics.rake'
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
|
23
|
+
require 'bundler/gem_tasks'
|
24
24
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
9
|
//
|
10
10
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
@@ -6,9 +6,9 @@
|
|
6
6
|
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
8
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any
|
10
|
-
*
|
11
|
-
* file per style scope.
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
12
|
*
|
13
13
|
*= require_self
|
14
14
|
*/
|
@@ -4,7 +4,6 @@ module Unidom::Common::Concerns::ModelExtension
|
|
4
4
|
|
5
5
|
include Unidom::Common::Concerns::ArgumentValidation
|
6
6
|
include Unidom::Common::Concerns::NotationColumn
|
7
|
-
include Unidom::Common::Concerns::ExactColumn
|
8
7
|
include Unidom::Common::Concerns::SecureColumn
|
9
8
|
|
10
9
|
included do |includer|
|
@@ -90,8 +89,8 @@ module Unidom::Common::Concerns::ModelExtension
|
|
90
89
|
else
|
91
90
|
validates name.to_sym, presence: true, length: { maximum: columns_hash[name].limit }
|
92
91
|
end
|
93
|
-
scope "#{name}d_as".to_sym, ->(code) { where name => code }
|
94
|
-
scope "not_#{name}d_as".to_sym, ->(code) { where.not name => code }
|
92
|
+
scope "#{name}d_as".to_sym, ->(code) { where name => to_code(code) }
|
93
|
+
scope "not_#{name}d_as".to_sym, ->(code) { where.not name => to_code(code) }
|
95
94
|
scope "#{name}_starting_with".to_sym, ->(prefix) { where "#{name} LIKE :prefix", prefix: "#{prefix}%" }
|
96
95
|
scope "#{name}_ending_with".to_sym, ->(suffix) { where "#{name} LIKE :suffix", suffix: "%#{suffix}" }
|
97
96
|
end
|
@@ -156,6 +155,11 @@ module Unidom::Common::Concerns::ModelExtension
|
|
156
155
|
def to_id(model)
|
157
156
|
model.respond_to?(:id) ? model.id : model
|
158
157
|
end
|
158
|
+
|
159
|
+
def to_code(code)
|
160
|
+
code.respond_to?(:code) ? code.code : code
|
161
|
+
end
|
162
|
+
|
159
163
|
=begin
|
160
164
|
def notation_column(*names)
|
161
165
|
names.each do |name|
|
@@ -33,14 +33,16 @@ module Unidom::Common::Concerns::SecureColumn
|
|
33
33
|
encoded = hex_encrypt content, key: aes_key
|
34
34
|
json = {
|
35
35
|
encoded: encoded,
|
36
|
-
signature: Unidom::Common::Numeration.hex(self.class.exact_signature self.class, name, content)
|
36
|
+
signature: Unidom::Common::Numeration.hex(self.class.exact_signature self.class, name, content),
|
37
|
+
encryption_algorithm: self.class.encryption_algorithm
|
37
38
|
}
|
38
39
|
send "#{name}=", json
|
39
40
|
end
|
40
41
|
|
41
42
|
after_find do
|
42
43
|
json = send(name)
|
43
|
-
return if json['encoded'].blank?||json['signature'].blank?
|
44
|
+
return if json['encoded'].blank?||json['signature'].blank?||json['encryption_algorithm'].blank?
|
45
|
+
return if self.class.encryption_algorithm!=json['encryption_algorithm']
|
44
46
|
aes_key = Digest::SHA512::digest self.class.exact_signature(self.class, name, '')
|
45
47
|
content = decrypt Unidom::Common::Numeration.rev_hex(json['encoded']), key: aes_key
|
46
48
|
actual_signature = self.class.exact_signature(self.class, name, content)
|
data/lib/unidom/common.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Unidom::Common::YamlHelper
|
2
|
+
|
3
|
+
def self.load_enum(config: nil, root: nil)
|
4
|
+
|
5
|
+
enum_yaml_path = root.join 'config', 'enum.yml'
|
6
|
+
raise ArgumentError.new "The file #{enum_yaml_path} does not exist." unless enum_yaml_path.exist?
|
7
|
+
|
8
|
+
unless config.respond_to? :enum
|
9
|
+
config.class_eval do
|
10
|
+
attr_accessor :enum
|
11
|
+
end
|
12
|
+
end
|
13
|
+
config.enum = {} if config.enum.nil?
|
14
|
+
|
15
|
+
enum_definitions = YAML.load File.read(enum_yaml_path)
|
16
|
+
config.enum.merge! enum_definitions['enum'] if enum_definitions.present?&&enum_definitions['enum'].present?
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: progne_tapera
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,10 +91,14 @@ files:
|
|
77
91
|
- MIT-LICENSE
|
78
92
|
- README.md
|
79
93
|
- Rakefile
|
94
|
+
- app/assets/config/unidom-common_manifest.js
|
80
95
|
- app/assets/javascripts/unidom/common/application.js
|
81
96
|
- app/assets/stylesheets/unidom/common/application.css
|
82
97
|
- app/controllers/unidom/common/application_controller.rb
|
83
98
|
- app/helpers/unidom/common/application_helper.rb
|
99
|
+
- app/jobs/unidom/common/application_job.rb
|
100
|
+
- app/mailers/unidom/common/application_mailer.rb
|
101
|
+
- app/models/unidom/common/application_record.rb
|
84
102
|
- app/models/unidom/common/concerns/aes256_cryptor.rb
|
85
103
|
- app/models/unidom/common/concerns/argument_validation.rb
|
86
104
|
- app/models/unidom/common/concerns/exact_column.rb
|
@@ -102,6 +120,7 @@ files:
|
|
102
120
|
- lib/unidom/common/engine.rb
|
103
121
|
- lib/unidom/common/numeration.rb
|
104
122
|
- lib/unidom/common/version.rb
|
123
|
+
- lib/unidom/common/yaml_helper.rb
|
105
124
|
homepage: http://github.com/topbitdu/unidom-common
|
106
125
|
licenses:
|
107
126
|
- MIT
|