sleep2 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -1
- data/lib/sleep2.rb +9 -8
- data/lib/sleep2/version.rb +1 -1
- data/sleep2.gemspec +0 -4
- metadata +3 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aa42b4d7a08e76a9286f915dad31be946ef8799
|
4
|
+
data.tar.gz: 902f693b95b9f75eaf95315fdbc2b218c6d3bd63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d083104f206bdacb79635f9905e9f22c93adc1172a28a1bd4e1615ade62df0c4e95828e37e65e570400299fc724a3b300c629eaae9b8470e707df3dee06bf0d
|
7
|
+
data.tar.gz: 0a8bb0d665df888535f652607c31cc56ac2958edf712c83c582c2384dd2eb64f4283814da4eaa0c926e617f82d5843564967a8a9557c0db8a43d406e0dc65ef9
|
data/Gemfile
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in sleep2.gemspec
|
4
|
-
gemspec
|
4
|
+
# gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem "bundler", "~> 1.14"
|
8
|
+
gem "rake", "~> 10.0"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
end
|
11
|
+
group :development, :test do
|
12
|
+
gem 'pry', '~> 0.10.4'
|
13
|
+
end
|
data/lib/sleep2.rb
CHANGED
@@ -10,13 +10,14 @@ class Sleep2
|
|
10
10
|
attr_accessor :duration, :sleep_proc
|
11
11
|
attr_writer :new
|
12
12
|
|
13
|
-
def initialize
|
14
|
-
if
|
15
|
-
|
16
|
-
elsif
|
17
|
-
|
13
|
+
def initialize time_interval
|
14
|
+
if time_interval.class.ancestors.include?(Numeric)
|
15
|
+
self.duration = time_interval.to_f
|
16
|
+
elsif time_interval.class == self.class
|
17
|
+
self.duration = time_interval.duration.to_f
|
18
18
|
else
|
19
|
-
|
19
|
+
msg = "can't convert #{time_interval.class} into time interval"
|
20
|
+
raise TypeError, msg
|
20
21
|
end
|
21
22
|
@new = true
|
22
23
|
end
|
@@ -30,7 +31,7 @@ class Sleep2
|
|
30
31
|
unless new?
|
31
32
|
self.sleep_proc.call
|
32
33
|
else
|
33
|
-
self.new
|
34
|
+
self.new = false
|
34
35
|
self.sleep_proc = proc { sleep duration }
|
35
36
|
end
|
36
37
|
end
|
@@ -40,7 +41,7 @@ class Sleep2
|
|
40
41
|
end
|
41
42
|
|
42
43
|
# Creates new sleep instance by calculating it with integer
|
43
|
-
[
|
44
|
+
%i[* / + - % **].each do |m|
|
44
45
|
define_method m do |num|
|
45
46
|
num = num.duration if num.kind_of? self.class
|
46
47
|
self.class[ duration.public_send(m, num) ]
|
data/lib/sleep2/version.rb
CHANGED
data/sleep2.gemspec
CHANGED
@@ -20,8 +20,4 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.bindir = "exe"
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.14"
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
27
23
|
end
|
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sleep2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Setyadi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.14'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.14'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description: ''
|
56
14
|
email:
|
57
15
|
- a.styd@yahoo.com
|