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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31e947542b83ee7bc53b16e264cacace80fb92c4c2c481215cce0962fcc681e7
4
- data.tar.gz: 32672b1a8dba6d1a87f0be517d50475370085218d59ddc0b5f8aaee0c0ba97c6
3
+ metadata.gz: 0f6103e2634ee6f2cdb4945459728fa6a0c440608c73759c40e5cba20985d365
4
+ data.tar.gz: 4b0a2c1b7da8b301623d1955bfcaaaf2e6e5be3804dc5691413683d393adbb57
5
5
  SHA512:
6
- metadata.gz: d010a8bdfe495a14665a006f14540c405732bdc7ceadb662874c5ce6085ada5a97447f4ffe973564d46a6cf6091af4885d99cc1d446b89a445e6d38914e99fc2
7
- data.tar.gz: adbae4f2a41150d999a18ac3f1b98efd410061949ed152817fa751954e58fb56dd821e89058ed892e12a67f2886af1b35280ddbb58554c6fce9bf89f72491bd1
6
+ metadata.gz: d900b59a0372b1dad440b3d720f9a03933e0c3c61124a2a2799497239b101e58daae1165cf9e1ed8f1455e409672109bf8cba2fd93b4c6fcaefdb2261f52a5a2
7
+ data.tar.gz: 252df81bd74bbdc46e3a4fdd7d2a30e33ca4fbfbc79275d5f43269ebd4797f23eaafcbeeb739f2df787bc0b75a4c7c70302b6cf1e94b26200c758544a18a40b9
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
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
@@ -1,4 +1,7 @@
1
1
  require "service/utils/version"
2
+ require_relative "utils/wrappers/object"
3
+ require_relative "utils/wrappers/nil"
4
+ require_relative "utils/wrappers/string"
2
5
 
3
6
  module Service
4
7
  module Utils
@@ -1,5 +1,5 @@
1
1
  module Service
2
2
  module Utils
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,17 @@
1
+ class NilClass
2
+ def blank?
3
+ return true
4
+ end
5
+
6
+ def present?
7
+ return false
8
+ end
9
+
10
+ def is_true?
11
+ return false
12
+ end
13
+
14
+ def is_false?
15
+ return false
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ class Object
2
+ def is_true?
3
+ return false
4
+ end
5
+
6
+ def is_false?
7
+ return false
8
+ end
9
+ end
@@ -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
@@ -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/support-service"
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.1.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: 2020-09-18 00:00:00.000000000 Z
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/support-service
79
+ homepage: https://gitlab.opinioni.net/farhan.gazi/service-utils
76
80
  licenses:
77
81
  - MIT
78
82
  metadata: {}