tty-config 0.3.1 → 0.5.1

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -1
  3. data/LICENSE.txt +1 -1
  4. data/README.md +305 -153
  5. data/lib/tty/config/dependency_loader.rb +55 -0
  6. data/lib/tty/config/generator.rb +57 -0
  7. data/lib/tty/config/marshaller.rb +66 -0
  8. data/lib/tty/config/marshaller_registry.rb +45 -0
  9. data/lib/tty/config/marshallers/hcl_marshaller.rb +30 -0
  10. data/lib/tty/config/marshallers/ini_marshaller.rb +31 -0
  11. data/lib/tty/config/marshallers/java_props_marshaller.rb +28 -0
  12. data/lib/tty/config/marshallers/json_marshaller.rb +28 -0
  13. data/lib/tty/config/marshallers/toml_marshaller.rb +28 -0
  14. data/lib/tty/config/marshallers/yaml_marshaller.rb +32 -0
  15. data/lib/tty/config/marshallers.rb +35 -0
  16. data/lib/tty/config/version.rb +3 -3
  17. data/lib/tty/config.rb +374 -190
  18. data/lib/tty-config.rb +1 -1
  19. metadata +66 -57
  20. data/Rakefile +0 -8
  21. data/bin/console +0 -14
  22. data/bin/setup +0 -8
  23. data/spec/spec_helper.rb +0 -54
  24. data/spec/unit/alias_setting_spec.rb +0 -72
  25. data/spec/unit/append_spec.rb +0 -26
  26. data/spec/unit/autoload_env_spec.rb +0 -62
  27. data/spec/unit/delete_spec.rb +0 -22
  28. data/spec/unit/exist_spec.rb +0 -24
  29. data/spec/unit/fetch_spec.rb +0 -45
  30. data/spec/unit/generate_spec.rb +0 -70
  31. data/spec/unit/merge_spec.rb +0 -13
  32. data/spec/unit/new_spec.rb +0 -6
  33. data/spec/unit/normalize_hash_spec.rb +0 -21
  34. data/spec/unit/read_spec.rb +0 -109
  35. data/spec/unit/remove_spec.rb +0 -16
  36. data/spec/unit/set_from_env_spec.rb +0 -78
  37. data/spec/unit/set_if_empty_spec.rb +0 -26
  38. data/spec/unit/set_spec.rb +0 -62
  39. data/spec/unit/validate_spec.rb +0 -76
  40. data/spec/unit/write_spec.rb +0 -197
  41. data/tasks/console.rake +0 -11
  42. data/tasks/coverage.rake +0 -11
  43. data/tasks/spec.rake +0 -29
  44. data/tty-config.gemspec +0 -30
data/lib/tty-config.rb CHANGED
@@ -1 +1 @@
1
- require_relative 'tty/config'
1
+ require_relative "tty/config"
metadata CHANGED
@@ -1,129 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-24 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: inifile
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '3.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: java-properties
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0.3'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: toml
56
+ name: rhcl
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.2.0
61
+ version: '0.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.2.0
68
+ version: '0.1'
69
69
  - !ruby/object:Gem::Dependency
70
- name: inifile
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: toml
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 3.0.0
89
+ version: '0.2'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 3.0.0
83
- description: Define, read and write any Ruby app configurations with a penchant for
84
- terminal clients.
96
+ version: '0.2'
97
+ description: A highly customisable application configuration interface for building
98
+ terminal tools. It supports many file formats such as YAML, JSON, TOML, INI, HCL
99
+ and Java Properties.
85
100
  email:
86
- - ''
101
+ - piotr@piotrmurach.com
87
102
  executables: []
88
103
  extensions: []
89
- extra_rdoc_files: []
104
+ extra_rdoc_files:
105
+ - README.md
106
+ - CHANGELOG.md
107
+ - LICENSE.txt
90
108
  files:
91
109
  - CHANGELOG.md
92
110
  - LICENSE.txt
93
111
  - README.md
94
- - Rakefile
95
- - bin/console
96
- - bin/setup
97
112
  - lib/tty-config.rb
98
113
  - lib/tty/config.rb
