knowledge 0.1.3 → 0.1.4

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: e28940c54f36797206858a07d3d32df46040353791a38ac382ebea787878a6ae
4
- data.tar.gz: 896a9533cf13495a123af671fbffe430ece3c0f25d85183fd9b99b4fd5a79f77
3
+ metadata.gz: 8ddde96c930ed905c6761e25779cd203b752d33a5cad99df862443afbf5a6873
4
+ data.tar.gz: 6e129b7c1b34c0a927f1595b38d20d3fcc52b85bd0c99618f594e6e40e8b7529
5
5
  SHA512:
6
- metadata.gz: 3a5aa9d9d3131761a3d1f2b627838d54b352d61f1c37405ec82a2aa82262c0d78739bac2d20f7fb9467911921ce18c0c87b63f186452a9d59a00312028a0cf9f
7
- data.tar.gz: d9f4a3335d3cd9f0d6065ec91604ee739a7ac1145d5060eacff40820af8204d40567b8d0ee9de6a5b1d215e7154b370f640a9302f6e69bffbb2bd5f5dbe970df
6
+ metadata.gz: 1a3fddeafb3a21c2ca6b5a0499a99a64a02d8b1547be45760ed1475228d6d43bf0958fb442faf076420abecd667a8625776983031f63f566388202688e87f043
7
+ data.tar.gz: 30ec24f95ab6948c56286f436f286f5e1252a509943a6dab29863f103c8d1486c013cfe7c67f97fa07cfb169c0789d2df1c0d1c9659eeeccc21b612f0771839a
@@ -0,0 +1,17 @@
1
+ FROM ruby:2.6.4
2
+
3
+ RUN bundle config --global frozen 1
4
+
5
+ RUN mkdir /app
6
+ RUN mkdir -p /app/lib/knowledge
7
+ WORKDIR /app
8
+
9
+ RUN gem update --system
10
+ RUN gem install bundler -v "~> 2.0" --no-doc
11
+
12
+ COPY lib/knowledge/version.rb ./lib/knowledge
13
+ COPY knowledge.gemspec Gemfile Gemfile.lock ./
14
+
15
+ RUN bundle install
16
+
17
+ COPY . .
data/Gemfile CHANGED
@@ -6,3 +6,18 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in knowledge.gemspec
8
8
  gemspec
9
+
10
+ # Tests
11
+ gem 'rspec'
12
+ gem 'simplecov'
13
+
14
+ # Linting
15
+ gem 'rubocop', '~> 0.62.0'
16
+
17
+ # Documentation
18
+ gem 'yard'
19
+
20
+ # Watchers
21
+ gem 'guard'
22
+ gem 'guard-process'
23
+ gem 'guard-rspec'
@@ -1,24 +1,48 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knowledge (0.1.3)
5
- dry-configurable (~> 0.7)
4
+ knowledge (0.1.4)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
9
  ast (2.4.0)
11
10
  coderay (1.1.2)
12
- concurrent-ruby (1.1.4)
13
11
  diff-lcs (1.3)
14
12
  docile (1.3.1)
15
- dry-configurable (0.7.0)
16
- concurrent-ruby (~> 1.0)
17
- jaro_winkler (1.5.1)
13
+ ffi (1.11.1)
14
+ formatador (0.2.5)
15
+ guard (2.15.1)
16
+ formatador (>= 0.2.4)
17
+ listen (>= 2.7, < 4.0)
18
+ lumberjack (>= 1.0.12, < 2.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.9.12)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-compat (1.2.1)
25
+ guard-process (1.2.1)
26
+ guard-compat (~> 1.2, >= 1.2.1)
27
+ spoon (~> 0.0.1)
28
+ guard-rspec (4.7.3)
29
+ guard (~> 2.1)
30
+ guard-compat (~> 1.1)
31
+ rspec (>= 2.99.0, < 4.0)
32
+ jaro_winkler (1.5.3)
18
33
  json (2.1.0)
