cli_yo 0.0.1 → 0.0.3

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: 1c3cb81486d2e06715a3de7678b6dbbcdce1ea29
4
- data.tar.gz: a183a16fec3d63b6dda3f6d4e48730109285ea6f
3
+ metadata.gz: 30f4a9bf6067848e26c850165049fc2922fc6d6e
4
+ data.tar.gz: 8f7aca875e58c2c77c2374d83e3d1cef8f32fc55
5
5
  SHA512:
6
- metadata.gz: d2c5ea920cb0b919e134d33bb77bda6657bf51d55c36b5f3c16b40af6bf2255bd2940a2927ed3a2e1a9a717ebc3a6119906c5e22092205641d26f4a84686004b
7
- data.tar.gz: 95e3aaa2bb274bb7154c90138008f37457506b9c0673f2862fdc76fa6e2aa33527eab2e93fca42c424996b3be75587c8cbed032adc650e0c6bc291e19426b679
6
+ metadata.gz: 8c3a3619f6e608432d16a09600e2983b528a113b081b3edd61ae295cd4b04a08dd3eec6bdf6ec841a381b4f6b2f7fb01d7996cd2f30f3e4ab3514972d383d3a5
7
+ data.tar.gz: dd0f0ada2ea2ffc74acb06f21920d2d249f6082541e21e603a0271a05b33db16de249228de5f5fec9a4dbcdd7a418cad1514b5f33ddd6dd8a7c55f57548fa7a8
data/lib/cli_yo.rb CHANGED
@@ -19,7 +19,6 @@ module Cli_Yo
19
19
 
20
20
  raise Yo_Error.new "invalid arguments class provided!" unless arguments.class == Hash || arguments.class == Yo_Arguments
21
21
  arguments = Yo_Arguments.new arguments if arguments.class == Hash
22
- p arguments
23
22
  begin
24
23
 
25
24
  raise Yo_Error.new "Noone to yo!" if arguments.usernames.size == 0
@@ -27,8 +26,7 @@ module Cli_Yo
27
26
  raise Yo_Error.new "Missing mandatory argument #{prop}" unless arguments.property_is_set? (prop)
28
27
  end
29
28
 
30
- puts "Going to start yo-ing #{Helper::beautiful_sentence(arguments.usernames)}"
31
- puts "Pid of current Process is #{Process.pid} "
29
+ puts "Going to start yo-ing #{Helper.beautiful_sentence(arguments.usernames)}"
32
30
 
33
31
  Process.daemon(true) if arguments.silent
34
32
  counter = arguments.times
data/lib/cli_yo/helper.rb CHANGED
@@ -1,27 +1,29 @@
1
- module Helper
2
- def self.consecutive_counter n
3
- suffix = "th"
4
- unless (n >= 10 && n <= 20) || n.to_s[-2] == '1'
5
- if n.to_s[-1] == '1'
6
- suffix = "st"
7
- elsif n.to_s[-1] == '2'
8
- suffix = "nd"
9
- elsif n.to_s[-1] == '3'
10
- suffix = 'rd'
1
+ module Cli_Yo
2
+ module Helper
3
+ def self.consecutive_counter n
4
+ suffix = "th"
5
+ unless (n >= 10 && n <= 20) || n.to_s[-2] == '1'
6
+ if n.to_s[-1] == '1'
7
+ suffix = "st"
8
+ elsif n.to_s[-1] == '2'
9
+ suffix = "nd"
10
+ elsif n.to_s[-1] == '3'
11
+ suffix = 'rd'
12
+ end
11
13
  end
14
+ "#{n}-#{suffix}"
12
15
  end
13
- "#{n}-#{suffix}"
14
- end
15
16
 
16
- def self.beautiful_sentence arr
17
- return nil if arr.size == 0
18
- return arr[0] if arr.size == 1
17
+ def self.beautiful_sentence arr
18
+ return nil if arr.size == 0
19
+ return arr[0] if arr.size == 1
19
20
 
