tkh_toolbox 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45197252bffe84fe952e96e5eba475598fc603d4
4
- data.tar.gz: 7dad90b356a542ca9b50348152f26e45cfc596a5
3
+ metadata.gz: 4cc86fa5ead5428a4cd0446ed8c1e9f545697fce
4
+ data.tar.gz: b34073bb201d63814bcb70545022f264d28e1b6e
5
5
  SHA512:
6
- metadata.gz: b083d95d09906e737f4e2fd928acad7c72ef891b7b08bd5c841d5b9f492acd71f97bf1f6a955b6c5ae3989e1112fc0ccc41e8dd2ee185240314e4cbbfb8e4b1e
7
- data.tar.gz: 6eeb756dbb15f3fd6e67c6a1a300b8a133feb4f6f2eb0255e700bfd2e6f90969c5d7ebc7fc5bb8125c467dbb59ad1c030bd766bd0bb15267f9ffd093a2022860
6
+ metadata.gz: ad27088367d6a1b92b68fa4e8f8523aa7f6ff52646031567763ea92cc6efc660d114806575ac700be47f61583431137bf1fd7ea9213de4658a4f08857cfb6fd3
7
+ data.tar.gz: 9f921fd9042d358adf1bdf019c03ce972e4b7f80bb26762cfd7ec1af792be15fe947c476dfabe7226709bab1b4211f752165953ae4d91aba0226ffd35e0c4c4c
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # TKH Toolbox
2
2
 
3
3
 
4
+
5
+ ## 0.9.3
6
+
7
+ * Added the human_date_and_time application helper extension.
8
+
9
+
4
10
  ## 0.9.2
5
11
 
6
12
  * Debugged flash message bit
data/README.md CHANGED
@@ -27,6 +27,16 @@ There are general purpose locale files. Look for them in the config/locales fold
27
27
 
28
28
  A flash view partial can be called at app/views/shared/_flash_messages.html.erb
29
29
 
30
+ A human_date_and_time(datetime_object) application extension gives the following date outputs depending when they happened in relation to today. Examples:
31
+
32
+ when less than 15 seconds then "just now"
33
+ when less than 5 minutes then "a few minutes ago"
34
+ when today then "at 02:18 pm"
35
+ when yesterday then "yesterday at 02:03 pm"
36
+ when this week then "Wednesday at 11:48 am"
37
+ when this year then "Jul. 23 at 02:12 pm"
38
+ when last year and earlier then "Aug. 23, 2013"
39
+
30
40
 
31
41
  ## Contributing
32
42
 
@@ -0,0 +1,27 @@
1
+ module TkhToolboxHelper
2
+ def self.included(base)
3
+ base.send(:include, InstanceMethods)
4
+ end
5
+
6
+ module InstanceMethods
7
+ def human_date_and_time(dt)
8
+ now = Time.zone.now
9
+
10
+ if now.to_i - dt.to_i <= 15 # less than 15 seconds ago
11
+ 'just now'
12
+ elsif now.to_i - dt.to_i < ( 60 * 5 ) # less than 5 minutes ago
13
+ 'a few minutes ago'
14
+ elsif dt > Time.zone.now.beginning_of_day # today
15
+ "at #{ dt.strftime('%I:%M %P')}"
16
+ elsif dt > Time.zone.now.beginning_of_day - 24.hours # yesterday
17
+ "yesterday at #{ dt.strftime('%I:%M %P')}"
18
+ elsif dt > Time.zone.now.beginning_of_week # before yesterday and since Monday morning
19
+ dt.strftime('%A at %I:%M %P')
20
+ elsif dt > Time.zone.now.beginning_of_year # between Jan. 1st this year and Sunday at midnight
21
+ dt.strftime("%b. %e at %I:%M %P")
22
+ else # before beginning of this year
23
+ dt.strftime("%b. %e, %Y")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module TkhToolbox
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
data/lib/tkh_toolbox.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  require "tkh_toolbox/version"
2
+ require 'tkh_toolbox/tkh_toolbox_helper'
2
3
 
3
4
  module TkhToolbox
4
5
  class Engine < ::Rails::Engine
6
+ # to extend the application helper in the host app
7
+ initializer 'tkh_toolbox.helper' do |app|
8
+ ActionView::Base.send :include, TkhToolboxHelper
9
+ end
5
10
  end
6
11
  end
data/tkh_toolbox.gemspec CHANGED
@@ -16,4 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "bundler", "~> 1.7"
21
+ gem.add_development_dependency "rake"
19
22
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swami Atma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2014-08-23 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: Assortment of all-purpose utilities used by gems across the tkh_cms suite
14
42
  email:
15
43
  - swami@TenThousandHours.eu
@@ -32,6 +60,7 @@ files:
32
60
  - lib/generators/tkh_toolbox/create_or_update_locales/templates/it.yml
33
61
  - lib/tasks/tkh_toolbox_tasks.rake
34
62
  - lib/tkh_toolbox.rb
63
+ - lib/tkh_toolbox/tkh_toolbox_helper.rb
35
64
  - lib/tkh_toolbox/version.rb
36
65
  - tkh_toolbox.gemspec
37
66
  homepage: ''
@@ -53,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
82
  version: '0'
54
83
  requirements: []
55
84
  rubyforge_project:
56
- rubygems_version: 2.2.0
85
+ rubygems_version: 2.2.2
57
86
  signing_key:
58
87
  specification_version: 4
59
88
  summary: Assortment of all-purpose utilities used by gems across the tkh_cms suite