highline_wrapper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0454ae57461089fa8b01bd5174e89e8eb71dc41c110a82bb86f4473f345bafdf
4
+ data.tar.gz: 34dba9a54d461b365da6de34bbd1c20611bec926df54699c2673306a9eb82828
5
+ SHA512:
6
+ metadata.gz: 513c0869cf6ac26663fcab9e65cb01897875fcdd4a9d31ff9ff890728a9004a26f1503c94c374e363d99b6e1649931427c121f4a10638120cbec11e9efdd78a8
7
+ data.tar.gz: 85e805046f5d586303ea0286ab810d974d6a3466e57e0c794f3d61771e9a67cebf17039100490841c1716d16b79b9c88b1a0c62bea818ec73c6bdd660aaecc24
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in highline_wrapper.gemspec
6
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'bundle exec rspec', all_on_start: true do
4
+ watch(%r{^spec/.+_spec\.rb$})
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
6
+ watch('spec/spec_helper.rb') { 'spec' }
7
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 Emma Sax
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # Highline Wrapper [![Main](https://github.com/emmahsax/highline_wrapper/actions/workflows/main.yml/badge.svg)](https://github.com/emmahsax/highline_wrapper/actions/workflows/main.yml)
2
+
3
+ A little wrapper to help ask some easy questions via the command-line with Highline. The types of questions this wrapper supports is:
4
+
5
+ * Open-ended question
6
+ * Yes/No question
7
+ * Multiple choice question where the user is allowed to select one answer
8
+ * Multiple choice "checkbox" question where the user is allowed to select multiple answers
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'highline_wrapper'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ ```bash
21
+ bundle install
22
+ ```
23
+
24
+ Or install it yourself as:
25
+
26
+ ```bash
27
+ gem install highline_wrapper
28
+ ```
29
+
30
+ ### Usage
31
+
32
+ Once this gem is installed, you can then initiate a new `HighlineWrapper` object:
33
+
34
+ ```ruby
35
+ HighlineWrapper.new
36
+ ```
37
+
38
+ Then, add this to the top of your file (or to your gem):
39
+
40
+ ```ruby
41
+ require 'highline_wrapper'
42
+ ```
43
+
44
+ Then, you can call its questions to receive answers:
45
+
46
+ ```ruby
47
+ > HighlineWrapper.new.ask('What is your favorite number?')
48
+ What is your favorite number?
49
+ four
50
+ => "four"
51
+
52
+ > HighlineWrapper.new.ask_yes_no('Do you like Ruby?')
53
+ Do you like Ruby?
54
+ no
55
+ => false
56
+
57
+ > HighlineWrapper.new.ask_yes_no('Do you like Ruby?')
58
+ Do you like Ruby?
59
+ yes
60
+ => true
61
+
62
+ HighlineWrapper.new.ask_multiple_choice('What is your favorite number of t
63
+ hese?', ['one', 'two', 'three'])
64
+ What is your favorite number of these?
65
+ 1. one
66
+ 2. two
67
+ 3. three
68
+ 2
69
+ => "two"
70
+
71
+ > HighlineWrapper.new.ask_checkbox("What are your favorite numbers of these?
72
+ ", ['one', 'two','three'])
73
+ What are your favorite numbers of these?
74
+ 1. one
75
+ 2. two
76
+ 3. three
77
+ 1,3
78
+ => ["one", "three"]
79
+
80
+ > HighlineWrapper.new.ask_checkbox("What are your favorite numbers of these?
81
+ ", ['one', 'two','three'], with_indexes: true)
82
+ What are your favorite numbers of these?
83
+ 1. one
84
+ 2. two
85
+ 3. three
86
+ 1, 3
87
+ => [{:choice=>"one", :index=>0}, {:choice=>"three", :index=>2}]
88
+ ```
89
+
90
+ ### Tests
91
+
92
+ To run the tests, run `bundle exec rspec` from the command line. GitHub Actions will also run the tests upon every commit to make sure they're up to date and that everything is working correctly. Locally, you can also run `bundle exec guard` to automatically run tests as you develop!
93
+
94
+ ## Contributing
95
+
96
+ To submit a feature request, bug ticket, etc, please submit an official [GitHub Issue](https://github.com/emmahsax/highline_wrapper/issues/new).
97
+
98
+ To report any security vulnerabilities, please view this project's [Security Policy](https://github.com/emmahsax/highline_wrapper/security/policy).
99
+
100
+ When interacting with this repository, please follow [Contributor Covenant's Code of Conduct](https://contributor-covenant.org).
101
+
102
+ ## Releasing
103
+
104
+ To make a new release of this gem:
105
+
106
+ 1. Merge the pull request via the big green button
107
+ 2. Run `git tag vX.X.X` and `git push --tag`
108
+ 3. Make a new release [here](https://github.com/emmahsax/highline_wrapper/releases/new)
109
+ 4. Run `gem build *.gemspec`
110
+ 5. Run `gem push *.gem` to push the new gem to RubyGems
111
+ 6. Run `rm *.gem` to clean up your local repository
112
+
113
+ To set up your local machine to push to RubyGems via the API, see the [RubyGems documentation](https://guides.rubygems.org/publishing/#publishing-to-rubygemsorg).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'highline'
4
+
5
+ files = "#{File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), 'highline_wrapper'))}/**/*.rb"
6
+
7
+ Dir[files].each do |file|
8
+ require_relative file
9
+ end
10
+
11
+ class HighlineWrapper
12
+ # Returns - string; the answer to the question
13
+ # prompt - string; the prompt for the question
14
+ def ask(prompt, secret: false)
15
+ client.ask(prompt, secret)
16
+ end
17
+
18
+ # Returns - boolean; yes for true, no for false
19
+ # prompt - string; the prompt for the question
20
+ # preference - boolean; whether skipping the question should return true or false
21
+ def ask_yes_no(prompt, preference: true)
22
+ client.ask_yes_no(prompt, preference)
23
+ end
24
+
25
+ # Returns - string OR hash; the selection
26
+ # e.g. 'c'
27
+ # prompt - string; the prompt for the question
28
+ # choices - array; an array of string options
29
+ # e.g. [ 'a', 'b', 'c' ]
30
+ # with_index - boolean; whether to return the index of the selection
31
+ # e.g. { choice: 'c', index: 2 }
32
+ def ask_multiple_choice(prompt, choices, with_index: false)
33
+ client.ask_multiple_choice(prompt, choices, with_index)
34
+ end
35
+
36
+ # Returns - array; an array of selections
37
+ # e.g. [ 'a', 'c' ]
38
+ # prompt - string; the prompt for the question
39
+ # choices - array; an array of string options
40
+ # e.g. [ 'a', 'b', 'c' ]
41
+ # with_indexes - boolean; whether to return the indices of the selections
42
+ # e.g. [ { choice: 'a', index: 0 }, { choice: 'c', index: 2 } ]
43
+ def ask_checkbox(prompt, choices, with_indexes: false)
44
+ client.ask_checkbox(prompt, choices, with_indexes)
45
+ end
46
+
47
+ private def client
48
+ @client ||= HighlineWrapper::Client.new
49
+ end
50
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ class HighlineWrapper
4
+ class Client
5
+ def ask(prompt, secret)
6
+ highline.ask(prompt) do |conf|
7
+ conf.readline = true
8
+ if secret
9
+ conf.echo = false
10
+ conf.echo = '*'
11
+ end
12
+ end.to_s
13
+ end
14
+
15
+ def ask_yes_no(prompt, preference)
16
+ answer = highline.ask(prompt) do |conf|
17
+ conf.readline = true
18
+ end.to_s
19
+
20
+ answer.empty? ? preference : !!(answer =~ /^y/i)
21
+ end
22
+
23
+ def ask_multiple_choice(prompt, choices, with_index)
24
+ index = highline.ask(format_options(prompt, choices)) do |conf|
25
+ conf.readline = true
26
+ end.to_i - 1
27
+
28
+ if with_index
29
+ { choice: choices[index], index: index }
30
+ else
31
+ choices[index]
32
+ end
33
+ end
34
+
35
+ # rubocop:disable Metrics/AbcSize
36
+ # rubocop:disable Metrics/MethodLength
37
+ def ask_checkbox(prompt, choices, provide_indices)
38
+ indices = []
39
+ selected = []
40
+
41
+ answer = highline.ask(format_options(prompt, choices)) do |conf|
42
+ conf.readline = true
43
+ end
44
+
45
+ answer.split(',').each { |i| indices << i.strip.to_i - 1 }
46
+
47
+ if provide_indices
48
+ indices.each { |index| selected << { choice: choices[index], index: index } }
49
+ else
50
+ indices.each { |index| selected << choices[index] }
51
+ end
52
+
53
+ selected
54
+ end
55
+ # rubocop:enable Metrics/MethodLength
56
+ # rubocop:enable Metrics/AbcSize
57
+
58
+ private def format_options(prompt, choices)
59
+ choices_as_string_options = ''.dup
60
+ choices.each_with_index { |choice, index| choices_as_string_options << "#{index + 1}. #{choice}\n" }
61
+ "#{prompt}\n#{choices_as_string_options.strip}"
62
+ end
63
+
64
+ private def highline
65
+ @highline ||= HighLine.new
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class HighlineWrapper
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'highline_wrapper'
5
+
6
+ describe HighlineWrapper::Client do
7
+ let(:response) { double(:response, readline: true, to_i: 3) }
8
+ let(:highline) { double(:highline_cli, ask: response) }
9
+
10
+ before do
11
+ allow(HighLine).to receive(:new).and_return(highline)
12
+ end
13
+
14
+ describe '#ask' do
15
+ it 'should ask the highline client ask' do
16
+ expect(highline).to receive(:ask)
17
+ subject.ask(Faker::Lorem.sentence, false)
18
+ end
19
+
20
+ it 'should return a string' do
21
+ expect(subject.ask(Faker::Lorem.sentence, true)).to be_a(String)
22
+ end
23
+ end
24
+
25
+ describe '#ask_yes_no' do
26
+ it 'should ask the highline client ask' do
27
+ expect(highline).to receive(:ask)
28
+ subject.ask_yes_no(Faker::Lorem.sentence, true)
29
+ end
30
+
31
+ it 'should return a boolean' do
32
+ expect(subject.ask_yes_no(Faker::Lorem.sentence, false)).to be_falsey
33
+ end
34
+
35
+ it 'should return true if we say yes' do
36
+ allow(response).to receive(:to_s).and_return('y')
37
+ expect(subject.ask_yes_no(Faker::Lorem.sentence, false)).to be_truthy
38
+ end
39
+
40
+ it 'should return false if we say yes' do
41
+ allow(response).to receive(:to_s).and_return('no')
42
+ expect(subject.ask_yes_no(Faker::Lorem.sentence, true)).to be_falsey
43
+ end
44
+
45
+ context 'when preferring true' do
46
+ it 'should return true if empty' do
47
+ allow(response).to receive(:to_s).and_return('')
48
+ expect(subject.ask_yes_no(Faker::Lorem.sentence, true)).to be_truthy
49
+ end
50
+
51
+ it 'should return false if empty' do
52
+ allow(response).to receive(:to_s).and_return('')
53
+ expect(subject.ask_yes_no(Faker::Lorem.sentence, false)).to be_falsey
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '#ask_multiple_choice' do
59
+ it 'should ask the highline client ask' do
60
+ expect(highline).to receive(:ask)
61
+ subject.ask_multiple_choice(Faker::Lorem.sentence, %w[one two three], false)
62
+ end
63
+
64
+ context 'when not including the index' do
65
+ it 'should return an array of one from the options' do
66
+ resp = subject.ask_multiple_choice(Faker::Lorem.sentence, %w[one two three], false)
67
+ expect(resp).to be_a(String)
68
+ expect(resp).to eq('three')
69
+ end
70
+ end
71
+
72
+ context 'when including the index' do
73
+ it 'should return an array of two' do
74
+ resp = subject.ask_multiple_choice(Faker::Lorem.sentence, %w[one two three], true)
75
+ expect(resp).to be_a(Hash)
76
+ expect(resp[:choice]).to eq('three')
77
+ expect(resp[:index]).to eq(2)
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#ask_checkbox' do
83
+ it 'should ask the highline client ask' do
84
+ expect(highline).to receive(:ask).and_return('2')
85
+ subject.ask_checkbox(Faker::Lorem.sentence, %w[one two three], false)
86
+ end
87
+
88
+ context 'when not including the index' do
89
+ it 'should return an array of one from the options' do
90
+ allow(highline).to receive(:ask).and_return('1, 3')
91
+ resp = subject.ask_checkbox(Faker::Lorem.sentence, %w[one two three], false)
92
+ expect(resp).to be_a(Array)
93
+ expect(resp.count).to eq(2)
94
+ expect(resp).to include('one')
95
+ end
96
+ end
97
+
98
+ context 'when including the index' do
99
+ it 'should return an array of two' do
100
+ allow(highline).to receive(:ask).and_return('1, 3')
101
+ resp = subject.ask_checkbox(Faker::Lorem.sentence, %w[one two three], true)
102
+ expect(resp).to be_a(Array)
103
+ expect(resp.count).to eq(2)
104
+ expect(resp).to include({ choice: 'one', index: 0 })
105
+ expect(resp).to include({ choice: 'three', index: 2 })
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faker'
4
+ require 'pry'
5
+
6
+ # This file was generated by the `rspec --init` command. Conventionally, all
7
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
9
+ # this file to always be loaded, without a need to explicitly require it in any
10
+ # files.
11
+ #
12
+ # Given that it is always loaded, you are encouraged to keep this file as
13
+ # light-weight as possible. Requiring heavyweight dependencies from this file
14
+ # will add to the boot time of your test suite on EVERY test run, even for an
15
+ # individual file that may not need all of that loaded. Instead, consider making
16
+ # a separate helper file that requires the additional dependencies and performs
17
+ # the additional setup, and require it from the spec files that actually need
18
+ # it.
19
+ #
20
+ # The `.rspec` file also contains a few flags that are not defaults but that
21
+ # users commonly want.
22
+ #
23
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
24
+ RSpec.configure do |config|
25
+ # rspec-expectations config goes here. You can use an alternate
26
+ # assertion/expectation library such as wrong or the stdlib/minitest
27
+ # assertions if you prefer.
28
+ config.expect_with :rspec do |expectations|
29
+ # This option will default to `true` in RSpec 4. It makes the `description`
30
+ # and `failure_message` of custom matchers include text for helper methods
31
+ # defined using `chain`, e.g.:
32
+ # be_bigger_than(2).and_smaller_than(4).description
33
+ # # => "be bigger than 2 and smaller than 4"
34
+ # ...rather than:
35
+ # # => "be bigger than 2"
36
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
37
+ end
38
+
39
+ config.filter_run focus: true
40
+ config.run_all_when_everything_filtered = true
41
+
42
+ # rspec-mocks config goes here. You can use an alternate test double
43
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
44
+ config.mock_with :rspec do |mocks|
45
+ # Prevents you from mocking or stubbing a method that does not exist on
46
+ # a real object. This is generally recommended, and will default to
47
+ # `true` in RSpec 4.
48
+ mocks.verify_partial_doubles = true
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: highline_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Emma Sax
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faker
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.9'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Making it easier to ask simple questions, such as multiple choice questions,
126
+ yes/no questions, etc, using Highline
127
+ email:
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - Gemfile
133
+ - Guardfile
134
+ - LICENSE
135
+ - README.md
136
+ - Rakefile
137
+ - lib/highline_wrapper.rb
138
+ - lib/highline_wrapper/client.rb
139
+ - lib/highline_wrapper/version.rb
140
+ - spec/highline_wrapper/client_spec.rb
141
+ - spec/spec_helper.rb
142
+ homepage: https://github.com/emmahsax/highline_wrapper
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 1.9.3
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubygems_version: 3.2.3
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: A little wrapper for Highline
165
+ test_files:
166
+ - spec/spec_helper.rb
167
+ - spec/highline_wrapper/client_spec.rb