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 +4 -4
- data/lib/cli_yo.rb +1 -3
- data/lib/cli_yo/helper.rb +22 -20
- data/lib/cli_yo/yo_arguments.rb +26 -24
- data/lib/cli_yo/yo_error.rb +14 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f4a9bf6067848e26c850165049fc2922fc6d6e
|
4
|
+
data.tar.gz: 8f7aca875e58c2c77c2374d83e3d1cef8f32fc55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def self.beautiful_sentence arr
|
18
|
+
return nil if arr.size == 0
|
19
|
+
return arr[0] if arr.size == 1
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
data/lib/cli_yo/yo_arguments.rb
CHANGED
@@ -1,31 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Cli_Yo
|
2
|
+
class Yo_Arguments
|
3
|
+
def initialize arguments = Hash.new
|
4
|
+
@arguments = Hash.new
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
Cli_Yo.all_properties.each do |prop|
|
7
|
+
@arguments[prop] = arguments[prop]
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
@arguments[:times] ||= 1
|
11
|
+
@arguments[:api_token] ||= `echo $YO_TOKEN`.chomp
|
12
|
+
@arguments[:interval] ||= 1
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def method_missing method , *args
|
16
|
+
#check whether the property actuall exists
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
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
|
data/lib/cli_yo/yo_error.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Cli_Yo
|
2
|
+
class Yo_Error < Exception
|
3
|
+
attr_reader :error , :code
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def initialize error , code = nil
|
6
|
+
@error = error
|
7
|
+
@code = code
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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.
|
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: []
|