mongoid-shell 0.4.5 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b0e80be659912607683e05be144ad4456b51a999
4
- data.tar.gz: 9d43a23815209ba7354f1fc22bc8a7f54286d382
2
+ SHA256:
3
+ metadata.gz: 8f3fcabc0004e2cacdcac5776ed0d39e594708ec4ec152540b067bd1888dc527
4
+ data.tar.gz: 38d3a660fb2dfc72dada952faa2e46d692d5cfe0bf36588572932c76d51975eb
5
5
  SHA512:
6
- metadata.gz: d7fb5e80531426776aa4828a30e9dd5d328dff0db4430e20e50f5498c8ad72a1146c5b493e688283ec95ef65fc648fbd6fae72db52ff2d15eac0200d8b332aed
7
- data.tar.gz: 8a35c2256c55e8fa5c2ac3dcf2b998e7b8e32331b3f35e27fac021ffac1cf676419afd2ad42670443142465a2973a1294f4ccf81fcc53ef3bfb1344f03397ddf
6
+ metadata.gz: 8ffbf1bad9524352f98cd3a8bf1d98e544b9c428580442b85b108fa50de25cf4189e081a1639ab886e710fe60200d1c118dd46ee1c8be7eebe8e757d1371ba48
7
+ data.tar.gz: 5b6d190569e9d18542b651658c2b4b8bc58ca836536ac6f54ec6071a5163b19c28b6764fd436f4145c210d989904a0dd3ba7400e099785844593172e79e38135
data/CHANGELOG.md CHANGED
@@ -1,30 +1,41 @@
1
- ### 0.4.5 (9/7/2017)
1
+ ### 0.5.0 (2026/10/14)
2
+
3
+ * [#25](https://github.com/mongoid/mongoid-shell/pull/25): Add SimpleCov and Coveralls reporting in CI and update status badges - [@dblock](https://github.com/dblock).
4
+ * [#24](https://github.com/mongoid/mongoid-shell/pull/24): Test through Ruby 4.0 and MongoDB 8.0 with Mongoid 9, retain legacy coverage, and explicitly bundle OpenStruct - [@dblock](https://github.com/dblock).
5
+ * [#20](https://github.com/mongoid/mongoid-shell/pull/20): Added compatibility with Mongoid 7, 8, 9 - [@dblock](https://github.com/dblock).
6
+ * Migrated CI from Travis CI to GitHub Actions - [@dblock](https://github.com/dblock).
7
+
8
+ ### 0.4.6 (2017/12/29)
9
+
10
+ * [#16](https://github.com/mongoid/mongoid-shell/pull/16): Add `--ssl` and `--authenticationDatabase` support to all commands - [@cavvia](https://github.com/cavvia).
11
+
12
+ ### 0.4.5 (2017/09/07)
2
13
 
3
14
  * [#13](https://github.com/mongoid/mongoid-shell/issues/13): Support masking sensitive values with `to_s(mask_sensitive: true)` - [@dblock](https://github.com/dblock).
4
15
  * [#14](https://github.com/mongoid/mongoid-shell/pull/14): Refactored arg definitions into `arg` and `option` - [@dblock](https://github.com/dblock).
5
16
 
6
- ### 0.4.4 (6/4/2017)
17
+ ### 0.4.4 (2017/06/04)
7
18
 
8
19
  * [#11](https://github.com/mongoid/mongoid-shell/pull/11): Compatibility with Mongoid 6 - [@jbach](https://github.com/jbach).
9
20
  * [#12](https://github.com/mongoid/mongoid-shell/pull/12): Added Danger, PR linter - [@dblock](https://github.com/dblock).
10
21
 
11
- ### 0.4.3 (6/1/2016)
22
+ ### 0.4.3 (2016/06/01)
12
23
 
13
24
  * [#9](https://github.com/mongoid/mongoid-shell/pull/9): Remove example and spec alleging that `--collection` can be specified multiple times - [@joeyAghion](https://github.com/joeyAghion).
14
25
 
15
- ### 0.4.2 (2/9/2015)
26
+ ### 0.4.2 (2015/02/09)
16
27
 
17
28
  * [#8](https://github.com/mongoid/mongoid-shell/pull/8): Support repeatable parameters; add `excludeCollection` and `excludeCollectionsWithPrefix` to `mongodump` - [@joeyAghion](https://github.com/joeyAghion).
18
29
 
19
- ### 0.4.1 (10/25/2015)
30
+ ### 0.4.1 (2015/10/25)
20
31
 
21
32
  * [#7](https://github.com/mongoid/mongoid-shell/pull/7): Added support for `mongoimport` and `mongoexport` - [@hoang1417](https://github.com/hoang1417).
22
33
 
23
- ### 0.4.0 (10/20/2015)
34
+ ### 0.4.0 (2015/10/20)
24
35
 
25
36
  * [#6](https://github.com/mongoid/mongoid-shell/pull/6): Compatibility with Mongoid 5.x - [@dblock](https://github.com/dblock).
26
37
 
27
- ### 0.3.0 (7/1/2014)
38
+ ### 0.3.0 (2014/07/01)
28
39
 
29
40
  * [#3](https://github.com/mongoid/mongoid-shell/pull/3): Added Mongoid 4.x support - [@pawelniewie](https://github.com/pawelniewie), [@dblock](https://github.com/dblock).
30
41
  * [#2](https://github.com/mongoid/mongoid-shell/pull/2): Added support for `--noIndexRestore` to `Mongoid::Shell::Commands::Mongorestore` - [@macreery](https://github.com/macreery).
@@ -33,7 +44,7 @@
33
44
  * Added Rubocop, Ruby style linter - [@dblock](https://github.com/dblock).
34
45
  * Upgraded to RSpec 3.x expectation syntax - [@dblock](https://github.com/dblock).
35
46
 
36
- ### 0.2.0 (1/29/2013)
47
+ ### 0.2.0 (2013/01/29)
37
48
 
38
49
  * Added `Mongoid::Shell::Commands::Mongo` that generates a command line which connects to the session's primary node - [@dblock](https://github.com/dblock).
39
50
  * Added `Mongoid::Shell::Commands::Mongostat` that generates a command line for `mongostat` - [@dblock](https://github.com/dblock).
@@ -43,6 +54,6 @@
43
54
  * Added support for `--nodb`, `--norc`, `--quiet` and `--ipv6` to `Mongoid::Shell::Commands::Mongo` - [@dblock](https://github.com/dblock).
44
55
  * It's now possible to override built-in `db`, `username`, `password`, `host` and `primary` - [@dblock](https://github.com/dblock).
45
56
 
46
- ### 0.1.0 (1/27/2013)
57
+ ### 0.1.0 (2013/01/27)
47
58
 
48
59
  * Initial public release with support for `mongodump` - [@dblock](https://github.com/dblock).
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2013-2016 Daniel Doubrovkine, Artsy Inc.
3
+ Copyright (c) 2013-2026 Daniel Doubrovkine, Artsy Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -2,9 +2,11 @@ Mongoid::Shell
2
2
  ==============
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/mongoid-shell.svg)](https://badge.fury.io/rb/mongoid-shell)
5
- [![Build Status](https://travis-ci.org/mongoid/mongoid-shell.svg?branch=master)](https://travis-ci.org/mongoid/mongoid-shell)
6
- [![Dependency Status](https://gemnasium.com/mongoid/mongoid-shell.svg)](https://gemnasium.com/mongoid/mongoid-shell)
7
- [![Code Climate](https://codeclimate.com/github/mongoid/mongoid-shell.svg)](https://codeclimate.com/github/mongoid/mongoid-shell)
5
+ [![Test](https://github.com/mongoid/mongoid-shell/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/mongoid/mongoid-shell/actions/workflows/test.yml)
6
+ [![Rubocop](https://github.com/mongoid/mongoid-shell/actions/workflows/rubocop.yml/badge.svg?branch=master)](https://github.com/mongoid/mongoid-shell/actions/workflows/rubocop.yml)
7
+ [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid-shell/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid-shell?branch=master)
8
+
9
+ CI collects SimpleCov coverage on Ruby 3.4 with Mongoid 9 and MongoDB 8.0 and submits one report to Coveralls using GitHub's workflow token. To generate a local report, run `COVERAGE=true MONGOID_VERSION=9 bundle install` followed by `COVERAGE=true MONGOID_VERSION=9 bundle exec rake spec`. Reports are written to `coverage/`.
8
10
 
9
11
  Create mongo command-lines from Mongoid configuration.
10
12
 
@@ -56,7 +58,7 @@ To use output in logs, pass the `mask_sensitive` option to `to_s`.
56
58
  Compatibility
57
59
  -------------
58
60
 
59
- This gem supports Mongoid 3, 4, 5 and 6.
61
+ This gem supports Mongoid 3, 4, 5, 6, 7, 8 and 9.
60
62
 
61
63
  Supported Commands
62
64
  ------------------
@@ -69,7 +71,7 @@ The mongo shell is an interactive JavaScript shell for MongoDB. The `Mongoid::Sh
69
71
  Mongoid::Shell::Commands::Mongo.new.to_s
70
72
  ```
71
73
 
72
- Supports `--username`, `--password`, `--eval`, `--nodb`, `--norc`, `--quiet` and `--ipv6`.
74
+ Supports `--username`, `--password`, `--eval`, `--nodb`, `--norc`, `--quiet`, `--ipv6`, `--ssl` and `--authenticationDatabase`.
73
75
 
74
76
  ### Mongodump
75
77
 
@@ -80,7 +82,7 @@ mongodump = Mongoid::Shell::Commands::Mongodump.new(collection: 'test')
80
82
  mongodump.to_s # mongodump --db test --collection test
81
83
  ```
82
84
 
83
- The `Mongoid::Shell::Commands::Mongodump` class supports `--db`, `--host`, `--username`, `--password`, `--query`, `--out`, `--collection`, `--excludeCollection`, `--excludeCollectionsWithPrefix`, `--directoryperdb`, `--journal`, `--oplog`, `--repair`, `--forceTableScan`, `--dbpath` and `--ipv6`.
85
+ The `Mongoid::Shell::Commands::Mongodump` class supports `--db`, `--host`, `--username`, `--password`, `--query`, `--out`, `--collection`, `--excludeCollection`, `--excludeCollectionsWithPrefix`, `--directoryperdb`, `--journal`, `--oplog`, `--repair`, `--forceTableScan`, `--dbpath`, `--ipv6`, `--ssl` and `--authenticationDatabase`
84
86
 
85
87
  ### Mongorestore
86
88
 
@@ -91,7 +93,7 @@ mongorestore = Mongoid::Shell::Commands::Mongorestore.new(collection: 'test', re
91
93
  mongorestore.to_s # mongorestore --db test --collection test /tmp/db_backup
92
94
  ```
93
95
 
94
- The `Mongoid::Shell::Commands::Mongorestore` class supports `--db`, `--host`, `--username`, `--password`, `--collection`, `--ipv6`, `--dbpath`, `--directoryperdb`, `--journal`, `--objcheck`, `--filter`, `--drop`, `--oplogReplay`, `--keepIndexVersion` and `--noIndexRestore`.
96
+ The `Mongoid::Shell::Commands::Mongorestore` class supports `--db`, `--host`, `--username`, `--password`, `--collection`, `--ipv6`, `--dbpath`, `--directoryperdb`, `--journal`, `--objcheck`, `--filter`, `--drop`, `--oplogReplay`, `--keepIndexVersion`, `--noIndexRestore`, `--ssl` and `--authenticationDatabase`
95
97
 
96
98
  ### Mongoexport
97
99
 
@@ -120,7 +122,7 @@ The `Mongoid::Shell::Commands::Mongoimport` class supports `--verbose`, `--quiet
120
122
 
121
123
  The mongostat utility provides a quick overview of the status of a currently running mongod or mongos instance.
122
124
 
123
- The `Mongoid::Shell::Commands::Mongostat` class supports `--host`, `--username`, `--password`, `--rowcount`, `--discover`, `--noheaders`, `--http` and `--all`.
125
+ The `Mongoid::Shell::Commands::Mongostat` class supports `--host`, `--username`, `--password`, `--rowcount`, `--discover`, `--noheaders`, `--http`, `--all`, `--ssl` and `--authenticationDatabase`.
124
126
 
125
127
  Contributing
126
128
  ------------
@@ -132,4 +134,4 @@ Copyright and License
132
134
 
133
135
  MIT License, see [LICENSE](http://github.com/mongoid/mongoid-shell/raw/master/LICENSE.md) for details.
134
136
 
135
- (c) 2013-2016 [Daniel Doubrovkine](http://github.com/dblock), [Artsy Inc.](http://artsy.net)
137
+ (c) 2013-2026 [Daniel Doubrovkine](http://github.com/dblock), [Artsy Inc.](http://artsy.net)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Commands
@@ -6,6 +8,7 @@ module Mongoid
6
8
 
7
9
  class << self
8
10
  attr_accessor :args
11
+
9
12
  @args = {}
10
13
 
11
14
  def inherit_args(args)
@@ -22,12 +25,12 @@ module Mongoid
22
25
  end
23
26
 
24
27
  def arg(name, options = {})
25
- attr_accessor name unless instance_methods.include?(name)
28
+ attr_accessor name unless method_defined?(name)
26
29
  args[name] = { property: name }.merge(options)
27
30
  end
28
31
 
29
32
  def option(name, options = {})
30
- attr_accessor name unless instance_methods.include?(name)
33
+ attr_accessor name unless method_defined?(name)
31
34
  args[name] = { key: "--#{name}", property: name }.merge(options)
32
35
  end
33
36
  end
@@ -47,11 +50,12 @@ module Mongoid
47
50
 
48
51
  def vargs(options = {})
49
52
  mask_sensitive = options[:mask_sensitive]
50
- mask_sensitive = '********' if mask_sensitive && mask_sensitive.is_a?(TrueClass)
53
+ mask_sensitive = '********' if mask_sensitive.is_a?(TrueClass)
51
54
  self.class.args.values.map do |arg|
52
55
  key = arg[:key]
53
56
  value = send(arg[:property])
54
57
  next unless value
58
+
55
59
  case value
56
60
  when Boolean, TrueClass then key
57
61
  when Array then value.map { |v| "#{key} #{v}" }.join(' ')
@@ -61,7 +65,7 @@ module Mongoid
61
65
  else
62
66
  # TODO: quote other special characters?
63
67
  value = value.to_s
64
- value = '"' + value + '"' if value.include? ' '
68
+ value = "\"#{value}\"" if value.include? ' '
65
69
  end
66
70
  key ? "#{key} #{value}" : value
67
71
  end
@@ -74,13 +78,13 @@ module Mongoid
74
78
 
75
79
  private
76
80
 
77
- if ::Mongoid::Compatibility::Version.mongoid3? || ::Mongoid::Compatibility::Version.mongoid4?
81
+ if ::Mongoid::Compatibility::Version.mongoid5_or_newer?
78
82
  def default_client_or_session
79
- Mongoid.default_session
83
+ Mongoid.default_client
80
84
  end
81
85
  else
82
86
  def default_client_or_session
83
- Mongoid.default_client
87
+ Mongoid.default_session
84
88
  end
85
89
  end
86
90
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Commands
@@ -6,6 +8,8 @@ module Mongoid
6
8
  include Mongoid::Shell::Properties::Database
7
9
  include Mongoid::Shell::Properties::Username
8
10
  include Mongoid::Shell::Properties::Password
11
+ include Mongoid::Shell::Properties::AuthenticationDatabase
12
+ include Mongoid::Shell::Properties::SSL
9
13
 
10
14
  arg :host_port_and_db
11
15
 
@@ -16,6 +20,8 @@ module Mongoid
16
20
  option :norc
17
21
  option :quiet
18
22
  option :ipv6
23
+ option :authenticationDatabase
24
+ option :ssl
19
25
 
20
26
  def host_port_and_db
21
27
  [primary, db].compact.join('/')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Commands
@@ -6,6 +8,8 @@ module Mongoid
6
8
  include Mongoid::Shell::Properties::Database
7
9
  include Mongoid::Shell::Properties::Username
8
10
  include Mongoid::Shell::Properties::Password
11
+ include Mongoid::Shell::Properties::AuthenticationDatabase
12
+ include Mongoid::Shell::Properties::SSL
9
13
 
10
14
  option :host
11
15
  option :db
@@ -23,6 +27,8 @@ module Mongoid
23
27
  option :forceTableScan
24
28
  option :dbpath
25
29
  option :ipv6
30
+ option :authenticationDatabase
31
+ option :ssl
26
32
  end
27
33
  end
28
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Commands
@@ -6,6 +8,8 @@ module Mongoid
6
8
  include Mongoid::Shell::Properties::Database
7
9
  include Mongoid::Shell::Properties::Username
8
10
  include Mongoid::Shell::Properties::Password
11
+ include Mongoid::Shell::Properties::AuthenticationDatabase
12
+ include Mongoid::Shell::Properties::SSL
9
13
 
10
14
  # args
11
15
  option :db
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Commands
@@ -6,6 +8,8 @@ module Mongoid
6
8
  include Mongoid::Shell::Properties::Database
7
9
  include Mongoid::Shell::Properties::Username
8
10
  include Mongoid::Shell::Properties::Password
11
+ include Mongoid::Shell::Properties::AuthenticationDatabase
12
+ include Mongoid::Shell::Properties::SSL
9
13
 
10
14
  option :db
11
15
  option :host
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Commands
@@ -6,6 +8,8 @@ module Mongoid
6
8
  include Mongoid::Shell::Properties::Database
7
9
  include Mongoid::Shell::Properties::Username
8
10
  include Mongoid::Shell::Properties::Password
11
+ include Mongoid::Shell::Properties::AuthenticationDatabase
12
+ include Mongoid::Shell::Properties::SSL
9
13
 
10
14
  option :host
11
15
  option :db
@@ -22,6 +26,8 @@ module Mongoid
22
26
  option :oplogReplay
23
27
  option :keepIndexVersion
24
28
  option :noIndexRestore
29
+ option :authenticationDatabase
30
+ option :ssl
25
31
 
26
32
  arg :restore
27
33
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Commands
@@ -6,6 +8,8 @@ module Mongoid
6
8
  include Mongoid::Shell::Properties::Database
7
9
  include Mongoid::Shell::Properties::Username
8
10
  include Mongoid::Shell::Properties::Password
11
+ include Mongoid::Shell::Properties::AuthenticationDatabase
12
+ include Mongoid::Shell::Properties::SSL
9
13
 
10
14
  option :host
11
15
  option :username
@@ -15,6 +19,8 @@ module Mongoid
15
19
  option :noheaders
16
20
  option :http
17
21
  option :all
22
+ option :authenticationDatabase
23
+ option :ssl
18
24
  end
19
25
  end
20
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mongoid/shell/commands/base'
2
4
  require 'mongoid/shell/commands/mongo'
3
5
  require 'mongoid/shell/commands/mongodump'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Errors
@@ -21,13 +23,13 @@ module Mongoid
21
23
  @resolution = create_resolution(key, attributes)
22
24
 
23
25
  "\nProblem:\n #{@problem}" \
24
- "\nSummary:\n #{@summary}" \
25
- "\nResolution:\n #{@resolution}"
26
+ "\nSummary:\n #{@summary}" \
27
+ "\nResolution:\n #{@resolution}"
26
28
  end
27
29
 
28
30
  private
29
31
 
30
- BASE_KEY = 'mongoid.shell.errors.messages'.freeze #:nodoc:
32
+ BASE_KEY = 'mongoid.shell.errors.messages' # :nodoc:
31
33
 
32
34
  # Given the key of the specific error and the options hash, translate the
33
35
  # message.
@@ -38,7 +40,7 @@ module Mongoid
38
40
  #
39
41
  # Returns a localized error message string.
40
42
  def translate(key, options)
41
- ::I18n.translate("#{BASE_KEY}.#{key}", { locale: :en }.merge(options)).strip
43
+ ::I18n.translate("#{BASE_KEY}.#{key}", locale: :en, **options).strip
42
44
  end
43
45
 
44
46
  # Create the problem.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Errors
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Errors
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Errors
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mongoid/shell/errors/base'
2
4
  require 'mongoid/shell/errors/missing_session_error'
3
5
  require 'mongoid/shell/errors/session_not_connected_error'
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mongoid
4
+ module Shell
5
+ module Properties
6
+ module AuthenticationDatabase
7
+ attr_accessor :authenticationDatabase
8
+
9
+ def authenticationDatabase
10
+ @authenticationDatabase || begin
11
+ auth_source = session.options['auth_source']
12
+ auth_source unless auth_source == db
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Properties
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Properties
@@ -10,6 +12,7 @@ module Mongoid
10
12
  @host || begin
11
13
  node = session.cluster.nodes.first
12
14
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless node
15
+
13
16
  node.address == 'localhost:27017' ? nil : node.address
14
17
  end
15
18
  end
@@ -18,6 +21,7 @@ module Mongoid
18
21
  @host || begin
19
22
  node = session.cluster.nodes.first
20
23
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless node
24
+
21
25
  node.address.original == 'localhost:27017' ? nil : node.address.original
22
26
  end
23
27
  end
@@ -26,6 +30,7 @@ module Mongoid
26
30
  @host || begin
27
31
  node = session.cluster.servers.first
28
32
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless node
33
+
29
34
  node.address.to_s == 'localhost:27017' ? nil : node.address.to_s
30
35
  end
31
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Properties
@@ -8,7 +10,8 @@ module Mongoid
8
10
  if ::Mongoid::Compatibility::Version.mongoid3?
9
11
  def password
10
12
  @password || begin
11
- return nil unless session.context.cluster.auth && session.context.cluster.auth.first
13
+ return nil unless session.context.cluster.auth&.first
14
+
12
15
  session.context.cluster.auth.first[1][1]
13
16
  end
14
17
  end
@@ -18,18 +21,13 @@ module Mongoid
18
21
  node = session.cluster.nodes.first
19
22
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless node
20
23
  return nil if !node.credentials.key?(db) || node.credentials[db].empty?
24
+
21
25
  node.credentials[db][1]
22
26
  end
23
27
  end
24
28
  else
25
29
  def password
26
- @password || begin
27
- server = session.cluster.servers.first
28
- raise Mongoid::Shell::Errors::SessionNotConnectedError unless server
29
- server.context.with_connection do |connection|
30
- connection.options[:password]
31
- end
32
- end
30
+ @password || session.options[:password]
33
31
  end
34
32
  end
35
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Properties
@@ -9,8 +11,10 @@ module Mongoid
9
11
  def primary
10
12
  @primary || begin
11
13
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless session.cluster.nodes.any?
14
+
12
15
  node = session.cluster.nodes.find(&:primary?)
13
16
  raise Mongoid::Shell::Errors::MissingPrimaryNodeError unless node
17
+
14
18
  node.address == 'localhost:27017' ? nil : node.address
15
19
  end
16
20
  end
@@ -18,8 +22,10 @@ module Mongoid
18
22
  def primary
19
23
  @primary || begin
20
24
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless session.cluster.nodes.any?
25
+
21
26
  node = session.cluster.nodes.find(&:primary?)
22
27
  raise Mongoid::Shell::Errors::MissingPrimaryNodeError unless node
28
+
23
29
  node.address.original == 'localhost:27017' ? nil : node.address.original
24
30
  end
25
31
  end
@@ -27,8 +33,10 @@ module Mongoid
27
33
  def primary
28
34
  @primary || begin
29
35
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless session.cluster.servers.any?
36
+
30
37
  node = session.cluster.servers.find { |server| server.primary? || server.standalone? }
31
38
  raise Mongoid::Shell::Errors::MissingPrimaryNodeError unless node
39
+
32
40
  node.address.to_s == 'localhost:27017' ? nil : node.address.to_s
33
41
  end
34
42
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mongoid
4
+ module Shell
5
+ module Properties
6
+ module SSL
7
+ attr_accessor :ssl
8
+
9
+ def ssl
10
+ return @ssl unless @ssl.nil?
11
+
12
+ session.options['ssl']
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
5
  module Properties
@@ -8,7 +10,8 @@ module Mongoid
8
10
  if ::Mongoid::Compatibility::Version.mongoid3?
9
11
  def username
10
12
  @username || begin
11
- return nil unless session.context.cluster.auth && session.context.cluster.auth.first
13
+ return nil unless session.context.cluster.auth&.first
14
+
12
15
  session.context.cluster.auth.first[1][0]
13
16
  end
14
17
  end
@@ -18,18 +21,13 @@ module Mongoid
18
21
  node = session.cluster.nodes.first
19
22
  raise Mongoid::Shell::Errors::SessionNotConnectedError unless node
20
23
  return nil if !node.credentials.key?(db) || node.credentials[db].empty?
24
+
21
25
  node.credentials[db][0]
22
26
  end
23
27
  end
24
28
  else
25
29
  def username
26
- @username || begin
27
- server = session.cluster.servers.first
28
- raise Mongoid::Shell::Errors::SessionNotConnectedError unless server
29
- server.context.with_connection do |connection|
30
- connection.options[:user]
31
- end
32
- end
30
+ @username || session.options[:user]
33
31
  end
34
32
  end
35
33
  end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mongoid/shell/properties/host'
2
4
  require 'mongoid/shell/properties/primary'
3
5
  require 'mongoid/shell/properties/database'
4
6
  require 'mongoid/shell/properties/username'
5
7
  require 'mongoid/shell/properties/password'
8
+ require 'mongoid/shell/properties/authentication_database'
9
+ require 'mongoid/shell/properties/ssl'
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mongoid
2
4
  module Shell
3
- VERSION = '0.4.5'.freeze
5
+ VERSION = '0.5.0'
4
6
  end
5
7
  end
data/lib/mongoid-shell.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'i18n'
2
4
 
3
5
  I18n.load_path << File.join(File.dirname(__FILE__), 'config', 'locales', 'en.yml')
data/lib/mongoid_shell.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mongoid-shell'
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2026-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: mongoid
14
+ name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: '0'
20
20
  type: :runtime
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: 3.0.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: i18n
28
+ name: mongoid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 3.0.0
34
34
  type: :runtime
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: '0'
40
+ version: 3.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mongoid-compatibility
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description:
55
+ description:
56
56
  email: dblock@dblock.org
57
57
  executables: []
58
58
  extensions: []
@@ -77,18 +77,21 @@ files:
77
77
  - lib/mongoid/shell/errors/missing_session_error.rb
78
78
  - lib/mongoid/shell/errors/session_not_connected_error.rb
79
79
  - lib/mongoid/shell/properties.rb
80
+ - lib/mongoid/shell/properties/authentication_database.rb
80
81
  - lib/mongoid/shell/properties/database.rb
81
82
  - lib/mongoid/shell/properties/host.rb
82
83
  - lib/mongoid/shell/properties/password.rb
83
84
  - lib/mongoid/shell/properties/primary.rb
85
+ - lib/mongoid/shell/properties/ssl.rb
84
86
  - lib/mongoid/shell/properties/username.rb
85
87
  - lib/mongoid/shell/version.rb
86
88
  - lib/mongoid_shell.rb
87
89
  homepage: http://github.com/mongoid/mongoid-shell
88
90
  licenses:
89
91
  - MIT
90
- metadata: {}
91
- post_install_message:
92
+ metadata:
93
+ rubygems_mfa_required: 'true'
94
+ post_install_message:
92
95
  rdoc_options: []
93
96
  require_paths:
94
97
  - lib
@@ -103,9 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
106
  - !ruby/object:Gem::Version
104
107
  version: 1.3.6
105
108
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.6.12
108
- signing_key:
109
+ rubygems_version: 3.5.16
110
+ signing_key:
109
111
  specification_version: 4
110
112
  summary: Derive shell commands from Mongoid configuration options.
111
113
  test_files: []