hublot 0.0.1 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +15 -0
  2. data/{LICENSE.txt → MIT-LICENSE} +2 -4
  3. data/README.rdoc +42 -0
  4. data/Rakefile +34 -1
  5. data/lib/hublot.rb +1 -1
  6. data/lib/hublot/pretty.rb +16 -16
  7. data/lib/hublot/rails.rb +9 -0
  8. data/lib/hublot/version.rb +2 -2
  9. data/lib/tasks/hublot_tasks.rake +4 -0
  10. data/test/dummy/Guardfile +24 -0
  11. data/test/dummy/Rakefile +7 -0
  12. data/test/dummy/app/assets/javascripts/application.js +15 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/test/dummy/app/controllers/application_controller.rb +3 -0
  15. data/test/dummy/app/helpers/application_helper.rb +2 -0
  16. data/test/dummy/app/models/comment.rb +7 -0
  17. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  18. data/test/dummy/config.ru +4 -0
  19. data/test/dummy/config/application.rb +59 -0
  20. data/test/dummy/config/boot.rb +10 -0
  21. data/test/dummy/config/database.yml +25 -0
  22. data/test/dummy/config/environment.rb +5 -0
  23. data/test/dummy/config/environments/development.rb +37 -0
  24. data/test/dummy/config/environments/production.rb +67 -0
  25. data/test/dummy/config/environments/test.rb +37 -0
  26. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  27. data/test/dummy/config/initializers/inflections.rb +15 -0
  28. data/test/dummy/config/initializers/mime_types.rb +5 -0
  29. data/test/dummy/config/initializers/secret_token.rb +7 -0
  30. data/test/dummy/config/initializers/session_store.rb +8 -0
  31. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  32. data/test/dummy/config/locales/en.yml +5 -0
  33. data/test/dummy/config/routes.rb +58 -0
  34. data/test/dummy/db/development.sqlite3 +0 -0
  35. data/test/dummy/db/migrate/20130715211742_create_comments.rb +9 -0
  36. data/test/dummy/db/schema.rb +22 -0
  37. data/test/dummy/db/test.sqlite3 +0 -0
  38. data/test/dummy/log/development.log +57 -0
  39. data/test/dummy/log/test.log +3069 -0
  40. data/test/dummy/public/404.html +26 -0
  41. data/test/dummy/public/422.html +26 -0
  42. data/test/dummy/public/500.html +25 -0
  43. data/test/dummy/public/favicon.ico +0 -0
  44. data/test/dummy/script/rails +6 -0
  45. data/test/dummy/spec/factories.rb +86 -0
  46. data/test/dummy/spec/features/hublot_prettifies_time_with_zone_spec.rb +83 -0
  47. data/test/dummy/spec/models/comment_spec.rb +73 -0
  48. data/test/dummy/spec/spec_helper.rb +38 -0
  49. data/test/dummy/test/fixtures/comments.yml +7 -0
  50. data/test/dummy/test/unit/comment_test.rb +7 -0
  51. data/test/dummy/tmp/rspec_guard_result +1 -0
  52. data/test/hublot_test.rb +7 -0
  53. data/test/test_helper.rb +15 -0
  54. metadata +131 -57
  55. data/.gitignore +0 -17
  56. data/.rspec +0 -1
  57. data/Gemfile +0 -9
  58. data/README.md +0 -50
  59. data/hublot.gemspec +0 -24
  60. data/lib/clock/clockmanifest.rb +0 -17
  61. data/lib/clock/friday.rb +0 -9
  62. data/lib/clock/last_friday.rb +0 -9
  63. data/lib/clock/last_monday.rb +0 -9
  64. data/lib/clock/last_saturday.rb +0 -9
  65. data/lib/clock/last_sunday.rb +0 -9
  66. data/lib/clock/last_thursday.rb +0 -9
  67. data/lib/clock/last_tuesday.rb +0 -9
  68. data/lib/clock/last_wednesday.rb +0 -9
  69. data/lib/clock/monday.rb +0 -9
  70. data/lib/clock/next_monday.rb +0 -9
  71. data/lib/clock/next_sunday.rb +0 -9
  72. data/lib/clock/saturday.rb +0 -9
  73. data/lib/clock/sunday.rb +0 -9
  74. data/lib/clock/thursday.rb +0 -9
  75. data/lib/clock/timepiece.rb +0 -15
  76. data/lib/clock/tuesday.rb +0 -9
  77. data/lib/clock/wednesday.rb +0 -9
  78. data/lib/example_objects/active_record_example.rb +0 -14
  79. data/spec/clock_spec.rb +0 -119
  80. data/spec/pretty_spec.rb +0 -77