20
- str = ""
21
- for i in 0...(arr.size - 1) do
22
- str += ", " unless i == 0
23
- str += "#{arr[i]}"
21
+ str = ""
22
+ for i in 0...(arr.size - 1) do
23
+ str += ", " unless i == 0
24
+ str += "#{arr[i]}"
25
+ end
26
+ str = "#{str} and #{arr.last}"
24
27
  end
25
- str = "#{str} and #{arr.last}"
26
28
  end
27
29
  end
@@ -1,31 +1,33 @@
1
- class Yo_Arguments
2
- def initialize arguments = Hash.new
3
- @arguments = Hash.new
1
+ module Cli_Yo
2
+ class Yo_Arguments
3
+ def initialize arguments = Hash.new
4
+ @arguments = Hash.new
4
5
 
5
- Cli_Yo.all_properties.each do |prop|
6
- @arguments[prop] = arguments[prop]
7
- end
6
+ Cli_Yo.all_properties.each do |prop|
7
+ @arguments[prop] = arguments[prop]
8
+ end
8
9
 
9
- @arguments[:times] ||= 1
10
- @arguments[:api_token] ||= `echo $YO_TOKEN`.chomp
11
- @arguments[:interval] ||= 1
12
- end
10
+ @arguments[:times] ||= 1
11
+ @arguments[:api_token] ||= `echo $YO_TOKEN`.chomp
12
+ @arguments[:interval] ||= 1
13
+ end
13
14
 
14
- def method_missing method , *args
15
- #check whether the property actuall exists
15
+ def method_missing method , *args
16
+ #check whether the property actuall exists
16
17
 
17
- is_setter = (method.to_s[-1] == '=')
18
- reference_symbol = method.to_s[-1] == '=' ? method.to_s.chop.to_sym : method
19
- super unless Cli_Yo.all_properties.include? reference_symbol
20
- if is_setter
21
- @arguments[reference_symbol] = args[0]
22
- else
23
- @arguments[reference_symbol]
18
+ is_setter = (method.to_s[-1] == '=')
19
+ reference_symbol = method.to_s[-1] == '=' ? method.to_s.chop.to_sym : method
20
+ super unless Cli_Yo.all_properties.include? reference_symbol
21
+ if is_setter
22
+ @arguments[reference_symbol] = args[0]
23
+ else
24
+ @arguments[reference_symbol]
25
+ end
24
26
  end
25
- end
26
27
 
27
- def property_is_set? property
28
- property = property.to_sym if property.class == String
29
- @arguments[property] != nil
28
+ def property_is_set? property
29
+ property = property.to_sym if property.class == String
30
+ @arguments[property] != nil
31
+ end
30
32
  end
31
- end
33
+ end
@@ -1,16 +1,18 @@
1
- class Yo_Error < Exception
2
- attr_reader :error , :code
1
+ module Cli_Yo
2
+ class Yo_Error < Exception
3
+ attr_reader :error , :code
3
4
 
4
- def initialize error , code = nil
5
- @error = error
6
- @code = code
7
- end
5
+ def initialize error , code = nil
6
+ @error = error
7
+ @code = code
8
+ end
8
9
 
9
- def to_s
10
- if @code
11
- "Error code #{@code} => #{@error}"
12
- else
13
- @error
10
+ def to_s
11
+ if @code
12
+ "Error code #{@code} => #{@error}"
13
+ else
14
+ @error
15
+ end
14
16
  end
15
17
  end
16
- end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli_yo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FY Quah
@@ -66,7 +66,8 @@ files:
66
66
  - lib/cli_yo/yo_arguments.rb
67
67
  - lib/cli_yo/yo_error.rb
68
68
  homepage: https://github.com/fyquah95/cli-yo/
69
- licenses: []
69
+ licenses:
70
+ - MIT
70
71
  metadata: {}
71
72
  post_install_message:
72
73
  rdoc_options: []