timescopes 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/timescopes/scopes.rb +23 -7
- data/timescopes.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1643c8affd87519a7ee139fc8608870933363ff
|
4
|
+
data.tar.gz: b4fd4deed1b8aca04463d08ff0c236647fa9bffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15f522ce7a05aebe84deb952e3ac817b688d93467e51bc9228ab394549c2f35751f01cd07cd28d88998c5ec41951aefd67a018faaa99c794724ffccae9104dca
|
7
|
+
data.tar.gz: 849437851c86b03590db879153fef893c4dda9685d525521a49dc2d4337e96bf5a892746ce6dc1d6fc837db7a828bb42c976e2844556b18f29c8cdcf1373a1a3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/lib/timescopes/scopes.rb
CHANGED
@@ -2,6 +2,29 @@ require 'chronic'
|
|
2
2
|
|
3
3
|
module TimeScopes
|
4
4
|
class << self
|
5
|
+
def next_range(scope, start)
|
6
|
+
case scope.to_sym
|
7
|
+
when :minutely, :minute
|
8
|
+
1.hour.since(start).utc
|
9
|
+
when :hourly, :hour
|
10
|
+
1.day.since(start).utc
|
11
|
+
when :daily, :day
|
12
|
+
1.day.since(start).utc
|
13
|
+
when :weekly, :week
|
14
|
+
1.week.since(start).utc
|
15
|
+
when :monthly, :month
|
16
|
+
1.month.since(start).utc
|
17
|
+
when :yearly, :year
|
18
|
+
1.year.since(start).utc
|
19
|
+
when :rolling_7, :rolling_30
|
20
|
+
1.day.since(start).utc
|
21
|
+
when :overall, nil
|
22
|
+
nil
|
23
|
+
else
|
24
|
+
raise "Unknown scope passed to TimeScopes.next_range"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
5
28
|
def minutely(start=nil)
|
6
29
|
start ||= Time.now
|
7
30
|
[ Chronic.parse(start_of_minute(start.utc)),
|
@@ -39,13 +62,6 @@ module TimeScopes
|
|
39
62
|
end
|
40
63
|
alias_method :month, :monthly
|
41
64
|
|
42
|
-
def monthly(start=nil)
|
43
|
-
start ||= Time.now
|
44
|
-
[ Chronic.parse(start_of_month(start.utc)),
|
45
|
-
Chronic.parse(start_of_month(1.month.since(start.utc))) ]
|
46
|
-
end
|
47
|
-
alias_method :month, :monthly
|
48
|
-
|
49
65
|
def yearly(start=nil)
|
50
66
|
start ||= Time.now
|
51
67
|
[ Chronic.parse(start_of_year(start.utc)),
|
data/timescopes.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: timescopes 0.1.
|
5
|
+
# stub: timescopes 0.1.7 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "timescopes"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.7"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Ian Hunter"]
|
14
|
-
s.date = "2016-05-
|
14
|
+
s.date = "2016-05-19"
|
15
15
|
s.description = ""
|
16
16
|
s.email = "ianhunter@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timescopes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Hunter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|