better_input 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: 8bf1091645c1a560391ce297d8782434ef4cab23082ace9dd66130713ba444c8
4
+ data.tar.gz: 887189e5e74a48ba84004c097964af27cd8558b8ee45c2a66dc3888e6fadf376
5
+ SHA512:
6
+ metadata.gz: 38f8acda9933caa9d733c9b9e109fd39dd58b2ad75f4825cb38501eb642a46af66a6767fa1a4a990a2dc73ca76cb3608a309595f7eb84cc7baeccb3f8a2a2e79
7
+ data.tar.gz: cd5675272a7f21a79c493375af3185221eada8c2b474c3570487885ae637e93dfcecf2ebe23870c319dc79d6b97524d8220d8934ed85176e45c3bb47af4ecfed
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-11-06
4
+
5
+ - Initial release
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # BetterInput
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/better_input`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/better_input.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,3 @@
1
+ module BetterInput
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,42 @@
1
+ module BetterInput
2
+ def self.input(question = nil, show_response: false, type: "string")
3
+ unless question.nil?
4
+ puts question
5
+ end
6
+
7
+ loop do
8
+ var = gets.chomp
9
+
10
+ case type
11
+ when "int"
12
+ begin
13
+ var = Integer(var)
14
+ rescue ArgumentError
15
+ puts "Err: Please, type a (integer) number."
16
+ next
17
+ end
18
+ when "float"
19
+ begin
20
+ var = Float(var)
21
+ rescue ArgumentError
22
+ puts "Err: Please, type a (float) number."
23
+ next
24
+ end
25
+ when "bool"
26
+ if var.downcase == "true"
27
+ var = true
28
+ elsif var.downcase == "false"
29
+ var = false
30
+ else
31
+ puts "Err: Please, type 'true' or 'false'."
32
+ next
33
+ end
34
+ end
35
+
36
+ if show_response
37
+ puts "User Response: #{var}"
38
+ end
39
+ return var
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ module BetterInput
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: better_input
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Barros FLavio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-11-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: When working with CLI I found myself doing things that could be summarized
14
+ as this function, so I did it!
15
+ email:
16
+ - flaviomarbs@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - README.md
23
+ - Rakefile
24
+ - lib/better_input.rb
25
+ - lib/better_input/version.rb
26
+ - sig/better_input.rbs
27
+ homepage: https://github.com/barrosflavio/ruby_better_input
28
+ licenses: []
29
+ metadata:
30
+ allowed_push_host: https://rubygems.org
31
+ homepage_uri: https://github.com/barrosflavio/ruby_better_input
32
+ source_code_uri: https://github.com/barrosflavio/ruby_better_input
33
+ changelog_uri: https://github.com/barrosflavio/ruby_better_input/blob/main/CHANGELOG.md
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.0.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.5.16
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: A better input function for ruby
53
+ test_files: []