34
+ listen (3.1.5)
35
+ rb-fsevent (~> 0.9, >= 0.9.4)
36
+ rb-inotify (~> 0.9, >= 0.9.7)
37
+ ruby_dep (~> 1.2)
38
+ lumberjack (1.0.13)
19
39
  method_source (0.9.2)
20
- parallel (1.12.1)
21
- parser (2.5.3.0)
40
+ nenv (0.3.0)
41
+ notiffany (0.1.3)
42
+ nenv (~> 0.1)
43
+ shellany (~> 0.0)
44
+ parallel (1.17.0)
45
+ parser (2.6.4.1)
22
46
  ast (~> 2.4.0)
23
47
  powerpack (0.1.2)
24
48
  pry (0.12.2)
@@ -26,6 +50,9 @@ GEM
26
50
  method_source (~> 0.9.0)
27
51
  rainbow (3.0.0)
28
52
  rake (10.5.0)
53
+ rb-fsevent (0.10.3)
54
+ rb-inotify (0.10.0)
55
+ ffi (~> 1.0)
29
56
  rspec (3.8.0)
30
57
  rspec-core (~> 3.8.0)
31
58
  rspec-expectations (~> 3.8.0)
@@ -39,7 +66,7 @@ GEM
39
66
  diff-lcs (>= 1.2.0, < 2.0)
40
67
  rspec-support (~> 3.8.0)
41
68
  rspec-support (3.8.0)
42
- rubocop (0.60.0)
69
+ rubocop (0.62.0)
43
70
  jaro_winkler (~> 1.5.1)
44
71
  parallel (~> 1.10)
45
72
  parser (>= 2.5, != 2.5.1.1)
@@ -47,25 +74,35 @@ GEM
47
74
  rainbow (>= 2.2.2, < 4.0)
48
75
  ruby-progressbar (~> 1.7)
49
76
  unicode-display_width (~> 1.4.0)
50
- ruby-progressbar (1.10.0)
77
+ ruby-progressbar (1.10.1)
78
+ ruby_dep (1.5.0)
79
+ shellany (0.0.1)
51
80
  simplecov (0.16.1)
52
81
  docile (~> 1.1)
53
82
  json (>= 1.8, < 3)
54
83
  simplecov-html (~> 0.10.0)
55
84
  simplecov-html (0.10.2)
56
- unicode-display_width (1.4.0)
85
+ spoon (0.0.6)
86
+ ffi
87
+ thor (0.20.3)
88
+ unicode-display_width (1.4.1)
89
+ yard (0.9.20)
57
90
 
58
91
  PLATFORMS
59
92
  ruby
60
93
 
61
94
  DEPENDENCIES
62
95
  bundler (~> 1.16)
96
+ guard
97
+ guard-process
98
+ guard-rspec
63
99
  knowledge!
64
100
  pry (>= 0.12)
65
101
  rake (~> 10.0)
66
- rspec (~> 3.0)
67
- rubocop (>= 0.60)
102
+ rspec
103
+ rubocop (~> 0.62.0)
68
104
  simplecov
105
+ yard
69
106
 
70
107
  BUNDLED WITH
71
108
  1.16.6
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ group :linter do
4
+ guard 'process', command: 'bundle exec rubocop -a' do
5
+ watch(/\.rb$/)
6
+ end
7
+ end
8
+
9
+ group :test do
10
+ guard 'rspec', cmd: 'bundle exec rspec' do
11
+ watch(/\.rb$/) { 'spec' }
12
+ end
13
+ end
data/README.md CHANGED
@@ -11,6 +11,12 @@ The full documentation is currently being written. You should be able to find a
11
11
 
