service-utils 0.1.0 → 0.2.0
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +35 -0
- data/lib/service/utils.rb +3 -0
- data/lib/service/utils/version.rb +1 -1
- data/lib/service/utils/wrappers/nil.rb +17 -0
- data/lib/service/utils/wrappers/object.rb +9 -0
- data/lib/service/utils/wrappers/string.rb +36 -0
- data/service-utils.gemspec +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f6103e2634ee6f2cdb4945459728fa6a0c440608c73759c40e5cba20985d365
|
4
|
+
data.tar.gz: 4b0a2c1b7da8b301623d1955bfcaaaf2e6e5be3804dc5691413683d393adbb57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d900b59a0372b1dad440b3d720f9a03933e0c3c61124a2a2799497239b101e58daae1165cf9e1ed8f1455e409672109bf8cba2fd93b4c6fcaefdb2261f52a5a2
|
7
|
+
data.tar.gz: 252df81bd74bbdc46e3a4fdd7d2a30e33ca4fbfbc79275d5f43269ebd4797f23eaafcbeeb739f2df787bc0b75a4c7c70302b6cf1e94b26200c758544a18a40b9
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
service-utils (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.4.4)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.2)
|
16
|
+
rspec-support (~> 3.9.3)
|
17
|
+
rspec-expectations (3.9.2)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.1)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.3)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.17)
|
30
|
+
rake (~> 10.0)
|
31
|
+
rspec (~> 3.0)
|
32
|
+
service-utils!
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.17.3
|
data/lib/service/utils.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
class String
|
2
|
+
# Converts a timestring to seconds with milliseconds part support
|
3
|
+
def as_seconds
|
4
|
+
# Check if input string has a valid format
|
5
|
+
raise "Invalid timestring format: #{self}" if not self.match(/^\d{1,}:[0-5]?[0-9](:[0-5]?[0-9](\.\d+)?)?$/)
|
6
|
+
|
7
|
+
# Split input string by ":" char and convert each part to float
|
8
|
+
hours, minutes, seconds = self.split(":").map(&:to_f)
|
9
|
+
|
10
|
+
# Seconds part could be missing, so set it to 0 by default
|
11
|
+
seconds ||= 0
|
12
|
+
|
13
|
+
return hours * 3600 + minutes * 60 + seconds
|
14
|
+
end
|
15
|
+
|
16
|
+
# Converts a timestring to hours
|
17
|
+
def as_hours
|
18
|
+
return self.as_seconds.to_f / 3600
|
19
|
+
end
|
20
|
+
|
21
|
+
def blank?
|
22
|
+
return self.strip == ""
|
23
|
+
end
|
24
|
+
|
25
|
+
def present?
|
26
|
+
return (not self.blank?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def is_true?
|
30
|
+
return ["y", "yes", "t", "true"].include?(self.strip.downcase)
|
31
|
+
end
|
32
|
+
|
33
|
+
def is_false?
|
34
|
+
return ["n", "no", "f", "false"].include?(self.strip.downcase)
|
35
|
+
end
|
36
|
+
end
|
data/service-utils.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{A Ruby gem with frequently used utilities.}
|
13
13
|
spec.description = %q{A Ruby gem written to semplify the use of frequently used utilities.}
|
14
|
-
spec.homepage = "https://gitlab.opinioni.net/farhan.gazi/
|
14
|
+
spec.homepage = "https://gitlab.opinioni.net/farhan.gazi/service-utils"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Farhan Gazi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- ".travis.yml"
|
65
65
|
- CODE_OF_CONDUCT.md
|
66
66
|
- Gemfile
|
67
|
+
- Gemfile.lock
|
67
68
|
- LICENSE.txt
|
68
69
|
- README.md
|
69
70
|
- Rakefile
|
@@ -71,8 +72,11 @@ files:
|
|
71
72
|
- bin/setup
|
72
73
|
- lib/service/utils.rb
|
73
74
|
- lib/service/utils/version.rb
|
75
|
+
- lib/service/utils/wrappers/nil.rb
|
76
|
+
- lib/service/utils/wrappers/object.rb
|
77
|
+
- lib/service/utils/wrappers/string.rb
|
74
78
|
- service-utils.gemspec
|
75
|
-
homepage: https://gitlab.opinioni.net/farhan.gazi/
|
79
|
+
homepage: https://gitlab.opinioni.net/farhan.gazi/service-utils
|
76
80
|
licenses:
|
77
81
|
- MIT
|
78
82
|
metadata: {}
|