first_gem_hello_world 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6e33f5f8355b3d58e28b7f6990700a976fb3af9
4
- data.tar.gz: acf6f3e7698b19676398b3844eb47315d0d10703
3
+ metadata.gz: 26583164004b8bd3c112b5596d0be31c7c4d617f
4
+ data.tar.gz: 8811def0bf2aa0ce6da4074b79a807faac50c0ee
5
5
  SHA512:
6
- metadata.gz: 554b6ebf326cdd446759181cfed4a77f47ea2e096519a56564410ebab4284387485a327ab632bdc5b7149c019b82981b2370987bfeba875165396595e56affee
7
- data.tar.gz: 0d465de21b6a1401dc473cded48af5a9f0d3e02774dc0e30888390b946b3ec76510d09da12dc56b5b7e0c10fffb91829ef93cfbf0aeafbc3c642a60187ec45f8
6
+ metadata.gz: 13d910ec37d9f6d26390ad66f6e8b904151ae08646d19b97c32f5586b182b1aa54a268a66bf81bfd13d977bc90924fad89ff777fb55c1f8b38e66c739aad4efa
7
+ data.tar.gz: 8c55602787e5b1ceca2b90151f15c3427169295ecd379b23183569682a16f210e3d3d3c664c26cfb626557acee1f51878a1616c932389b3c469640560dbdd46b
@@ -1,18 +1,40 @@
1
1
  #!/usr/bin/env ruby
2
+ $LOAD_PATH << './lib'
3
+
2
4
  require 'optparse'
3
5
 
4
- require './lib/first_gem_hello_world'
6
+ require 'first_gem_hello_world'
7
+ require 'hello'
8
+
9
+ options = {}
10
+ OptionParser.new do |opt|
11
+ opt.banner = "Usage:\n first_gem_hello_world WORD [OPTIONS]"
12
+ opt.separator ''
13
+ opt.separator 'Options'
14
+
15
+ opt.on('--world', 'Print "Hello world!!!"') do
16
+ options[:world] = true
17
+ end
18
+
19
+ opt.on('-w', '--word', String, 'Word after "Hello"') do |word|
20
+ options[:word] = word
21
+ end
5
22
 
6
- OptionParser.new do |parser|
7
- parser.banner = <<BANNER
8
- FirstGemHelloWorld can say him self version)
23
+ opt.on_tail('-v', '--version', 'Show Version') do
24
+ puts FirstGemHelloWorld::VERSION
25
+ exit
26
+ end
9
27
 
10
- Usage:
11
- first_gem_hello_world
28
+ opt.on_tail('-h', '--help', 'Show this.') { puts opt; exit }
29
+
30
+ if ARGV.empty? && options.empty?
31
+ opt.on { puts opt; exit }
32
+ end
33
+ end.parse!
12
34
 
13
- Options:
14
- BANNER
15
- parser.on('-v', '--version', 'Show Version'){ puts FirstGemHelloWorld::VERSION; exit}
16
- parser.on('-h', '--help', 'Show this.') { puts parser; exit }
17
- parser.on { puts parser; exit }
18
- end.parse!
35
+ if options[:world]
36
+ puts Hello.world
37
+ else
38
+ word = options[:word] || ARGV[0]
39
+ puts Hello.world(word)
40
+ end
@@ -1,3 +1,3 @@
1
1
  module FirstGemHelloWorld
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -1,5 +1,5 @@
1
1
  class Hello
2
- def self.world
3
- self.name + 'world'
2
+ def self.world(word = 'world')
3
+ "#{self.name} #{word}!!!"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: first_gem_hello_world
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Petrov