acts_as_time_racing 0.1
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.
- data/.gitignore +2 -0
- data/README.markdown +5 -0
- data/acts_as_time_racing.gemspec +12 -0
- data/lib/acts_as_time_racing.rb +32 -0
- metadata +48 -0
data/.gitignore
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'acts_as_time_racing'
|
3
|
+
s.version = '0.1'
|
4
|
+
s.date = '2013-05-09'
|
5
|
+
s.summary = "Record one item's start and finish"
|
6
|
+
s.summary = s.description
|
7
|
+
s.authors = ["mvj3"]
|
8
|
+
s.email = 'mvjome@gmail.com'
|
9
|
+
s.homepage = 'https://github.com/eoecn/acts_as_time_racing'
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# TODO 支持自定义字段
|
4
|
+
|
5
|
+
require 'active_support/concern'
|
6
|
+
|
7
|
+
module ActsAsTimeRacing
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
# scope
|
12
|
+
# TODO 判断column存在
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
end
|
17
|
+
|
18
|
+
# 是否开始 和 结束
|
19
|
+
def started?; !!started_at end
|
20
|
+
def finished?; !!finished_at end
|
21
|
+
|
22
|
+
# 开始和结束
|
23
|
+
def start; self.update_attributes :started_at => DateTime.now; end
|
24
|
+
def finish; self.update_attributes :finished_at => DateTime.now; end
|
25
|
+
|
26
|
+
# 花费的时间
|
27
|
+
def time_passed
|
28
|
+
return 0 if not started?
|
29
|
+
((self.finished_at || Time.now) - self.started_at).to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_time_racing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- mvj3
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email: mvjome@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- README.markdown
|
22
|
+
- acts_as_time_racing.gemspec
|
23
|
+
- lib/acts_as_time_racing.rb
|
24
|
+
homepage: https://github.com/eoecn/acts_as_time_racing
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 1.8.25
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: ''
|
48
|
+
test_files: []
|