time_will_tell 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 +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +4 -0
- data/lib/generators/USAGE +3 -0
- data/lib/generators/install_generator.rb +12 -0
- data/lib/generators/time_will_tell/templates/config/locales/time_will_tell.en.yml +23 -0
- data/lib/time_will_tell/helpers/date_helper.rb +71 -0
- data/lib/time_will_tell/helpers/date_range_helper.rb +47 -0
- data/lib/time_will_tell/railtie.rb +10 -0
- data/lib/time_will_tell/version.rb +3 -0
- data/lib/time_will_tell.rb +2 -0
- data/spec/fixtures/locales/time_will_tell.fr.yml +53 -0
- data/spec/helpers/date_helper_spec.rb +76 -0
- data/spec/helpers/date_range_helper_spec.rb +88 -0
- data/spec/spec_helper.rb +13 -0
- data/time_will_tell.gemspec +26 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7d045ed7cc8e6baa8ef712946a170497f1d1ade3
|
4
|
+
data.tar.gz: 72c9d0576641152da145b5b6297c8d6d04cea39a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 860917b1eea35691792b65bf095e24bcdb24767712a4ccbca01f4f05d9466b67b03246bdc9195debcb0b4af799a82a70b52f42079afea36c3d33cf3117f0d90f
|
7
|
+
data.tar.gz: d7744d0cba56ef69ed4c189fc660d64349be7ec67fcf7a39e309e7d5f6170ee156afe041117a3a2bb7bad0e14be82399595b7cefef9528dd111b385790b93da9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Michel Billard
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# TimeWillTell
|
2
|
+
|
3
|
+
Specialized conversions of dates and times to strings.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'time_will_tell'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install time_will_tell
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/time_will_tell/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module TimeWillTell
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc "Copy TimeWillTell default files"
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
6
|
+
|
7
|
+
def copy_locales
|
8
|
+
directory "config/locales"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
en:
|
2
|
+
time_will_tell:
|
3
|
+
date_range:
|
4
|
+
different_months_same_year: "%{from_month} %{from_day} %{sep} %{to_month} %{to_day}, %{year}"
|
5
|
+
different_years: "%{from_month} %{from_day}, %{from_year} %{sep} %{to_month} %{to_day}, %{to_year}"
|
6
|
+
same_month: "%{month} %{from_day} %{sep} %{to_day}, %{year}"
|
7
|
+
same_date: "%{month} %{from_day}, %{year}"
|
8
|
+
|
9
|
+
distance_in_words:
|
10
|
+
template: "%{count} %{unit}"
|
11
|
+
template_long: "%{rest} and %{last}"
|
12
|
+
|
13
|
+
units:
|
14
|
+
second: second
|
15
|
+
minute: minute
|
16
|
+
hour: hour
|
17
|
+
day: day
|
18
|
+
month: month
|
19
|
+
year: year
|
20
|
+
|
21
|
+
special:
|
22
|
+
half_an_hour: half an hour
|
23
|
+
and_a_half: and a half
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module TimeWillTell
|
2
|
+
module Helpers
|
3
|
+
module DateHelper
|
4
|
+
|
5
|
+
DISTANCES_OF_TIME = [
|
6
|
+
{ unit: :year, minutes_per_unit: 365*24*60 },
|
7
|
+
{ unit: :month, minutes_per_unit: 30*24*60 },
|
8
|
+
{ unit: :day, minutes_per_unit: 24*60 },
|
9
|
+
{ unit: :hour, minutes_per_unit: 60 },
|
10
|
+
{ unit: :minute, minutes_per_unit: 1 }
|
11
|
+
].freeze
|
12
|
+
|
13
|
+
def exact_distance_of_time_in_words(from_time, to_time, options = {})
|
14
|
+
options = {
|
15
|
+
scope: :'time_will_tell.distance_in_words'
|
16
|
+
}.merge!(options)
|
17
|
+
|
18
|
+
include_seconds = options.fetch(:include_seconds, false)
|
19
|
+
|
20
|
+
from_time, to_time = to_time, from_time if from_time > to_time
|
21
|
+
timespan = to_time - from_time
|
22
|
+
distance_in_minutes = (timespan / 60.0).to_i
|
23
|
+
|
24
|
+
distance_in_words = []
|
25
|
+
|
26
|
+
I18n.with_options scope: options[:scope] do |locale|
|
27
|
+
DISTANCES_OF_TIME.each do |distance_of_time|
|
28
|
+
unit = distance_of_time[:unit]
|
29
|
+
minutes_per_unit = distance_of_time[:minutes_per_unit].to_f
|
30
|
+
|
31
|
+
count = (distance_in_minutes / minutes_per_unit).to_i
|
32
|
+
|
33
|
+
next if count == 0
|
34
|
+
|
35
|
+
if count == 30 && unit == :minute
|
36
|
+
if distance_in_words.empty?
|
37
|
+
distance_in_words << locale.t(:'special.half_an_hour')
|
38
|
+
else
|
39
|
+
distance_in_words << locale.t(:'special.and_a_half')
|
40
|
+
end
|
41
|
+
else
|
42
|
+
distance_in_words << pluralize_unit_with_locale(count, unit, locale)
|
43
|
+
end
|
44
|
+
|
45
|
+
distance_in_minutes -= count * minutes_per_unit
|
46
|
+
end
|
47
|
+
|
48
|
+
if include_seconds && (seconds_count = (timespan % 60).to_i) > 0
|
49
|
+
distance_in_words << pluralize_unit_with_locale(seconds_count, 'second', locale)
|
50
|
+
end
|
51
|
+
|
52
|
+
if distance_in_words.length > 2
|
53
|
+
locale.t(:template_long, rest: distance_in_words[0..-2].join(' '), last: distance_in_words.last)
|
54
|
+
else
|
55
|
+
distance_in_words.join(' ')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# Simplified reimplementation of Rails' ActionView::Helpers::TextHelper::pluralize
|
63
|
+
def pluralize_unit_with_locale(count, unit, locale)
|
64
|
+
singular = locale.t(:"units.#{unit}")
|
65
|
+
unit_word = count == 1 ? singular : singular.pluralize
|
66
|
+
locale.t(:template, count: count, unit: unit_word)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module TimeWillTell
|
2
|
+
module Helpers
|
3
|
+
module DateRangeHelper
|
4
|
+
|
5
|
+
def date_range(from_date, to_date, options = {})
|
6
|
+
format = options.fetch(:format, :short)
|
7
|
+
scope = options.fetch(:scope, 'time_will_tell.date_range')
|
8
|
+
separator = options.fetch(:separator, '—')
|
9
|
+
|
10
|
+
month_names = format.to_sym == :short ? I18n.t("date.abbr_month_names") : I18n.t("date.month_names")
|
11
|
+
|
12
|
+
from_date, to_date = to_date, from_date if from_date > to_date
|
13
|
+
from_day = from_date.day
|
14
|
+
from_month = month_names[from_date.month]
|
15
|
+
from_year = from_date.year
|
16
|
+
to_day = to_date.day
|
17
|
+
|
18
|
+
dates = { from_day: from_day, sep: separator }
|
19
|
+
|
20
|
+
if from_date == to_date
|
21
|
+
template = :same_date
|
22
|
+
dates.merge!(month: from_month, year: from_year)
|
23
|
+
elsif from_date.month == to_date.month && from_date.year == to_date.year
|
24
|
+
template = :same_month
|
25
|
+
dates.merge!(to_day: to_day, month: from_month, year: from_year)
|
26
|
+
else
|
27
|
+
to_month = month_names[to_date.month]
|
28
|
+
|
29
|
+
dates.merge!(from_month: from_month, to_month: to_month, to_day: to_day)
|
30
|
+
|
31
|
+
if from_date.year == to_date.year
|
32
|
+
template = :different_months_same_year
|
33
|
+
dates.merge!(year: from_year)
|
34
|
+
else
|
35
|
+
to_year = to_date.year
|
36
|
+
|
37
|
+
template = :different_years
|
38
|
+
dates.merge!(from_year: from_year, to_year: to_year)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
I18n.t("#{scope}.#{template}", dates)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'time_will_tell/helpers/date_helper'
|
3
|
+
require 'time_will_tell/helpers/date_range_helper'
|
4
|
+
|
5
|
+
module TimeWillTell
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
config.eager_load_namespaces << TimeWillTell::Helpers::DateHelper
|
8
|
+
config.eager_load_namespaces << TimeWillTell::Helpers::DateRangeHelper
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
fr:
|
2
|
+
date:
|
3
|
+
abbr_month_names:
|
4
|
+
- ~
|
5
|
+
- jan.
|
6
|
+
- fév.
|
7
|
+
- mar.
|
8
|
+
- avr.
|
9
|
+
- mai
|
10
|
+
- juin
|
11
|
+
- juil.
|
12
|
+
- août
|
13
|
+
- sept.
|
14
|
+
- oct.
|
15
|
+
- nov.
|
16
|
+
- déc.
|
17
|
+
month_names:
|
18
|
+
- ~
|
19
|
+
- janvier
|
20
|
+
- février
|
21
|
+
- mars
|
22
|
+
- avril
|
23
|
+
- mai
|
24
|
+
- juin
|
25
|
+
- juillet
|
26
|
+
- août
|
27
|
+
- septembre
|
28
|
+
- octobre
|
29
|
+
- novembre
|
30
|
+
- décembre
|
31
|
+
|
32
|
+
time_will_tell:
|
33
|
+
date_range:
|
34
|
+
different_months_same_year: "%{from_day} %{from_month} %{sep} %{to_day} %{to_month} %{year}"
|
35
|
+
different_years: "%{from_day} %{from_month} %{from_year} %{sep} %{to_day} %{to_month} %{to_year}"
|
36
|
+
same_month: "%{from_day} %{sep} %{to_day} %{month} %{year}"
|
37
|
+
same_date: "%{from_day} %{month} %{year}"
|
38
|
+
|
39
|
+
distance_in_words:
|
40
|
+
template: "%{count} %{unit}"
|
41
|
+
template_long: "%{rest} et %{last}"
|
42
|
+
|
43
|
+
units:
|
44
|
+
second: seconde
|
45
|
+
minute: minute
|
46
|
+
hour: heure
|
47
|
+
day: jour
|
48
|
+
month: mois
|
49
|
+
year: an
|
50
|
+
|
51
|
+
special:
|
52
|
+
half_an_hour: une demie heure
|
53
|
+
and_a_half: et demie
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TimeWillTell::Helpers::DateHelper do
|
4
|
+
# A helper instance with the DateHelper module included
|
5
|
+
let(:helper) do
|
6
|
+
Class.new do
|
7
|
+
include TimeWillTell::Helpers::DateHelper
|
8
|
+
end.new
|
9
|
+
end
|
10
|
+
|
11
|
+
SECOND = 1
|
12
|
+
MINUTE = 60 * SECOND
|
13
|
+
HOUR = 60 * MINUTE
|
14
|
+
DAY = 24 * HOUR
|
15
|
+
MONTH = 30 * DAY
|
16
|
+
YEAR = 365 * DAY
|
17
|
+
|
18
|
+
describe '#exact_distance_of_time_in_words' do
|
19
|
+
{
|
20
|
+
[2 * HOUR + 33 * MINUTE + 44 * SECOND] => '2 hours 33 minutes',
|
21
|
+
[1 * HOUR + 30 * MINUTE] => '1 hour and a half',
|
22
|
+
[3 * YEAR + 11 * MONTH + 21 * SECOND, include_seconds: true] => '3 years 11 months and 21 seconds',
|
23
|
+
[45 * DAY + 1 * MINUTE] => '1 month 15 days and 1 minute',
|
24
|
+
[1 * DAY + 2 * HOUR + 30 * MINUTE + 5 * SECOND, include_seconds: true] => '1 day 2 hours and a half and 5 seconds',
|
25
|
+
[30 * MINUTE] => 'half an hour',
|
26
|
+
}.each do |args, expected|
|
27
|
+
it "outputs '#{expected}'" do
|
28
|
+
timespan = args[0]
|
29
|
+
options = args[1]
|
30
|
+
|
31
|
+
from_time = Time.now
|
32
|
+
to_time = from_time + timespan
|
33
|
+
|
34
|
+
expect(
|
35
|
+
helper.exact_distance_of_time_in_words(*[from_time, to_time, options].compact)
|
36
|
+
).to eq expected
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'swaps from_time and to_time to get a positive timespan' do
|
41
|
+
to_time = Time.now
|
42
|
+
from_time = Time.now + (4 * DAY + 15 * MINUTE)
|
43
|
+
|
44
|
+
expect(
|
45
|
+
helper.exact_distance_of_time_in_words(from_time, to_time)
|
46
|
+
).to eq '4 days 15 minutes'
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with a custom locale' do
|
50
|
+
let(:locale) { :fr }
|
51
|
+
|
52
|
+
{
|
53
|
+
[2 * HOUR + 33 * MINUTE + 44 * SECOND] => '2 heures 33 minutes',
|
54
|
+
[1 * HOUR + 30 * MINUTE] => '1 heure et demie',
|
55
|
+
[3 * YEAR + 11 * MONTH + 21 * SECOND, include_seconds: true] => '3 ans 11 mois et 21 secondes',
|
56
|
+
[45 * DAY + 1 * MINUTE] => '1 mois 15 jours et 1 minute',
|
57
|
+
[1 * DAY + 2 * HOUR + 30 * MINUTE + 5 * SECOND, include_seconds: true] => '1 jour 2 heures et demie et 5 secondes',
|
58
|
+
[30 * MINUTE] => 'une demie heure',
|
59
|
+
}.each do |args, expected|
|
60
|
+
it "outputs '#{expected}'" do
|
61
|
+
timespan = args[0]
|
62
|
+
options = args[1]
|
63
|
+
|
64
|
+
from_time = Time.now
|
65
|
+
to_time = from_time + timespan
|
66
|
+
|
67
|
+
I18n.with_locale locale do
|
68
|
+
expect(
|
69
|
+
helper.exact_distance_of_time_in_words(*[from_time, to_time, options].compact)
|
70
|
+
).to eq expected
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TimeWillTell::Helpers::DateRangeHelper do
|
4
|
+
# A helper instance with the DateRangeHelper module included
|
5
|
+
let(:helper) do
|
6
|
+
Class.new do
|
7
|
+
include TimeWillTell::Helpers::DateRangeHelper
|
8
|
+
end.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#date_range' do
|
12
|
+
{
|
13
|
+
# short form
|
14
|
+
[Date.new(2012, 10, 3), Date.new(2012, 10, 8)] => 'Oct 3 — 8, 2012',
|
15
|
+
[Date.new(2013, 1, 30), Date.new(2013, 2, 5)] => 'Jan 30 — Feb 5, 2013',
|
16
|
+
[Date.new(2012, 12, 26), Date.new(2013, 1, 3)] => 'Dec 26, 2012 — Jan 3, 2013',
|
17
|
+
[Date.new(2013, 8, 24), Date.new(2013, 8, 24)] => 'Aug 24, 2013',
|
18
|
+
[Date.new(2014, 2, 10), Date.new(2015, 2, 10)] => 'Feb 10, 2014 — Feb 10, 2015',
|
19
|
+
|
20
|
+
# long form
|
21
|
+
[Date.new(2012, 10, 3), Date.new(2012, 10, 8), format: :long] => 'October 3 — 8, 2012',
|
22
|
+
[Date.new(2013, 1, 30), Date.new(2013, 2, 5), format: :long] => 'January 30 — February 5, 2013',
|
23
|
+
[Date.new(2012, 12, 26), Date.new(2013, 1, 3), format: :long] => 'December 26, 2012 — January 3, 2013',
|
24
|
+
[Date.new(2013, 8, 24), Date.new(2013, 8, 24), format: :long] => 'August 24, 2013',
|
25
|
+
[Date.new(2014, 2, 10), Date.new(2015, 2, 10), format: :long] => 'February 10, 2014 — February 10, 2015',
|
26
|
+
}.each do |args, expected|
|
27
|
+
it "outputs '#{expected}" do
|
28
|
+
from_date = args[0]
|
29
|
+
to_date = args[1]
|
30
|
+
options = args[2]
|
31
|
+
|
32
|
+
expect(
|
33
|
+
helper.date_range(*[from_date, to_date, options].compact)
|
34
|
+
).to eq expected
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'swaps from_date and to_date to get a positive range' do
|
39
|
+
from_date = Date.new(2014, 3, 17)
|
40
|
+
to_date = Date.new(2000, 1, 1)
|
41
|
+
|
42
|
+
expect(
|
43
|
+
helper.date_range(from_date, to_date)
|
44
|
+
).to eq 'Jan 1, 2000 — Mar 17, 2014'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'accepts a custom separator' do
|
48
|
+
from_date = Date.new(2013, 10, 31)
|
49
|
+
to_date = Date.new(2013, 12, 25)
|
50
|
+
|
51
|
+
expect(
|
52
|
+
helper.date_range(from_date, to_date, separator: '~')
|
53
|
+
).to eq 'Oct 31 ~ Dec 25, 2013'
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with a custom locale' do
|
57
|
+
let(:locale) { :fr }
|
58
|
+
|
59
|
+
{
|
60
|
+
# short form
|
61
|
+
[Date.new(2012, 10, 3), Date.new(2012, 10, 8)] => '3 — 8 oct. 2012',
|
62
|
+
[Date.new(2013, 1, 30), Date.new(2013, 2, 5)] => '30 jan. — 5 fév. 2013',
|
63
|
+
[Date.new(2012, 12, 26), Date.new(2013, 1, 3)] => '26 déc. 2012 — 3 jan. 2013',
|
64
|
+
[Date.new(2013, 8, 24), Date.new(2013, 8, 24)] => '24 août 2013',
|
65
|
+
[Date.new(2014, 2, 10), Date.new(2015, 2, 10)] => '10 fév. 2014 — 10 fév. 2015',
|
66
|
+
|
67
|
+
# long form
|
68
|
+
[Date.new(2012, 10, 3), Date.new(2012, 10, 8), format: :long] => '3 — 8 octobre 2012',
|
69
|
+
[Date.new(2013, 1, 30), Date.new(2013, 2, 5), format: :long] => '30 janvier — 5 février 2013',
|
70
|
+
[Date.new(2012, 12, 26), Date.new(2013, 1, 3), format: :long] => '26 décembre 2012 — 3 janvier 2013',
|
71
|
+
[Date.new(2013, 8, 24), Date.new(2013, 8, 24), format: :long] => '24 août 2013',
|
72
|
+
[Date.new(2014, 2, 10), Date.new(2015, 2, 10), format: :long] => '10 février 2014 — 10 février 2015',
|
73
|
+
}.each do |args, expected|
|
74
|
+
it "outputs '#{expected}'" do
|
75
|
+
from_date = args[0]
|
76
|
+
to_date = args[1]
|
77
|
+
options = args[2]
|
78
|
+
|
79
|
+
I18n.with_locale locale do
|
80
|
+
expect(
|
81
|
+
helper.date_range(*[from_date, to_date, options].compact)
|
82
|
+
).to eq expected
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'time_will_tell'
|
3
|
+
|
4
|
+
I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '../lib/generators/time_will_tell/templates/config/locales/*.yml') ]
|
5
|
+
I18n.load_path += Dir[ File.join(File.dirname(__FILE__), './fixtures/locales/*.yml') ]
|
6
|
+
I18n.default_locale = :en
|
7
|
+
|
8
|
+
# Require this file using `require 'spec_helper'` to ensure that it is only
|
9
|
+
# loaded once.
|
10
|
+
#
|
11
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
12
|
+
RSpec.configure do |config|
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'time_will_tell/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "time_will_tell"
|
8
|
+
spec.version = TimeWillTell::VERSION
|
9
|
+
spec.authors = ["Michel Billard"]
|
10
|
+
spec.email = ["michel@mbillard.com"]
|
11
|
+
spec.summary = %q{Specialized conversions of dates and times to strings.}
|
12
|
+
# spec.description = %q{TODO: Write a longer description. Optional.}
|
13
|
+
spec.homepage = "http://github.com/mbillard/time_will_tell"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'railties', '>= 3.2'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: time_will_tell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michel Billard
|
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: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- michel@mbillard.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/generators/USAGE
|
83
|
+
- lib/generators/install_generator.rb
|
84
|
+
- lib/generators/time_will_tell/templates/config/locales/time_will_tell.en.yml
|
85
|
+
- lib/time_will_tell.rb
|
86
|
+
- lib/time_will_tell/helpers/date_helper.rb
|
87
|
+
- lib/time_will_tell/helpers/date_range_helper.rb
|
88
|
+
- lib/time_will_tell/railtie.rb
|
89
|
+
- lib/time_will_tell/version.rb
|
90
|
+
- spec/fixtures/locales/time_will_tell.fr.yml
|
91
|
+
- spec/helpers/date_helper_spec.rb
|
92
|
+
- spec/helpers/date_range_helper_spec.rb
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
- time_will_tell.gemspec
|
95
|
+
homepage: http://github.com/mbillard/time_will_tell
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.0.3
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Specialized conversions of dates and times to strings.
|
119
|
+
test_files:
|
120
|
+
- spec/fixtures/locales/time_will_tell.fr.yml
|
121
|
+
- spec/helpers/date_helper_spec.rb
|
122
|
+
- spec/helpers/date_range_helper_spec.rb
|
123
|
+
- spec/spec_helper.rb
|