114
+ - lib/tty/config/dependency_loader.rb
115
+ - lib/tty/config/generator.rb
116
+ - lib/tty/config/marshaller.rb
117
+ - lib/tty/config/marshaller_registry.rb
118
+ - lib/tty/config/marshallers.rb
119
+ - lib/tty/config/marshallers/hcl_marshaller.rb
120
+ - lib/tty/config/marshallers/ini_marshaller.rb
121
+ - lib/tty/config/marshallers/java_props_marshaller.rb
122
+ - lib/tty/config/marshallers/json_marshaller.rb
123
+ - lib/tty/config/marshallers/toml_marshaller.rb
124
+ - lib/tty/config/marshallers/yaml_marshaller.rb
99
125
  - lib/tty/config/version.rb
100
- - spec/spec_helper.rb
101
- - spec/unit/alias_setting_spec.rb
102
- - spec/unit/append_spec.rb
103
- - spec/unit/autoload_env_spec.rb
104
- - spec/unit/delete_spec.rb
105
- - spec/unit/exist_spec.rb
106
- - spec/unit/fetch_spec.rb
107
- - spec/unit/generate_spec.rb
108
- - spec/unit/merge_spec.rb
109
- - spec/unit/new_spec.rb
110
- - spec/unit/normalize_hash_spec.rb
111
- - spec/unit/read_spec.rb
112
- - spec/unit/remove_spec.rb
113
- - spec/unit/set_from_env_spec.rb
114
- - spec/unit/set_if_empty_spec.rb
115
- - spec/unit/set_spec.rb
116
- - spec/unit/validate_spec.rb
117
- - spec/unit/write_spec.rb
118
- - tasks/console.rake
119
- - tasks/coverage.rake
120
- - tasks/spec.rake
121
- - tty-config.gemspec
122
- homepage: https://piotrmurach.github.io/tty
126
+ homepage: https://ttytoolkit.org
123
127
  licenses:
124
128
  - MIT
125
- metadata: {}
126
- post_install_message:
129
+ metadata:
130
+ allowed_push_host: https://rubygems.org
131
+ bug_tracker_uri: https://github.com/piotrmurach/tty-config/issues
132
+ changelog_uri: https://github.com/piotrmurach/tty-config/blob/master/CHANGELOG.md
133
+ documentation_uri: https://www.rubydoc.info/gems/tty-config
134
+ homepage_uri: https://ttytoolkit.org
135
+ source_code_uri: https://github.com/piotrmurach/tty-config
136
+ post_install_message:
127
137
  rdoc_options: []
128
138
  require_paths:
129
139
  - lib
@@ -138,10 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
148
  - !ruby/object:Gem::Version
139
149
  version: '0'
140
150
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.7.3
143
- signing_key:
151
+ rubygems_version: 3.1.2
152
+ signing_key:
144
153
  specification_version: 4
