dummy_parser 1.0.1
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 +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/README.md +1 -0
- data/bin/dummy_parser +46 -0
- data/dummy_parser.gemspec +14 -0
- data/lib/dummy_parser.rb +1 -0
- data/lib/dummy_parser/version.rb +3 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b61aa2666e9359f58e67749cd21940963c5de3dd52dee0d38f89d14b4befef8
|
4
|
+
data.tar.gz: 36093095634a48dfd324a0ac9a8d6667a990f87893e22d4ae854682f34dae5da
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c5cecd47d3b7d7e12c0e43ffbd456453efa15db5d82c3a1fdd4403e7f8e5e1c3975f03b445ce68491ec5c949a9b741fa605ce8152fb66827cb2d62a32c2a059
|
7
|
+
data.tar.gz: '05896b553f96cfc3e501941d18990ad62912d1cd3d6b1fdbfb45bb4b2d6209ce176f035ca9ec5ec6d4dea57d2d9d39d2eb2f8edac117e52a1e8f82b80735897e'
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
## Simple project for showcasing capabilities of Ruby's 'optparser' module
|
data/bin/dummy_parser
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# frozen_sting_literal: true
|
3
|
+
|
4
|
+
require 'dummy_parser'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = 'Dummy program showcasing optparse module'
|
11
|
+
opts.program_name = 'Dummy Parser'
|
12
|
+
opts.version = DummyParser::VERSION
|
13
|
+
opts.on('-v', '--version', 'Prints the current version of dummy parser') do
|
14
|
+
puts(opts.version)
|
15
|
+
end
|
16
|
+
opts.on('-h', '--help', 'Prints this help message') do
|
17
|
+
puts(opts)
|
18
|
+
end
|
19
|
+
# Text input
|
20
|
+
opts.on('-g [USER]', '--greet [USER]', 'Greets the user before exiting') do |user|
|
21
|
+
puts("Hello #{user || 'User'}!")
|
22
|
+
end
|
23
|
+
# Numeric input with = sign
|
24
|
+
opts.on('-n=[NUM]', '--number=[NUM]', 'Prints the happy number') do |happy|
|
25
|
+
puts("The happy number is #{happy}")
|
26
|
+
end
|
27
|
+
# Boolean input
|
28
|
+
opts.on('-s', '--[no-]smile', 'Determines the mood of the printed face') do |smile|
|
29
|
+
puts(": - #{ smile ? ')' : '(' }")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Mandatory Args:
|
33
|
+
opts.on('-l LIKE', '--like LIKE', TrueClass, 'Tell me if you enjoyed this article') do |like|
|
34
|
+
puts("#{like ? 'Thanks' : 'Apologies' }")
|
35
|
+
end
|
36
|
+
|
37
|
+
# Aborting :
|
38
|
+
opts.on('--abort', 'Stops the program') do
|
39
|
+
opts.abort('Aborting...')
|
40
|
+
end
|
41
|
+
|
42
|
+
# Empty param
|
43
|
+
opts.on('-b')
|
44
|
+
end.parse!(ARGV, into: options)
|
45
|
+
|
46
|
+
puts(options)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'lib/dummy_parser/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'dummy_parser'
|
5
|
+
spec.version = DummyParser::VERSION
|
6
|
+
spec.author = 'Jan Taras'
|
7
|
+
spec.email = 'jan.taras29@gmail.com'
|
8
|
+
spec.summary = 'Dummy project showcasing the optparse module'
|
9
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
10
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
11
|
+
end
|
12
|
+
spec.bindir = 'bin'
|
13
|
+
spec.executables = 'dummy_parser'
|
14
|
+
end
|
data/lib/dummy_parser.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'dummy_parser/version'
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dummy_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Taras
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: jan.taras29@gmail.com
|
15
|
+
executables:
|
16
|
+
- dummy_parser
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- README.md
|
23
|
+
- bin/dummy_parser
|
24
|
+
- dummy_parser.gemspec
|
25
|
+
- lib/dummy_parser.rb
|
26
|
+
- lib/dummy_parser/version.rb
|
27
|
+
homepage:
|
28
|
+
licenses: []
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubygems_version: 3.0.3
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Dummy project showcasing the optparse module
|
49
|
+
test_files: []
|