over_the_midnight 0.1.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 +94 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/over_the_midnight.rb +15 -0
- data/lib/over_the_midnight/time.rb +45 -0
- data/lib/over_the_midnight/version.rb +3 -0
- data/over_the_midnight.gemspec +24 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ed6b5fa818bdb8effe154d73e21ef88a433f3ad1
|
4
|
+
data.tar.gz: ad59b935768f11444d9b2d13289c57ba5c2b25e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2a27deda39995e0d24824eac83cfb1197b56aa7c115760173ebca7f7d968da6bd713dc29d8957f63430d37f1dc08be66c645c7b9cf842ee9be4d1057a50cc9a
|
7
|
+
data.tar.gz: 804a6cf89eaf5a0ae3de2f63907176c233182fe786eb177e00cb887f73b3532a8add0a2505cb2a95923dc5083c2605d96534b105aa10359ffea7376c50f4faed
|
data/.gitignore
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Created by https://www.gitignore.io/api/ruby,linux,osx
|
2
|
+
|
3
|
+
### Ruby ###
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
/.config
|
7
|
+
/coverage/
|
8
|
+
/InstalledFiles
|
9
|
+
/pkg/
|
10
|
+
/spec/reports/
|
11
|
+
/spec/examples.txt
|
12
|
+
/test/tmp/
|
13
|
+
/test/version_tmp/
|
14
|
+
/tmp/
|
15
|
+
|
16
|
+
# Used by dotenv library to load environment variables.
|
17
|
+
# .env
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
Gemfile.lock
|
49
|
+
.ruby-version
|
50
|
+
.ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
|
56
|
+
### Linux ###
|
57
|
+
*~
|
58
|
+
|
59
|
+
# temporary files which can be created if a process still has a handle open of a deleted file
|
60
|
+
.fuse_hidden*
|
61
|
+
|
62
|
+
# KDE directory preferences
|
63
|
+
.directory
|
64
|
+
|
65
|
+
# Linux trash folder which might appear on any partition or disk
|
66
|
+
.Trash-*
|
67
|
+
|
68
|
+
|
69
|
+
### OSX ###
|
70
|
+
*.DS_Store
|
71
|
+
.AppleDouble
|
72
|
+
.LSOverride
|
73
|
+
|
74
|
+
# Icon must end with two \r
|
75
|
+
Icon
|
76
|
+
|
77
|
+
# Thumbnails
|
78
|
+
._*
|
79
|
+
|
80
|
+
# Files that might appear in the root of a volume
|
81
|
+
.DocumentRevisions-V100
|
82
|
+
.fseventsd
|
83
|
+
.Spotlight-V100
|
84
|
+
.TemporaryItems
|
85
|
+
.Trashes
|
86
|
+
.VolumeIcon.icns
|
87
|
+
.com.apple.timemachine.donotpresent
|
88
|
+
|
89
|
+
# Directories potentially created on remote AFP share
|
90
|
+
.AppleDB
|
91
|
+
.AppleDesktop
|
92
|
+
Network Trash Folder
|
93
|
+
Temporary Items
|
94
|
+
.apdisk
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# OverTheMidnight
|
2
|
+
|
3
|
+
Implements the time expression which strided date.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'over_the_midnight'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install over_the_midnight
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
date = Date.new(2016, 8, 13)
|
25
|
+
|
26
|
+
# version 0.1.x
|
27
|
+
require "over_the_midnight"
|
28
|
+
otm = OverTheMidnight.new(date, "25:00")
|
29
|
+
otm.to_time.strftime("%Y/%m/%d %H:%M")
|
30
|
+
#=> "2016/08/14 01:00"
|
31
|
+
|
32
|
+
otm = OverTheMidnight.new(date, 30.5)
|
33
|
+
otm.to_time.strftime("%Y/%m/%d %H:%M")
|
34
|
+
#=> "2016/08/14 06:30"
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sekizo/over_the_midnight.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "over_the_midnight"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "over_the_midnight/version"
|
2
|
+
|
3
|
+
module OverTheMidnight
|
4
|
+
LIB = File.expand_path(File.dirname(__FILE__))
|
5
|
+
ROOT = File.dirname(OverTheMidnight::LIB)
|
6
|
+
|
7
|
+
def self.new(*args)
|
8
|
+
self::Time.new(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
$:<< OverTheMidnight::LIB
|
13
|
+
Dir.glob(File.join(OverTheMidnight::LIB, "**/*.rb")).each do |entory|
|
14
|
+
require entory
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "date"
|
2
|
+
|
3
|
+
class OverTheMidnight::Time
|
4
|
+
attr_reader :date
|
5
|
+
|
6
|
+
def initialize(date, time)
|
7
|
+
super()
|
8
|
+
@date = date
|
9
|
+
@raw_time = time
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_time
|
13
|
+
parse
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def parse
|
19
|
+
case @raw_time
|
20
|
+
when String
|
21
|
+
parse_string
|
22
|
+
when Numeric
|
23
|
+
parse_numeric
|
24
|
+
else
|
25
|
+
raise "invalid time"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse_string
|
30
|
+
min = @raw_time.scan(/\:([0-9]+)\s*\z/).flatten.first.to_i
|
31
|
+
|
32
|
+
h = @raw_time.scan(/\A\s*([0-9]+)/).flatten.first.to_i
|
33
|
+
_date = @date + (h / 24)
|
34
|
+
hour = h % 24
|
35
|
+
|
36
|
+
Time.new(_date.year, _date.month, _date.day, hour, min)
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_numeric
|
40
|
+
hour = (@raw_time % 24)
|
41
|
+
min = ((@raw_time % 1.0) * 60)
|
42
|
+
_date = @date + (@raw_time / 24)
|
43
|
+
Time.new(_date.year, _date.month, _date.day, hour, min)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'over_the_midnight/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "over_the_midnight"
|
8
|
+
spec.version = OverTheMidnight::VERSION
|
9
|
+
spec.authors = ["sekizo"]
|
10
|
+
spec.email = ["sekizoworld@mac.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Implements the time expression which strided date.}
|
13
|
+
spec.description = %q{Implements the time expression which strided date.}
|
14
|
+
spec.homepage = "https://github.com/sekizo/over_the_midnight"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: over_the_midnight
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sekizo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-14 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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'
|
55
|
+
description: Implements the time expression which strided date.
|
56
|
+
email:
|
57
|
+
- sekizoworld@mac.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/over_the_midnight.rb
|
71
|
+
- lib/over_the_midnight/time.rb
|
72
|
+
- lib/over_the_midnight/version.rb
|
73
|
+
- over_the_midnight.gemspec
|
74
|
+
homepage: https://github.com/sekizo/over_the_midnight
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.8
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Implements the time expression which strided date.
|
97
|
+
test_files: []
|