read_time 1.0.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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/read_time/version.rb +3 -0
- data/lib/read_time.rb +54 -0
- data/read_time.gemspec +32 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 69726aaf213f4ba9056242de62ea85ff1f8d5f9e
|
4
|
+
data.tar.gz: 6aec382f40168fb222deaa7db3e1478b5082f92f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72b4db0b3b7dd6207f1083f69c9f8f291c61825db6146305e2b085bfa68536ecf40e60cb44f76540dcd7b55feb02c0bfdc4ebfca132b1063abcb460f35e398e2
|
7
|
+
data.tar.gz: f15d938a4d16437e52e9dc0f011f4610ddd833c65ad7c59ea9b1bff0c71a8e1ff17f80a6c1bb8cb66a5ecac74e7bc148bb71ee66a6aaaec19aeb7488f6bd2fa4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Kaan Kölköy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# ReadTime
|
2
|
+
|
3
|
+
Find out read time of your content in hh:mm:ss format.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'read_time'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install read_time
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To use the gem, call `time_to_read` on string.
|
24
|
+
|
25
|
+
Example:
|
26
|
+
`some_string.time_to_read`
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kaanklky/read_time.
|
31
|
+
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "read_time"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/read_time.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require "read_time/version"
|
2
|
+
|
3
|
+
module ReadTime
|
4
|
+
module String
|
5
|
+
@@output = ""
|
6
|
+
|
7
|
+
def seconds_to_read
|
8
|
+
(self.split(" ").count/3.3333333333).to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def minutes_to_read(secs)
|
12
|
+
if secs / 60 > 1
|
13
|
+
@@output << "#{secs / 60} minutes "
|
14
|
+
else
|
15
|
+
@@output << "1 minute "
|
16
|
+
end
|
17
|
+
|
18
|
+
if secs % 60 > 0
|
19
|
+
@@output << "#{secs % 60} seconds"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def hours_to_read(secs)
|
24
|
+
if secs / 3600 > 1
|
25
|
+
@@output << "#{secs / 3600} hours "
|
26
|
+
else
|
27
|
+
@@output << "1 hour "
|
28
|
+
end
|
29
|
+
|
30
|
+
if secs % 3600 > 0
|
31
|
+
minutes_to_read(secs % 3600)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def time_to_read
|
36
|
+
if seconds_to_read <= 1
|
37
|
+
puts "1 second"
|
38
|
+
elsif seconds_to_read > 1 && seconds_to_read < 60
|
39
|
+
puts "#{seconds_to_read} seconds"
|
40
|
+
else
|
41
|
+
if secs > 3600
|
42
|
+
hours_to_read(seconds_to_read)
|
43
|
+
else
|
44
|
+
minutes_to_read(seconds_to_read)
|
45
|
+
end
|
46
|
+
puts @@output
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class String
|
53
|
+
include ReadTime::String
|
54
|
+
end
|
data/read_time.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'read_time/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "read_time"
|
8
|
+
spec.version = ReadTime::VERSION
|
9
|
+
spec.authors = ["Kaan Kölköy"]
|
10
|
+
spec.email = ["kaanklky@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Find out read time of your content in hh:mm:ss format.}
|
13
|
+
spec.homepage = "https://github.com/kaanklky/read_time"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org/'"
|
18
|
+
else
|
19
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
20
|
+
"public gem pushes."
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
f.match(%r{^(test|spec|features)/})
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: read_time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kaan Kölköy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-22 00:00:00.000000000 Z
|
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
|
+
description:
|
42
|
+
email:
|
43
|
+
- kaanklky@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- lib/read_time.rb
|
56
|
+
- lib/read_time/version.rb
|
57
|
+
- read_time.gemspec
|
58
|
+
homepage: https://github.com/kaanklky/read_time
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata:
|
62
|
+
allowed_push_host: https://rubygems.org/'
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.6.10
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Find out read time of your content in hh:mm:ss format.
|
83
|
+
test_files: []
|