knowledge 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +4 -4
- data/.rubocop.yml +6 -0
- data/Gemfile.lock +2 -2
- data/lib/knowledge.rb +1 -1
- data/lib/knowledge/adapters/environment.rb +0 -1
- data/lib/knowledge/exceptions.rb +15 -1
- data/lib/knowledge/initializer.rb +0 -4
- data/lib/knowledge/learner.rb +2 -2
- data/lib/knowledge/setter.rb +4 -33
- data/lib/knowledge/setters.rb +22 -0
- data/lib/knowledge/setters/base.rb +47 -0
- data/lib/knowledge/setters/knowledge.rb +49 -0
- data/lib/knowledge/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e28940c54f36797206858a07d3d32df46040353791a38ac382ebea787878a6ae
|
4
|
+
data.tar.gz: 896a9533cf13495a123af671fbffe430ece3c0f25d85183fd9b99b4fd5a79f77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a5aa9d9d3131761a3d1f2b627838d54b352d61f1c37405ec82a2aa82262c0d78739bac2d20f7fb9467911921ce18c0c87b63f186452a9d59a00312028a0cf9f
|
7
|
+
data.tar.gz: d9f4a3335d3cd9f0d6065ec91604ee739a7ac1145d5060eacff40820af8204d40567b8d0ee9de6a5b1d215e7154b370f640a9302f6e69bffbb2bd5f5dbe970df
|
data/.circleci/config.yml
CHANGED
@@ -6,7 +6,7 @@ version: 2
|
|
6
6
|
jobs:
|
7
7
|
build:
|
8
8
|
docker:
|
9
|
-
- image: circleci/ruby:2.5
|
9
|
+
- image: circleci/ruby:2.5.1-node-browsers
|
10
10
|
|
11
11
|
working_directory: ~/repo
|
12
12
|
|
@@ -48,6 +48,6 @@ jobs:
|
|
48
48
|
path: /tmp/test-results
|
49
49
|
destination: test-results
|
50
50
|
|
51
|
-
- run:
|
52
|
-
|
53
|
-
|
51
|
+
# - run:
|
52
|
+
# name: Rubocop linting
|
53
|
+
# command: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
knowledge (0.1.
|
4
|
+
knowledge (0.1.3)
|
5
5
|
dry-configurable (~> 0.7)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.0)
|
11
11
|
coderay (1.1.2)
|
12
|
-
concurrent-ruby (1.1.
|
12
|
+
concurrent-ruby (1.1.4)
|
13
13
|
diff-lcs (1.3)
|
14
14
|
docile (1.3.1)
|
15
15
|
dry-configurable (0.7.0)
|
data/lib/knowledge.rb
CHANGED
data/lib/knowledge/exceptions.rb
CHANGED
@@ -17,6 +17,13 @@ module Knowledge
|
|
17
17
|
#
|
18
18
|
class Error < ::StandardError; end
|
19
19
|
|
20
|
+
#
|
21
|
+
# === Description
|
22
|
+
#
|
23
|
+
# This error is used when a method is not defined
|
24
|
+
#
|
25
|
+
class MethodNotImplemented < Error; end
|
26
|
+
|
20
27
|
#
|
21
28
|
# === Description
|
22
29
|
#
|
@@ -29,7 +36,7 @@ module Knowledge
|
|
29
36
|
#
|
30
37
|
# This error is used when an adapter has no #run method declared
|
31
38
|
#
|
32
|
-
class AdapterRunMethodNotImplemented <
|
39
|
+
class AdapterRunMethodNotImplemented < MethodNotImplemented; end
|
33
40
|
|
34
41
|
#
|
35
42
|
# === Description
|
@@ -45,6 +52,13 @@ module Knowledge
|
|
45
52
|
#
|
46
53
|
class RegisterError < Error; end
|
47
54
|
|
55
|
+
#
|
56
|
+
# === Description
|
57
|
+
#
|
58
|
+
# This error is used when an adapter has no #run method declared
|
59
|
+
#
|
60
|
+
class SetterSetMethodNotImplemented < MethodNotImplemented; end
|
61
|
+
|
48
62
|
#
|
49
63
|
# === Description
|
50
64
|
#
|
@@ -59,8 +59,6 @@ module Knowledge
|
|
59
59
|
|
60
60
|
# == Class methods ===============================================================================================
|
61
61
|
class << self
|
62
|
-
#
|
63
|
-
# === Description
|
64
62
|
#
|
65
63
|
# Instanciates the current class and runs all registered adapters.
|
66
64
|
#
|
@@ -78,8 +76,6 @@ module Knowledge
|
|
78
76
|
|
79
77
|
# == Instance methods ============================================================================================
|
80
78
|
|
81
|
-
#
|
82
|
-
# === Description
|
83
79
|
#
|
84
80
|
# Runs all registered adapters.
|
85
81
|
#
|
data/lib/knowledge/learner.rb
CHANGED
@@ -4,7 +4,7 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
require 'knowledge/initializer'
|
6
6
|
require 'knowledge/adapters'
|
7
|
-
require 'knowledge/
|
7
|
+
require 'knowledge/setters'
|
8
8
|
require 'knowledge/backupper'
|
9
9
|
|
10
10
|
module Knowledge
|
@@ -54,7 +54,7 @@ module Knowledge
|
|
54
54
|
@additionnal_params = {}
|
55
55
|
@available_adapters = {}
|
56
56
|
@enabled_adapters = {}
|
57
|
-
@setter = ::Knowledge::
|
57
|
+
@setter = ::Knowledge::Setters.config.default.new
|
58
58
|
@variables = {}
|
59
59
|
end
|
60
60
|
|
data/lib/knowledge/setter.rb
CHANGED
@@ -6,40 +6,11 @@ module Knowledge
|
|
6
6
|
#
|
7
7
|
# === Description
|
8
8
|
#
|
9
|
-
#
|
10
|
-
# This is the custom setter.
|
9
|
+
# @deprecated
|
11
10
|
#
|
12
|
-
#
|
11
|
+
# Deprecated, will be removed in v1.0.0.
|
12
|
+
# Use Knowledge::Setters::Knowledge instead.
|
13
13
|
#
|
14
|
-
# @example:
|
15
14
|
#
|
16
|
-
|
17
|
-
#
|
18
|
-
class Setter
|
19
|
-
# == Constructor ===================================================================================================
|
20
|
-
|
21
|
-
#
|
22
|
-
# Just sets the basic configuration object.
|
23
|
-
#
|
24
|
-
def initialize
|
25
|
-
@configuration = ::Knowledge::Configuration
|
26
|
-
end
|
27
|
-
|
28
|
-
# == Instance methods ==============================================================================================
|
29
|
-
|
30
|
-
#
|
31
|
-
# === Description
|
32
|
-
#
|
33
|
-
# Sets the variable by doing black magic on Knowledge::Configuration.
|
34
|
-
#
|
35
|
-
# === Parameters
|
36
|
-
#
|
37
|
-
# @param :name [String | Symbol]
|
38
|
-
# @param :value [Any]
|
39
|
-
#
|
40
|
-
def set(name:, value:)
|
41
|
-
@configuration.singleton_class.class_eval { attr_accessor name.to_sym } unless @configuration.respond_to?(name)
|
42
|
-
@configuration.instance_variable_set(:"@#{name}", value)
|
43
|
-
end
|
44
|
-
end
|
15
|
+
class Setter < ::Knowledge::Setters::Knowledge; end
|
45
16
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Knowledge
|
4
|
+
#
|
5
|
+
# === Description
|
6
|
+
#
|
7
|
+
# This is the namespace used to put the lib's setters.
|
8
|
+
# You can find the setters by looking to the inclusions below or to the setters folder.
|
9
|
+
#
|
10
|
+
module Setters
|
11
|
+
# == Behaviors =====================================================================================================
|
12
|
+
extend Dry::Configurable
|
13
|
+
|
14
|
+
# == Settings ======================================================================================================
|
15
|
+
setting :default
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'knowledge/setters/base'
|
20
|
+
require 'knowledge/setters/knowledge'
|
21
|
+
|
22
|
+
Knowledge::Setters.config.default = Knowledge::Setters::Knowledge
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'knowledge/configuration'
|
4
|
+
|
5
|
+
module Knowledge
|
6
|
+
module Setters
|
7
|
+
#
|
8
|
+
# === Description
|
9
|
+
#
|
10
|
+
# This adapter is the base setter.
|
11
|
+
# It does nothing specific but is meant to manage all generic stuff.
|
12
|
+
#
|
13
|
+
# === Usage
|
14
|
+
#
|
15
|
+
# Just inherit from it
|
16
|
+
#
|
17
|
+
# @example:
|
18
|
+
#
|
19
|
+
# class MySuperSetter < Knowledge::Setters::Base; end
|
20
|
+
#
|
21
|
+
# === Attributes
|
22
|
+
#
|
23
|
+
# @attr_reader [Class | Hash | Object] configuration
|
24
|
+
#
|
25
|
+
class Base
|
26
|
+
# == Attributes ==================================================================================================
|
27
|
+
|
28
|
+
# Configuration object - can be whetever your setter knows how to work with
|
29
|
+
attr_reader :configuration
|
30
|
+
|
31
|
+
# == Instance methods ============================================================================================
|
32
|
+
|
33
|
+
#
|
34
|
+
# Sets the variable.
|
35
|
+
#
|
36
|
+
# === Parameters
|
37
|
+
#
|
38
|
+
# @param :name [String | Symbol]
|
39
|
+
# @param :value [Any]
|
40
|
+
#
|
41
|
+
def set(name:, value:)
|
42
|
+
error_message = "Expect setter to define #set method to be able to set #{name} with value '#{value}'"
|
43
|
+
raise ::Knowledge::SetterSetMethodNotImplemented, error_message
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'knowledge/configuration'
|
4
|
+
|
5
|
+
module Knowledge
|
6
|
+
module Setters
|
7
|
+
#
|
8
|
+
# === Description
|
9
|
+
#
|
10
|
+
# If you don't have a defined strategy to manage config for your project, you can use Knowledge's one.
|
11
|
+
# This is the custom setter.
|
12
|
+
#
|
13
|
+
# === Usage
|
14
|
+
#
|
15
|
+
# @example:
|
16
|
+
#
|
17
|
+
# Knowledge::Setters::Knowledge.new.set(name: :foo, value: 'bar')
|
18
|
+
#
|
19
|
+
# === Attributes
|
20
|
+
#
|
21
|
+
# @attr_reader [Knowledge::Configuration] configuration
|
22
|
+
#
|
23
|
+
class Knowledge < Base
|
24
|
+
# == Constructor =================================================================================================
|
25
|
+
|
26
|
+
#
|
27
|
+
# Just sets the basic configuration object.
|
28
|
+
#
|
29
|
+
def initialize
|
30
|
+
@configuration = ::Knowledge::Configuration
|
31
|
+
end
|
32
|
+
|
33
|
+
# == Instance methods ============================================================================================
|
34
|
+
|
35
|
+
#
|
36
|
+
# Sets the variable by doing black magic on Knowledge::Configuration.
|
37
|
+
#
|
38
|
+
# === Parameters
|
39
|
+
#
|
40
|
+
# @param :name [String | Symbol]
|
41
|
+
# @param :value [Any]
|
42
|
+
#
|
43
|
+
def set(name:, value:)
|
44
|
+
@configuration.singleton_class.class_eval { attr_accessor name.to_sym } unless @configuration.respond_to?(name)
|
45
|
+
@configuration.instance_variable_set(:"@#{name}", value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/knowledge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knowledge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johann Wilfrid-Calixte
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -142,6 +142,9 @@ files:
|
|
142
142
|
- lib/knowledge/initializer.rb
|
143
143
|
- lib/knowledge/learner.rb
|
144
144
|
- lib/knowledge/setter.rb
|
145
|
+
- lib/knowledge/setters.rb
|
146
|
+
- lib/knowledge/setters/base.rb
|
147
|
+
- lib/knowledge/setters/knowledge.rb
|
145
148
|
- lib/knowledge/version.rb
|
146
149
|
homepage: https://github.com/knowledge-ruby/knowledge
|
147
150
|
licenses:
|