datetime_tag_helper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +0 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +47 -0
- data/Rakefile +3 -0
- data/datetime_tag_helper.gemspec +23 -0
- data/lib/action_view/helpers/datetime_tag_helper.rb +13 -0
- data/lib/datetime_tag_helper/version.rb +3 -0
- data/lib/datetime_tag_helper.rb +4 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8506ff7520f799203ce179ea0721b5b10d4db45e
|
4
|
+
data.tar.gz: c98defdc4b8eca59fbe1cf6bd5a42abe9beda46e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4dafe2de49d0f28561730070978a84a0055030920073b7597836764425b196c62f6a5770dfb4c86d706e4ec9ee7f7bbdcec560803990bca464f96a47ce99a0fb
|
7
|
+
data.tar.gz: 42b216fc8f5f1b7e69649359c50fb69ffdcb76829e6a3f7e9f81225f330fd93554fd45c5941be5e7902c423f0d2dd2831c349db5bb51d3e816f93f114a051626
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Jianqiu Xiao <swordray@gmail.com>
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# datetime_tag_helper
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/datetime_tag_helper.png)](http://badge.fury.io/rb/datetime_tag_helper) [![Build Status](https://secure.travis-ci.org/swordray/datetime_tag_helper.png?branch=master)](http://travis-ci.org/swordray/datetime_tag_helper) [![Dependency Status](https://gemnasium.com/swordray/datetime_tag_helper.png?travis)](https://gemnasium.com/swordray/datetime_tag_helper) [![Code Climate](https://codeclimate.com/github/swordray/datetime_tag_helper.png)](https://codeclimate.com/github/swordray/datetime_tag_helper)
|
4
|
+
|
5
|
+
ActionView Datetime Tag Helper
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby ~> 2.0
|
10
|
+
* Rails
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Include the gem in your Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'datetime_tag_helper'
|
18
|
+
```
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
datetime_tag(time)
|
24
|
+
```
|
25
|
+
|
26
|
+
## Examples
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
= datetime_tag Time.now
|
30
|
+
# => <span title="2014-03-18 19:24:24" class="datetime datetime_ago">less than a minute</span>
|
31
|
+
```
|
32
|
+
```ruby
|
33
|
+
= datetime_tag 5.hours.ago
|
34
|
+
# => <span title="2014-03-18 06:24:24" class="datetime datetime_ago">about 5 hours</span>
|
35
|
+
```
|
36
|
+
```ruby
|
37
|
+
= datetime_tag 3.days.from_now
|
38
|
+
# => <span title="2014-03-21 11:24:24" class="datetime datetime_from_now">3 days</span>
|
39
|
+
```
|
40
|
+
|
41
|
+
## Credits
|
42
|
+
|
43
|
+
* swordray @[ihaveu](http://www.ihaveu.com/home) @[shuhai](http://tw.shuhai.org/) @[leaf](http://leaf.iacger.com)
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
Copyright © 2014 Jianqiu Xiao <swordray@gmail.com> under The [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'datetime_tag_helper/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "datetime_tag_helper"
|
6
|
+
s.version = DatetimeTagHelper::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.author = ["Jianqiu Xiao"]
|
9
|
+
s.email = ["swordray@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/swordray/datetime_tag_helper"
|
11
|
+
s.summary = "ActionView Datetime Tag Helper"
|
12
|
+
s.description = "ActionView Datetime Tag Helper."
|
13
|
+
s.license = "MIT"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.required_ruby_version = "~> 2.0"
|
21
|
+
|
22
|
+
s.add_dependency 'rails'
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'action_view/helpers'
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
module Helpers
|
5
|
+
# = Action View I18n Datetime Span Tag Helper
|
6
|
+
module DatetimeTagHelper
|
7
|
+
# Creates a span tag of the given +time+ with I18n time_ago_in_words format.
|
8
|
+
def datetime_tag(time)
|
9
|
+
content_tag(:span, time_ago_in_words(time), title: time.to_s(:db), class: (time.to_time > Time.now ? 'datetime datetime_from_now' : 'datetime datetime_ago')) if time.respond_to?(:to_time)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: datetime_tag_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jianqiu Xiao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: ActionView Datetime Tag Helper.
|
28
|
+
email:
|
29
|
+
- swordray@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".travis.yml"
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- datetime_tag_helper.gemspec
|
41
|
+
- lib/action_view/helpers/datetime_tag_helper.rb
|
42
|
+
- lib/datetime_tag_helper.rb
|
43
|
+
- lib/datetime_tag_helper/version.rb
|
44
|
+
homepage: https://github.com/swordray/datetime_tag_helper
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2.0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.2.2
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: ActionView Datetime Tag Helper
|
68
|
+
test_files: []
|