@@ -1,77 +0,0 @@
1
- require 'rspec'
2
- require 'active_support/core_ext'
3
-
4
- require_relative '../lib/hublot'
5
- require_relative '../lib/clock/clockmanifest'
6
- require_relative '../lib/example_objects/active_record_example'
7
-
8
- describe Hublot do
9
- let(:example_object) { ExampleObjects::ActiveRecordExample.new }
10
- let(:monday) { Clock::Monday.new }
11
- let(:tuesday) { Clock::Tuesday.new }
12
- let(:wednesday) { Clock::Wednesday.new }
13
- let(:sunday) { Clock::Sunday.new }
14
- let(:last_monday) { Clock::LastMonday.new }
15
- let(:next_monday) { Clock::NextMonday.new }
16
- let(:next_sunday) { Clock::NextSunday.new }
17
-
18
- describe "#pretty" do
19
- it "returns just now when the object was just created" do
20
- expect(example_object.pretty).to eql("just now")
21
- end
22
-
23
- it "returns just now when the object was just created" do
24
- example_object.created_at = Time.now - 1.second
25
- expect(example_object.pretty).to eql("a second ago")
26
- end
27
-
28
- it "returns x seconds ago when it's been less than one minute since creation" do
29
- example_object.created_at = Time.now - 2.seconds
30
- expect(example_object.pretty).to eql("2 seconds ago")
31
- example_object.created_at = Time.now - 59.seconds
32
- expect(example_object.pretty).to eql("59 seconds ago")
33
- end
34
-
35
- it "returns x minutes ago when it's been less than one hour since creation" do
36
- example_object.created_at = Time.now - 1.minute
37
- expect(example_object.pretty).to eql("a minute ago")
38
- example_object.created_at = Time.now - 59.minutes
39
- expect(example_object.pretty).to eql("59 minutes ago")
40
- end
41
-
42
- it "returns an hour ago when it's been less than two hours since creation" do
43
- example_object.created_at = Time.now - 1.hour
44
- expect(example_object.pretty).to eql("an hour ago")
45
- example_object.created_at = Time.now - 2.hours + 1.second
46
- expect(example_object.pretty).to eql("an hour ago")
47
- end
48
-
49
- it "returns Today at time when it's been more than an hour, and it's still the same day" do
50
- example_object.created_at = monday.datetime - 2.hours
51
- expect(example_object.pretty(monday.datetime)).to eql("Today at 8:00PM")
52
- end
53
-
54
- it "returns Yesterday at time when it's been more than a day" do
55
- example_object.created_at = monday.datetime
56
- expect(example_object.pretty(tuesday.datetime)).to eql("Yesterday at 10:00PM")
57
- end
58
-
59
- it "returns the day of week at time when it's been more than two days and it's the same week" do
60
- example_object.created_at = monday.datetime
61
- expect(example_object.pretty(wednesday.datetime)).to eql("Monday at 10:00PM")
62
- expect(example_object.pretty(sunday.datetime)).to eql("Monday at 10:00PM")
63
- end
64
-
65
- it "returns last day of week at time when it's been more than one week" do
66
- example_object.created_at = last_monday.datetime
67
- expect(example_object.pretty(monday.datetime)).to eql("Last Monday at 10:00PM")
68
- expect(example_object.pretty(sunday.datetime)).to eql("Last Monday at 10:00PM")
69
- end
70
-
71
- it "returns a fully qualified datetime when it's been more than two weeks" do
72
- example_object.created_at = last_monday.datetime
73
- expect(example_object.pretty(next_monday.datetime)).to eql("Monday, July 1 at 10:00PM")
74
- expect(example_object.pretty(next_sunday.datetime)).to eql("Monday, July 1 at 10:00PM")
75
- end
76
- end
77
- end