12
12
  Waiting for the full documentation, you can have a look at the code which is already well-documented or at the [wiki](https://github.com/knowledge-ruby/knowledge/wiki)
13
13
 
14
+ ## Knowledge official ecosystem
15
+
16
+ - [knowledge](https://github.com/knowledge-ruby/knowledge) - Core project
17
+ - [knowledge-rails](https://github.com/knowledge-ruby/knowledge-rails) - Rails utilities
18
+ - [knowledge-ssm](https://github.com/knowledge-ruby/knowledge-ssm) - SSM Adapter
19
+
14
20
  ## Installation
15
21
 
16
22
  Add this line to your application's Gemfile:
@@ -128,10 +134,32 @@ Rails.application.config.key # => "value"
128
134
 
129
135
  ## Development
130
136
 
137
+ ### Without docker
138
+
131
139
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
132
140
 
133
141
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
134
142
 
143
+ ### With docker
144
+
145
+ First, please ensure you've got docker and docker-compose properly setup on your computer
146
+
147
+ Then run:
148
+
149
+ ```bash
150
+ $ docker-compose build
151
+ ```
152
+
153
+ Once the build has been done, run:
154
+
155
+ ```bash
156
+ $ docker-compose up
157
+ ```
158
+
159
+ You will be able to see linting and test tasks running each time you change a file.
160
+
161
+ You will also find the yard doc under `http://localhost:5001` and the coverage under `http://localhost:5002`.
162
+
135
163
  ## Contributing
136
164
 
137
165
  Bug reports and pull requests are welcome on GitHub at https://github.com/knowledge-ruby/knowledge. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -145,3 +173,5 @@ Everyone interacting in the Knowledge project’s codebases, issue trackers, cha
145
173
  This project is licensed under [GPLv3+](https://www.gnu.org/licenses/gpl-3.0.en.html).
146
174
 
147
175
  You can find it in LICENSE.md file.
176
+
177
+ Note: if you're a company willing to use the gem but you cannot because of the license, I can provide the gem under a different license. Please contact me if you need it.
@@ -0,0 +1,59 @@
1
+ version: "3.7"
2
+
3
+ services:
4
+ test:
5
+ build:
6
+ context: .
7
+ command: |
8
+ bash -c "bundle exec guard --no-interactions -g test"
9
+ volumes:
10
+ - .:/app:cached
11
+ networks:
12
+ knowledge:
13
+ aliases:
14
+ - knowledge.test
15
+
16
+ linter:
17
+ build:
18
+ context: .
19
+ command: |
20
+ bash -c "bundle exec guard --no-interactions -g linter"
21
+ volumes:
22
+ - .:/app:cached
23
+ networks:
24
+ knowledge:
25
+ aliases:
26
+ - knowledge.linter
27
+
28
+ doc:
29
+ build:
30
+ context: .
31
+ command: |
32
+ bash -c "bundle exec yardoc && yard server -B 0.0.0.0 -p 5001 --reload"
33
+ volumes:
34
+ - .:/app:cached
35
+ ports:
36
+ - "5001:5001"
37
+ networks:
38
+ knowledge:
39
+ aliases:
40
+ - knowledge.doc
41
+
42
+ coverage:
43
+ build:
44
+ context: .
45
+ command: |
46
+ bash -c "ruby -run -e httpd -- -p 5002 ./coverage"
47
+ volumes:
48
+ - .:/app:cached
49
+ ports:
50
+ - "5002:5002"
51
+ networks:
52
+ knowledge:
53
+ aliases:
54
+ - knowledge.coverage
55
+
56
+ networks:
57
+ knowledge:
58
+ name: knowledge
59
+ driver: bridge
@@ -38,12 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
39
  spec.require_paths = ['lib']
40
40
 
41
- spec.add_dependency 'dry-configurable', '~> 0.7'
42
-
43
41
  spec.add_development_dependency 'bundler', '~> 1.16'
44
42
  spec.add_development_dependency 'pry', '>= 0.12'
45
43
  spec.add_development_dependency 'rake', '~> 10.0'
46
- spec.add_development_dependency 'rspec', '~> 3.0'
47
- spec.add_development_dependency 'rubocop', '>= 0.60'
48
- spec.add_development_dependency 'simplecov'
49
44
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry-configurable'
4
-
5
3
  require 'knowledge/version'
6
4
  require 'knowledge/exceptions'
5
+ require 'knowledge/configurable'
7
6
  require 'knowledge/learner'
8
7
 
9
8
  #
@@ -19,7 +18,7 @@ require 'knowledge/learner'
19
18
  #
20
19
  # You can configure it one by one or all at once:
21
20
  #
22
- # @example:
21
+ # @example
23
22
  #
24
23
  # Knowledge.config.environment = ENV['RACK_ENV'] || Rails.env || ENV['APP_ENV'] # Or whatever you want
25
24
  #
@@ -29,7 +28,7 @@ require 'knowledge/learner'
29
28
  #
30
29
  # === Usage
31
30
  #
32
- # @example:
31
+ # @example
33
32
  # Knowledge.configure do |config|
34
33
  # config.environment = :production
35
34
  # end
@@ -40,7 +39,9 @@ require 'knowledge/learner'
40
39
  # learner = Knowledge::Learner.new
41
40
  # learner.setter = MyCustomProjectVariableSetter
42
41
  # learner.variables = 'path/to/config/file'
42
+ #
43
43
  # # or
44
+ #
44
45
  # learner.variables = { name: 'value_key' }
45
46
  # learner.register_adapter(:custom, MyCustomProjectVariableAdapter, enable: true)
46
47
  #
@@ -48,8 +49,8 @@ require 'knowledge/learner'
48
49
  #
49
50
  module Knowledge
50
51
  # == Behaviors =======================================================================================================
51
- extend Dry::Configurable
52
+ extend Configurable
52
53
 
53
54
  # == Settings ========================================================================================================
54
- setting :environment, :development
55
- end
55
+ setting :environment, default: :development
56
+ end
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Knowledge
4
+ #
5
+ # === Description
6
+ #
7
+ # Internal configuration module providing required DSL to be able to manage internal configuration.
8
+ #
9
+ # === Usage
10
+ #
11
+ # @example
12
+ # module MyModule
13
+ # extend Configurable
14
+ #
15
+ # setting :variable, default: :default_value
16
+ # end
17
+ #
18
+ # MyModule.variable # :default_value
19
+ #
20
+ # MyModule.configure do |config|
21
+ # config.variable = :foo
22
+ # end
23
+ #
24
+ # MyModule.variable # :foo
25
+ #
26
+ # MyModule.variable = :bar
27
+ #
28
+ # MyModule.variable # :bar
29
+ #
30
+ module Configurable
31
+ def self.extended(base)
32
+ base.singleton_class.extend(Forwardable)
33
+ base.extend(ClassMethods)
34
+ end
35
+
36
+ #
37
+ # Class Methods to be injected.
38
+ #
39
+ module ClassMethods
40
+ #
41
+ # Registers a configuration variable with a potential default value
42
+ #
43
+ # === Usage
44
+ #
45
+ # @example
46
+ #
47
+ # setting :my_config
48
+ # setting :environment, default: :development
49
+ #
50
+ # === Parameters
51
+ #
52
+ # @param name [String, Symbol] the variable's name
53
+ # @param default [any] default value for the variable to define
54
+ #
55
+ def setting(name, default: nil)
56
+ configuration.class.send(:attr_accessor, name)
57
+ configuration.public_send("#{name}=", default)
58
+
59
+ singleton_class.class_eval { def_delegators :configuration, name, "#{name}=" }
60
+ end
61
+
62
+ #
63
+ # Exposes the configuration allowing to manage it.
64
+ #
65
+ # === Usage
66
+ #
67
+ # @example
68
+ #
69
+ # MyModule.configure do |config|
70
+ # config.my_variable = :foo
71
+ # end
72
+ #
73
+ # === Parameters
74
+ #
75
+ # @yield configuration [Config]
76
+ #
77
+ def configure
78
+ yield configuration
79
+ end
80
+
81
+ #
82
+ # Syntaxic sugar allowing to access a config var.
83
+ #
84
+ # === Usage
85
+ #
86
+ # @example
87
+ #
88
+ # MyModule[:my_variable] # :foo
89
+ #
90
+ # === Parameters
91
+ #
92
+ # @param name [String, Symbol]
93
+ #
94
+ # @return the value of the config var
95
+ #
96
+ def [](name)
97
+ configuration.public_send(name.to_sym)
98
+ end
99
+
100
+ #
101
+ # Syntaxic sugar allowing to set a config var.
102
+ #
103
+ # === Usage
104
+ #
105
+ # @example
106
+ #
107
+ # MyModule[:my_variable] = :foo # :foo
108
+ #
109
+ # === Parameters
110
+ #
111
+ # @param name [String, Symbol]
112
+ # @param value [any]
113
+ #
114
+ # @return the value of the config var
115
+ #
116
+ def []=(name, value)
117
+ configuration.public_send("#{name}=", value)
118
+ end
119
+
120
+ private
121
+
122
+ #
123
+ # === Description
124
+ #
125
+ # Used for storing the configuration variables in order not to leak it into Class
126
+ #
127
+ class Config; end
128
+
129
+ # @return [Config]
130
+ def configuration
131
+ @configuration ||= Config.new
132
+ end
133
+ end
134
+ end
135
+ end
@@ -54,7 +54,7 @@ module Knowledge
54
54
  @additionnal_params = {}
55
55
  @available_adapters = {}
56
56
  @enabled_adapters = {}
57
- @setter = ::Knowledge::Setters.config.default.new
57
+ @setter = ::Knowledge::Setters.default.new
58
58
  @variables = {}
59
59
  end
60
60
 
@@ -417,7 +417,7 @@ module Knowledge
417
417
  #
418
418
  def fetch_variables_config(path)
419
419
  descriptor = yaml_content(path)
420
- @variables = descriptor[::Knowledge.config.environment.to_s] || descriptor
420
+ @variables = descriptor[::Knowledge.environment.to_s] || descriptor
421
421
  end
422
422
 
423
423
  #
@@ -9,7 +9,7 @@ module Knowledge
9
9
  #
10
10
  module Setters
11
11
  # == Behaviors =====================================================================================================
12
- extend Dry::Configurable
12
+ extend ::Knowledge::Configurable
13
13
 
14
14
  # == Settings ======================================================================================================
15
15
  setting :default
@@ -19,4 +19,4 @@ end
19
19
  require 'knowledge/setters/base'
20
20
  require 'knowledge/setters/knowledge'
21
21
 
22
- Knowledge::Setters.config.default = Knowledge::Setters::Knowledge
22
+ Knowledge::Setters.default = Knowledge::Setters::Knowledge
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Knowledge
4
- VERSION = '0.1.3'.freeze
4
+ VERSION = '0.1.4'.freeze
5
5
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knowledge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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-22 00:00:00.000000000 Z
11
+ date: 2019-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: dry-configurable
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.7'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.7'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -66,48 +52,6 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '10.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0.60'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0.60'
97
- - !ruby/object:Gem::Dependency
98
- name: simplecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
55
  description: Easy knowledge for yout project.
112
56
  email:
113
57
  - johann.open-source@protonmail.ch
@@ -122,13 +66,16 @@ files:
122
66
  - ".travis.yml"
123
67
  - CHANGELOG.md
124
68
  - CODE_OF_CONDUCT.md
69
+ - Dockerfile
125
70
  - Gemfile
126
71
  - Gemfile.lock
72
+ - Guardfile
127
73
  - LICENSE.md
128
74
  - README.md
129
75
  - Rakefile
130
76
  - bin/console
131
77
  - bin/setup
78
+ - docker-compose.yml
132
79
  - knowledge.gemspec
133
80
  - lib/knowledge.rb
134
81
  - lib/knowledge/adapters.rb
@@ -137,6 +84,7 @@ files:
137
84
  - lib/knowledge/adapters/file.rb
138
85
  - lib/knowledge/adapters/key_value.rb
139
86
  - lib/knowledge/backupper.rb
87
+ - lib/knowledge/configurable.rb
140
88
  - lib/knowledge/configuration.rb
141
89
  - lib/knowledge/exceptions.rb
142
90
  - lib/knowledge/initializer.rb