keepass_kpscript 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ describe KeepassKpscript::Select do
2
+
3
+ shared_examples 'a selector' do
4
+
5
+ subject(:selector) { KeepassKpscript.use('/path/to/KPScript.exe', debug: debug).select }
6
+
7
+ {
8
+ proc { |s| s.fields(Field: 'Value') } => '-ref-Field:"Value"',
9
+ proc { |s| s.fields(Field1: 'Value1', Field2: 'Value2') } => '-ref-Field1:"Value1" -ref-Field2:"Value2"',
10
+ proc { |s| s.fields(Field1: 'Value1').fields(Field2: 'Value2') } => '-ref-Field1:"Value1" -ref-Field2:"Value2"',
11
+ proc { |s| s.uuid('MyUUID') } => '-refx-UUID:MyUUID',
12
+ proc { |s| s.tags %w[tag1 tag2] } => '-refx-Tags:"tag1,tag2"',
13
+ proc { |s| s.tags(*%w[tag1 tag2]) } => '-refx-Tags:"tag1,tag2"',
14
+ proc { |s| s.expires } => '-refx-Expires:true',
15
+ proc { |s| s.expires(false) } => '-refx-Expires:false',
16
+ proc { |s| s.expired } => '-refx-Expired:true',
17
+ proc { |s| s.expired(false) } => '-refx-Expired:false',
18
+ proc { |s| s.group('MyGroup') } => '-refx-Group:"MyGroup"',
19
+ proc { |s| s.group_path %w[Group1 Group2 Group3] } => '-refx-GroupPath:"Group1/Group2/Group3"',
20
+ proc { |s| s.group_path(*%w[Group1 Group2 Group3]) } => '-refx-GroupPath:"Group1/Group2/Group3"',
21
+ proc { |s| s.all } => '-refx-All',
22
+ proc do |s|
23
+ # Check here that all methods are chainable
24
+ s.
25
+ group('MyGroup').
26
+ expires.
27
+ expired(false).
28
+ tags('MyTag').
29
+ fields(Field: 'Value').
30
+ uuid('MyUUID').
31
+ group_path(%w[Group1 Group2]).
32
+ all.
33
+ fields(Field1: 'Value1', Field2: 'Value2')
34
+ end => '-refx-Group:"MyGroup" -refx-Expires:true -refx-Expired:false -refx-Tags:"MyTag" -ref-Field:"Value" -refx-UUID:MyUUID -refx-GroupPath:"Group1/Group2" -refx-All -ref-Field1:"Value1" -ref-Field2:"Value2"'
35
+ }.each.with_index do |(select_block, expected_args), example_idx|
36
+
37
+ it "selects #{expected_args} (example ##{example_idx})" do
38
+ expect(select_block.call(selector).to_s).to eq expected_args
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ context 'without debug' do
46
+
47
+ it_behaves_like 'a selector' do
48
+ let(:debug) { false }
49
+ end
50
+
51
+ end
52
+
53
+ context 'with debug' do
54
+
55
+ it_behaves_like 'a selector' do
56
+ let(:debug) { true }
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,31 @@
1
+ require 'json'
2
+
3
+ describe 'Coding guidelines' do
4
+
5
+ it 'makes sure code style follow Rubocop guides' do
6
+ rubocop_report = JSON.parse(`bundle exec rubocop --format json`)
7
+ expect(rubocop_report['summary']['offense_count']).to(
8
+ eq(0),
9
+ proc do
10
+ # Format a great error message to help
11
+ wrong_files = rubocop_report['files'].reject { |file_info| file_info['offenses'].empty? }
12
+ <<~EO_ERROR
13
+ #{wrong_files.size} files have Rubocop issues:
14
+ #{
15
+ wrong_files.map do |file_info|
16
+ offenses = file_info['offenses'].map { |offense_info| "L#{offense_info['location']['start_line']}: #{offense_info['cop_name']} - #{offense_info['message']}" }
17
+ "* #{file_info['path']}:#{
18
+ if offenses.size == 1
19
+ " #{offenses.first}"
20
+ else
21
+ " #{offenses.size} offenses:\n#{offenses.map { |offense| " - #{offense}" }.join("\n")}"
22
+ end
23
+ }"
24
+ end.join("\n")
25
+ }
26
+ EO_ERROR
27
+ end
28
+ )
29
+ end
30
+
31
+ end
@@ -0,0 +1,102 @@
1
+ require 'keepass_kpscript_test/helpers'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
+ # have no way to turn it off -- the option exists only for backwards
44
+ # compatibility in RSpec 3). It causes shared context metadata to be
45
+ # inherited by the metadata hash of host groups and examples, rather than
46
+ # triggering implicit auto-inclusion in groups with matching metadata.
47
+ config.shared_context_metadata_behavior = :apply_to_host_groups
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+
52
+ # This allows you to limit a spec run to individual examples or groups
53
+ # you care about by tagging them with `:focus` metadata. When nothing
54
+ # is tagged with `:focus`, all examples get run. RSpec also provides
55
+ # aliases for `it`, `describe`, and `context` that include `:focus`
56
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
57
+ # config.filter_run_when_matching :focus
58
+
59
+ # Allows RSpec to persist some state between runs in order to support
60
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
61
+ # you configure your source control system to ignore this file.
62
+ # config.example_status_persistence_file_path = "spec/examples.txt"
63
+
64
+ # Limits the available syntax to the non-monkey patched syntax that is
65
+ # recommended. For more details, see:
66
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
67
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
68
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
69
+ # config.disable_monkey_patching!
70
+
71
+ # This setting enables warnings. It's recommended, but in some cases may
72
+ # be too noisy due to issues in dependencies.
73
+ # config.warnings = true
74
+
75
+ # Many RSpec users commonly either run the entire suite or an individual
76
+ # file, and it's useful to allow more verbose output when running an
77
+ # individual spec file.
78
+ # if config.files_to_run.one?
79
+ # # Use the documentation formatter for detailed output,
80
+ # # unless a formatter has already been configured
81
+ # # (e.g. via a command-line flag).
82
+ # config.default_formatter = "doc"
83
+ # end
84
+
85
+ # Print the 10 slowest examples and example groups at the
86
+ # end of the spec run, to help surface which specs are running
87
+ # particularly slow.
88
+ # config.profile_examples = 10
89
+
90
+ # Run specs in random order to surface order dependencies. If you find an
91
+ # order dependency and want to debug it, you can fix the order by providing
92
+ # the seed, which is printed after each run.
93
+ # --seed 1234
94
+ # config.order = :random
95
+
96
+ # Seed global randomization in this process using the `--seed` CLI option.
97
+ # Setting this allows you to use `--seed` to deterministically reproduce
98
+ # test failures related to randomization by passing the same `--seed` value
99
+ # as the one that triggered the failure.
100
+ # Kernel.srand config.seed
101
+
102
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: keepass_kpscript
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Muriel Salvan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: secret_string
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: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sem_ver_components
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.4'
83
+ description: Ruby API to handle Keepass databases using KPScript
84
+ email:
85
+ - muriel@x-aeon.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files:
89
+ - README.md
90
+ - CHANGELOG.md
91
+ files:
92
+ - CHANGELOG.md
93
+ - README.md
94
+ - lib/keepass_kpscript.rb
95
+ - lib/keepass_kpscript/database.rb
96
+ - lib/keepass_kpscript/kpscript.rb
97
+ - lib/keepass_kpscript/pass_encryptor.kdbx
98
+ - lib/keepass_kpscript/select.rb
99
+ - lib/keepass_kpscript/version.rb
100
+ - spec/keepass_kpscript_test/helpers.rb
101
+ - spec/keepass_kpscript_test/tests/keepass_kpscript/database_spec.rb
102
+ - spec/keepass_kpscript_test/tests/keepass_kpscript/kpscript_spec.rb
103
+ - spec/keepass_kpscript_test/tests/keepass_kpscript/select_spec.rb
104
+ - spec/keepass_kpscript_test/tests/rubocop_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage:
107
+ licenses:
108
+ - BSD-3-Clause
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '2.7'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubygems_version: 3.1.6
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Keepass KPScript
129
+ test_files: []