simple_scripting 0.9.0

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.
@@ -0,0 +1,17 @@
1
+ require_relative '../../../lib/simple_scripting/configuration/value.rb'
2
+
3
+ describe SimpleScripting::Configuration::Value do
4
+
5
+ # Encrypting won't yield constant values, as the IV is random, therefore, we test the full cycle.
6
+ #
7
+ it 'should encrypt and decrypt a value' do
8
+ plaintext = 'encrypted_value'
9
+ encryption_key = 'encryption_key'
10
+
11
+ encrypted_value = described_class.new(plaintext, encryption_key).encrypted
12
+ decrypted_value = described_class.new(encrypted_value, encryption_key).decrypted
13
+
14
+ expect(decrypted_value).to eql(plaintext)
15
+ end
16
+
17
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../../lib/simple_scripting/configuration.rb'
2
+
3
+ require 'tempfile'
4
+
5
+ module SimpleScripting::ConfigurationSpecHelper
6
+
7
+ def with_tempfile(config_content)
8
+ tempfile = Tempfile.new('ss_config_test')
9
+ tempfile.write(config_content)
10
+ tempfile.close
11
+
12
+ yield(tempfile.path)
13
+ ensure
14
+ tempfile.unlink
15
+ end
16
+
17
+ end
18
+
19
+ describe SimpleScripting::Configuration do
20
+
21
+ include SimpleScripting::ConfigurationSpecHelper
22
+
23
+ let(:configuration_text) {"
24
+ abspath_key=/tmp/bar
25
+ relpath_key=foo
26
+ encr_key=uTxllKRD2S+IH92oi30luwu0JIqp7kKA
27
+
28
+ [group1]
29
+ g_key=baz
30
+
31
+ [group2]
32
+ g2_key=bang
33
+ "}
34
+
35
+ it 'should parse a configuration' do
36
+ with_tempfile(configuration_text) do |config_file|
37
+ configuration = described_class.load(config_file: config_file, passwords_key: 'encryption_key')
38
+
39
+ expect(configuration.abspath_key.full_path).to eql('/tmp/bar')
40
+
41
+ expect(configuration.relpath_key.full_path).to eql(File.expand_path('foo', '~'))
42
+
43
+ expect(configuration.encr_key.decrypted).to eql('encrypted_value')
44
+
45
+ expect(configuration.group1.g_key).to eql('baz')
46
+ expect(configuration.group1.g_key).to eql('baz')
47
+
48
+ # Make sure the values are converted recursively
49
+ expect(configuration.group2.g2_key.full_path).to eql(File.expand_path('bang', '~'))
50
+ end
51
+ end
52
+
53
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_scripting
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Saverio Miroddi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: parseconfig
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.6'
55
+ description: Simplifies options parsing and configuration loading.
56
+ email:
57
+ - saverio.pub2@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - lib/simple_scripting/argv.rb
70
+ - lib/simple_scripting/configuration.rb
71
+ - lib/simple_scripting/configuration/value.rb
72
+ - lib/simple_scripting/version.rb
73
+ - simple_scripting.gemspec
74
+ - spec/simple_scripting/argv_spec.rb
75
+ - spec/simple_scripting/configuration/value_spec.rb
76
+ - spec/simple_scripting/configuration_spec.rb
77
+ homepage: https://github.com/saveriomiroddi/simple_scripting
78
+ licenses:
79
+ - GPL-3.0
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.5.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Library for simplifying some typical scripting functionalities.
101
+ test_files:
102
+ - spec/simple_scripting/argv_spec.rb
103
+ - spec/simple_scripting/configuration/value_spec.rb
104
+ - spec/simple_scripting/configuration_spec.rb