anytime 0.0.5 → 0.0.7
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/lib/anytime.rb +3 -0
- data/lib/app/controllers/anytime_controller.rb +2 -0
- data/lib/app/helpers/anytime_helper.rb +22 -0
- metadata +2 -1
data/lib/anytime.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
require 'mocha'
|
|
2
2
|
require 'app/controllers/anytime_controller'
|
|
3
|
+
require 'app/helpers/anytime_helper'
|
|
3
4
|
|
|
4
5
|
module Anytime
|
|
5
6
|
|
|
7
|
+
ActionView::Base.send :include, AnytimeHelper
|
|
8
|
+
|
|
6
9
|
def self.freeze_at(year, month, date, hour=0, min=0, sec=0)
|
|
7
10
|
DateTime.stubs(:now).returns(DateTime.new(year, month, date, hour, min, sec, self.utc_offset))
|
|
8
11
|
Time.stubs(:now).returns(Time.send(self.time_mode, year, month, date, hour, min, sec))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'action_controller/base'
|
|
2
2
|
|
|
3
3
|
class AnytimeController < ActionController::Base
|
|
4
|
+
|
|
4
5
|
def freeze
|
|
5
6
|
date = params[:date]
|
|
6
7
|
Anytime.freeze_at(date[:year].to_i, date[:month].to_i, date[:day].to_i, date[:hour].to_i, date[:minute].to_i, date[:second].to_i)
|
|
@@ -9,5 +10,6 @@ class AnytimeController < ActionController::Base
|
|
|
9
10
|
|
|
10
11
|
def unfreeze
|
|
11
12
|
Anytime.unfreeze!
|
|
13
|
+
redirect_to :back
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module AnytimeHelper
|
|
2
|
+
def anytime_tag(time_option=false)
|
|
3
|
+
if Rails.env.eql? 'development'
|
|
4
|
+
form_content = date_selector.safe_concat(form_submitter)
|
|
5
|
+
form_tag = content_tag_string(:form, form_content, :action => "/freeze", :method => :post)
|
|
6
|
+
form_tag.safe_concat(unfreeze_button || "")
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
def date_selector
|
|
12
|
+
select_date(Date.today, :order => [:year, :month, :day], :use_month_numbers => true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def form_submitter
|
|
16
|
+
submit_tag Anytime.is_frozen? ? :freeze_again : :freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def unfreeze_button
|
|
20
|
+
button_to "Unfreeze", "/unfreeze" if Anytime.is_frozen?
|
|
21
|
+
end
|
|
22
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: anytime
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -36,6 +36,7 @@ extra_rdoc_files: []
|
|
|
36
36
|
files:
|
|
37
37
|
- lib/anytime.rb
|
|
38
38
|
- lib/app/controllers/anytime_controller.rb
|
|
39
|
+
- lib/app/helpers/anytime_helper.rb
|
|
39
40
|
- config/routes.rb
|
|
40
41
|
homepage: http://rubygems.org/gems/anytime
|
|
41
42
|
licenses: []
|