145
- summary: Define, read and write any Ruby app configurations with a penchant for terminal
146
- clients.
154
+ summary: A highly customisable application configuration interface for building terminal
155
+ tools.
147
156
  test_files: []
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
3
- FileList['tasks/**/*.rake'].each(&method(:import))
4
-
5
- desc 'Run all specs'
6
- task ci: %w[ spec ]
7
-
8
- task default: :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "tty/config"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/spec/spec_helper.rb DELETED
@@ -1,54 +0,0 @@
1
- if ENV['COVERAGE'] || ENV['TRAVIS']
2
- require 'simplecov'
3
- require 'coveralls'
4
-
5
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
- SimpleCov::Formatter::HTMLFormatter,
7
- Coveralls::SimpleCov::Formatter
8
- ]
9
-
10
- SimpleCov.start do
11
- command_name 'spec'
12
- add_filter 'spec'
13
- end
14
- end
15
-
16
- require "bundler/setup"
17
- require "tty/config"
18
-
19
- module TestHelpers
20
- module Paths
21
- def gem_root
22
- File.expand_path(File.join(File.dirname(__FILE__), ".."))
23
- end
24
-
25
- def dir_path(*args)
26
- path = File.join(gem_root, *args)
27
- FileUtils.mkdir_p(path) unless ::File.exist?(path)
28
- File.realpath(path)
29
- end
30
-
31
- def tmp_path(*args)
32
- File.join(dir_path('tmp'), *args)
33
- end
34
-
35
- def fixtures_path(*args)
36
- File.join(dir_path('spec/fixtures'), *args)
37
- end
38
-
39
- def within_dir(target, &block)
40
- ::Dir.chdir(target, &block)
41
- end
42
- end
43
- end
44
-
45
- RSpec.configure do |config|
46
- config.include(TestHelpers::Paths)
47
- config.disable_monkey_patching!
48
- config.after(:example, type: :cli) do
49
- FileUtils.rm_rf(tmp_path)
50
- end
51
- config.expect_with :rspec do |c|
52
- c.syntax = :expect
53
- end
54
- end
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Config, '#alias_setting' do
4
- it "aliases setting key" do
5
- config = TTY::Config.new
6
- config.set :foo, value: :baz
7
-
8
- config.alias_setting :foo, to: :bar
9
-
10
- expect(config.fetch(:foo)).to eq(:baz)
11
- expect(config.fetch(:bar)).to eq(:baz)
12
- end
13
-
14
- it "aliases nested key to flat key" do
15
- config = TTY::Config.new
16
- config.set(:foo, :bar, :baz) { 12 }
17
-
18
- config.alias_setting(:foo, :bar, :baz, to: :flat_foo)
19
-
20
- expect(config.fetch(:foo, :bar, :baz)).to eq(12)
21
- expect(config.fetch(:flat_foo)).to eq(12)
22
- end
23
-
24
- it "aliases nested key as a string to flat key" do
25
- config = TTY::Config.new
26
- config.set('foo.bar.baz') { 12 }
27
-
28
- config.alias_setting(:foo, :bar, :baz, to: :flat_foo)
29
-
30
- expect(config.fetch(:foo, :bar, :baz)).to eq(12)
31
- expect(config.fetch(:flat_foo)).to eq(12)
32
- end
33
-
34
- it "aliases nested key to nested key" do
35
- config = TTY::Config.new
36
- config.set(:foo, :bar, :baz) { 12 }
37
-
38
- config.alias_setting(:foo, :bar, :baz, to: [:bee, :bop])
39
-
40
- expect(config.fetch(:foo, :bar, :baz)).to eq(12)
41
- expect(config.fetch(:bee, :bop)).to eq(12)
42
- end
43
-
44
- it "fails to alias to already existing key" do
45
- config = TTY::Config.new
46
- config.set(:foo, value: 1)
47
- config.set(:bar, value: 2)
48
-
49
- expect {
50
- config.alias_setting(:foo, to: :bar)
51
- }.to raise_error(ArgumentError, "Setting already exists with an alias ':bar'")
52
- end
53
-
54
- it "fails to alias to already existing key" do
55
- config = TTY::Config.new
56
- config.set(:foo, :bar, value: 1)
57
- config.set(:baz, :woo, value: 2)
58
-
59
- expect {
60
- config.alias_setting(:foo, :bar, to: [:baz, :woo])
61
- }.to raise_error(ArgumentError, "Setting already exists with an alias ':baz, :woo'")
62
- end
63
-
64
- it "fails to alias to matching key" do
65
- config = TTY::Config.new
66
- config.set(:foo, :bar, value: 1)
67
-
68
- expect {
69
- config.alias_setting(:foo, :bar, to: [:foo, :bar])
70
- }.to raise_error(ArgumentError, "Alias matches setting key")
71
- end
72
- end
@@ -1,26 +0,0 @@
1
- RSpec.describe TTY::Config, '#append' do
2
- it "returns appended values" do
3
- config = TTY::Config.new
4
- values = config.append(:foo, :bar, to: :values)
5
-
6
- expect(values).to eq([:foo, :bar])
7
- expect(config.fetch(:values)).to eq([:foo, :bar])
8
- end
9
-
10
- it "appends values to already existing key" do
11
- config = TTY::Config.new
12
- config.set(:values) { :foo }
13
- values = config.append(:bar, :baz, to: :values)
14
-
15
- expect(config.fetch(:values)).to eq([:foo, :bar, :baz])
16
- expect(values).to eq([:foo, :bar, :baz])
17
- end
18
-
19
- it "appends values to nested key" do
20
- config = TTY::Config.new
21
- config.set(:foo, :bar) { 1 }
22
- values = config.append(2,3, to: [:foo, :bar])
23
- expect(values).to eq([1,2,3])
24
- expect(config.fetch(:foo, :bar)).to eq([1,2,3])
25
- end
26
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Config, '#autoload_env' do
4
- it "autoloads env variables" do
5
- allow(ENV).to receive(:[]).with('HOST').and_return('localhost')
6
- config = TTY::Config.new
7
- expect(config.fetch(:host)).to eq(nil)
8
-
9
- config.autoload_env
10
-
11
- expect(config.fetch(:host)).to eq('localhost')
12
- end
13
-
14
- it "autoloads env variables with prefix" do
15
- allow(ENV).to receive(:[]).with('MYTOOL_HOST').and_return('localhost')
16
- config = TTY::Config.new
17
- config.env_prefix = 'mytool'
18
-
19
- expect(config.fetch(:host)).to eq(nil)
20
-
21
- config.autoload_env
22
-
23
- expect(config.fetch(:host)).to eq('localhost')
24
- end
25
-
26
- it "prioritises set over env vars" do
27
- allow(ENV).to receive(:[]).with('HOST').and_return('localhost')
28
- config = TTY::Config.new
29
- config.autoload_env
30
-
31
- config.set(:host, value: 'myhost')
32
-
33
- expect(config.fetch(:host)).to eq('myhost')
34
- end
35
-
36
- it "prioritises env vars over defaults when a keyword" do
37
- allow(ENV).to receive(:[]).with('PORT').and_return('7727')
38
- config = TTY::Config.new
39
-
40
- config.autoload_env
41
-
42
- expect(config.fetch(:port, default: '3000')).to eq('7727')
43
- end
44
-
45
- it "prioritises env vars over defaults when block" do
46
- allow(ENV).to receive(:[]).with('PORT').and_return('7727')
47
- config = TTY::Config.new
48
-
49
- config.autoload_env
50
-
51
- expect(config.fetch(:port) {'3000' }).to eq('7727')
52
- end
53
-
54
- it "prioritises present configuration over env vars" do
55
- allow(ENV).to receive(:[]).with('PORT').and_return('7727')
56
- config = TTY::Config.new(port: '3000')
57
-
58
- config.autoload_env
59
-
60
- expect(config.fetch(:port)).to eq('3000')
61
- end
62
- end
@@ -1,22 +0,0 @@
1
- RSpec.describe TTY::Config, '#delete' do
2
- it "deletes the value" do
3
- config = TTY::Config.new
4
- config.set(:foo, value: 2)
5
- expect(config.delete(:foo)).to eq(2)
6
- expect(config.fetch(:foo)).to eq(nil)
7
- end
8
-
9
- it "deletes the value under deeply nested key" do
10
- config = TTY::Config.new
11
- config.set(:foo, :bar, :baz) { 2 }
12
- expect(config.delete(:foo, :bar, :baz).call).to eq(2)
13
- expect(config.fetch(:foo, :bar, :baz)).to eq(nil)
14
- end
15
-
16
- it "deletes innermost key with array value" do
17
- config = TTY::Config.new
18
- config.set(:foo, :bar, value: [1,2,3])
19
- expect(config.delete(:foo, :bar)).to eq([1,2,3])
20
- expect(config.fetch(:foo, :bar)).to eq(nil)
21
- end
22
- end
@@ -1,24 +0,0 @@
1
- RSpec.describe TTY::Config, '#exist?', type: :cli do
2
- it "checks if configuration file exists" do
3
- config = TTY::Config.new
4
- config.append_path(tmp_path)
5
-
6
- expect(config.exist?).to eq(false)
7
-
8
- config.write(tmp_path('investments.yml'))
9
-
10
- expect(config.exist?).to eq(true)
11
- end
12
-
13
- it "checks if a file without extension is present" do
14
- config = TTY::Config.new
15
- config.append_path tmp_path
16
-
17
- expect(config.exist?).to eq(false)
18
-
19
- config.write(tmp_path('investments'), format: :yml)
20
-
21
- expect(config.exist?).to eq(true)
22
- expect(config.persisted?).to eq(true)
23
- end
24
- end
@@ -1,45 +0,0 @@
1
- RSpec.describe TTY::Config do
2
- it "fetches default if no value" do
3
- config = TTY::Config.new
4
- expect(config.fetch(:foo, default: :bar)).to eq(:bar)
5
- end
6
-
7
- it "fetches default proc value" do
8
- config = TTY::Config.new
9
- expect(config.fetch(:foo, default: -> { :bar })).to eq(:bar)
10
- end
11
-
12
- it "fetches deeply nested proc value" do
13
- config = TTY::Config.new
14
- expect(config.fetch(:foo, default: -> { -> { :bar }})).to eq(:bar)
15
- end
16
-
17
- it "fetches default as block" do
18
- config = TTY::Config.new
19
- expect(config.fetch(:foo) { :bar }).to eq(:bar)
20
- end
21
-
22
- it "fetches default as block for deeply nested missing key" do
23
- config = TTY::Config.new
24
- expect(config.fetch(:foo, :bar, :baz) { 2 }).to eq(2)
25
- end
26
-
27
- it "fetches value for deeply nested key" do
28
- config = TTY::Config.new
29
- config.set(:foo, :bar, :baz, value: 2)
30
- expect(config.fetch(:foo, :bar, :baz)).to eq(2)
31
- end
32
-
33
- it "fetches value as string delimited by . for deeply nested key" do
34
- config = TTY::Config.new
35
- config.set('foo', 'bar', 'baz') { 2 }
36
- expect(config.fetch("foo.bar.baz")).to eq(2)
37
- end
38
-
39
- it "fetches key with indifferent access" do
40
- config = TTY::Config.new
41
- config.set(:foo, :bar, :baz, value: 2)
42
-
43
- expect(config.fetch('foo', :bar, 'baz')).to eq(2)
44
- end
45
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Config, '#generate' do
4
- it "generate config content" do
5
- conf = {
6
- 'int' => 1,
7
- 'false' => false,
8
- 'str' => 'hello',
9
- 'array' => [1,2,3],
10
- 'deep_array' => [
11
- {foo: 1},
12
- {bar: 2}
13
- ],
14
- 'section' => {
15
- 'value' => 1,
16
- 'empty' => nil,
17
- 'array' => [1,2,3]
18
- },
19
- "empty" => { },
20
- 'nil' => nil,
21
- }
22
-
23
- content = TTY::Config.generate(conf)
24
-
25
- expect(content).to eq <<-EOS
26
- array = 1,2,3
27
- false = false
28
- int = 1
29
- str = hello
30
-
31
- [deep_array]
32
- foo = 1
33
- bar = 2
34
-
35
- [section]
36
- value = 1
37
- array = 1,2,3
38
- EOS
39
- end
40
-
41
- it "generate config content with custom separator" do
42
- conf = {
43
- 'str' => 'hello',
44
- 'array' => [1,2,3],
45
- 'deep_array' => [
46
- {foo: 1},
47
- {bar: 2}
48
- ],
49
- 'section' => {
50
- 'value' => 1,
51
- 'array' => [1,2,3]
52
- }
53
- }
54
-
55
- content = TTY::Config.generate(conf, separator: ':')
56
-
57
- expect(content).to eq <<-EOS
58
- array : 1,2,3
59
- str : hello
60
-
61
- [deep_array]
62
- foo : 1
63
- bar : 2
64
-
65
- [section]
66
- value : 1
67
- array : 1,2,3
68
- EOS
69
- end
70
- end
@@ -1,13 +0,0 @@
1
- RSpec.describe TTY::Config, '#merge' do
2
- it "merges nested hash" do
3
- config = TTY::Config.new
4
- config.set(:a, :b, value: 1)
5
- config.set(:a, :c, value: 2)
6
-
7
- config.merge({'a' => {'c' => 3, 'd' => 4}})
8
-
9
- expect(config.fetch(:a, :b)).to eq(1)
10
- expect(config.fetch(:a, :c)).to eq(3)
11
- expect(config.fetch(:a, :d)).to eq(4)
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- RSpec.describe TTY::Config, '#new' do
2
- it "sets settings through initialization" do
3
- config = TTY::Config.new(foo: "bar")
4
- expect(config.fetch(:foo)).to eq("bar")
5
- end
6
- end
@@ -1,21 +0,0 @@
1
- RSpec.describe TTY::Config, '#normalize_hash' do
2
- it "normalizes keys via method to symbols" do
3
- hash = {
4
- "settings" => {
5
- "base" => "USD",
6
- "color" => true,
7
- "exchange" => "CCCAGG"
8
- },
9
- "coins" => ["BTC", "ETH", "TRX", "DASH"]
10
- }
11
-
12
- expect(TTY::Config.normalize_hash(hash)).to eq({
13
- settings: {
14
- base: "USD",
15
- color: true,
16
- exchange: "CCCAGG"
17
- },
18
- coins: ["BTC", "ETH", "TRX", "DASH"]
19
- })
20
- end
21
- end