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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ca73aa2b3b39d5cd33bf7e5a3b6a31605cedfd6
4
- data.tar.gz: 6b0d9ab155ff7a442e19d754cc1a78417ffbd3d4
3
+ metadata.gz: e320e5e90fd5fc0f4d5a89fc873887e6be8ee99c
4
+ data.tar.gz: bcf811c16e6dc629b18809935f1323a6ff6fdc7d
5
5
  SHA512:
6
- metadata.gz: 5ba36cf153a52b1f321b4a97279fce29b33b7b891652d45c3afe96304491337cb3065ebb81df668e6d3c8cac649fd6020a77dd3e7c874f6fb38d990f901eff4e
7
- data.tar.gz: c39c2db1e0bad0c883cea0dfafdd5cf84c20050c88414bc8b8966f46ca43fff4d5f96f4491fdf49b41a5d3cc1c2bf9938ae09bdd71833f8cf09678514a940fc6
6
+ metadata.gz: 2a5fd79dc8b1908c83bc7e762423ddda6c4f606d838e7cd093991e6984b1c65d6b646bbe217bbd14f3cfee280d1296febc01767f9b97caa53fc57dcf617eb7f7
7
+ data.tar.gz: fd0ab0632d930873c4df54d8f14bad5a8f31a2200f0dbe6e60c7f354b69194559da1683f2d5b6ebfeadab3dccb0cd222899b7d1a4f91f108019fb14cccc7f2e8
data/README.md CHANGED
@@ -56,6 +56,9 @@ class Project < ActiveRecord::Base
56
56
  belongs_to :team
57
57
  belongs_to :place
58
58
 
59
+ code :software_process, SoftwareProcess
60
+ # SoftwareProcess is a enum type per ProgneTapera
61
+
59
62
  # other fields: code, description
60
63
 
61
64
  def kick_off(in: nil)
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.rdoc')
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
- Bundler::GemHelper.install_tasks
23
+ require 'bundler/gem_tasks'
24
24
 
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/unidom/common .js
2
+ //= link_directory ../stylesheets/unidom/common .css
@@ -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 styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
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
  */
@@ -1,2 +1,3 @@
1
1
  class Unidom::Common::ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
2
3
  end
@@ -0,0 +1,2 @@
1
+ class Unidom::Common::ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class Unidom::Common::ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class Unidom::Common::ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -28,6 +28,10 @@ module Unidom::Common::Concerns::Aes256Cryptor
28
28
 
29
29
  module ClassMethods
30
30
 
31
+ def encryption_algorithm
32
+ 'AES-256-CBC'
33
+ end
34
+
31
35
  def encrypt(message, key: nil)
32
36
 
33
37
  raise ArgumentError.new('The message argument is required.') if message.blank?
@@ -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
@@ -2,6 +2,8 @@ require 'unidom/common/engine'
2
2
 
3
3
  require 'unidom/common/numeration'
4
4
 
5
+ require 'unidom/common/yaml_helper'
6
+
5
7
  module Unidom
6
8
  module Common
7
9
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Common
3
- VERSION = '1.6'.freeze
3
+ VERSION = '1.7'.freeze
4
4
  end
5
5
  end
@@ -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.6'
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-13 00:00:00.000000000 Z
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