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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 409e3b9c102f85c26c55bec5aee42ab024fd8c6ade9b20f5cb54bb9c178a64fe
4
- data.tar.gz: 0c783a29e26d3fcb7472c868976528950f921599390ca8e58f7c92394b210228
3
+ metadata.gz: e28940c54f36797206858a07d3d32df46040353791a38ac382ebea787878a6ae
4
+ data.tar.gz: 896a9533cf13495a123af671fbffe430ece3c0f25d85183fd9b99b4fd5a79f77
5
5
  SHA512:
6
- metadata.gz: 9ae56a1eedef1509142f30dca684398b734b8da5b7d17b1c050ff601ebcfa0be58b3fcb2c7b067308a1884233b3e8453f1e89a855147fa19d96182dd9fd93c96
7
- data.tar.gz: 85f6bae4579b1755de739279f9a30ed5e62bb6bb2e1944eed482960e2507312ea2606acd73cf65fe8c27d7eaf823259650452a71eb23979bbb9f70b50a6307c7
6
+ metadata.gz: 3a5aa9d9d3131761a3d1f2b627838d54b352d61f1c37405ec82a2aa82262c0d78739bac2d20f7fb9467911921ce18c0c87b63f186452a9d59a00312028a0cf9f
7
+ data.tar.gz: d9f4a3335d3cd9f0d6065ec91604ee739a7ac1145d5060eacff40820af8204d40567b8d0ee9de6a5b1d215e7154b370f640a9302f6e69bffbb2bd5f5dbe970df
@@ -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
- name: Rubocop linting
53
- command: bundle exec rubocop
51
+ # - run:
52
+ # name: Rubocop linting
53
+ # command: bundle exec rubocop
@@ -1,3 +1,9 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ Exclude:
4
+ - lib/knowledge/version.rb
5
+ - vendor/bundle/*
6
+
1
7
  Metrics/LineLength:
2
8
  Max: 120
3
9
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knowledge (0.1.2)
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.3)
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)
@@ -52,4 +52,4 @@ module Knowledge
52
52
 
53
53
  # == Settings ========================================================================================================
54
54
  setting :environment, :development
55
- end
55
+ end
@@ -54,7 +54,6 @@ module Knowledge
54
54
 
55
55
  setter.set(name: name_in_project, value: value)
56
56
  end
57
-
58
57
  rescue ::KeyError => e
59
58
  raise ::Knowledge::ValueNotFound, "[#{e.class}]: #{e.message}"
60
59
  end
@@ -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 < Error; end
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
  #
@@ -4,7 +4,7 @@ require 'yaml'
4
4
 
5
5
  require 'knowledge/initializer'
6
6
  require 'knowledge/adapters'
7
- require 'knowledge/setter'
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::Setter.new
57
+ @setter = ::Knowledge::Setters.config.default.new
58
58
  @variables = {}
59
59
  end
60
60
 
@@ -6,40 +6,11 @@ module Knowledge
6
6
  #
7
7
  # === Description
8
8
  #
9
- # If you don't have a defined strategy to manage config for your project, you can use Knowledge's one.
10
- # This is the custom setter.
9
+ # @deprecated
11
10
  #
12
- # === Usage
11
+ # Deprecated, will be removed in v1.0.0.
12
+ # Use Knowledge::Setters::Knowledge instead.
13
13
  #
14
- # @example:
15
14
  #
16
- # Knowledge::Setter.new.set(name: :foo, value: 'bar')
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Knowledge
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.1.3'.freeze
5
5
  end
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.2
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-15 00:00:00.000000000 Z
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: