dev-time 0.0.1
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.markdown +35 -0
- data/Rakefile +1 -0
- data/app/assets/stylesheets/dev-time.css +52 -0
- data/app/assets/stylesheets/dev_time/current_time.css +12 -0
- data/app/controllers/dev_time/time_machine_controller.rb +29 -0
- data/app/helpers/dev_time/current_time_helper.rb +22 -0
- data/app/views/dev_time/time_machine/show.html.erb +53 -0
- data/config/routes.rb +12 -0
- data/dev-time.gemspec +27 -0
- data/lib/dev-time.rb +2 -0
- data/lib/dev-time/engine.rb +11 -0
- data/lib/dev-time/version.rb +5 -0
- metadata +85 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
Dev Time
|
2
|
+
========
|
3
|
+
|
4
|
+
Ever wish it were last month instead of right now when trying to test
|
5
|
+
your Rails app? DevTime uses the Delorean gem to add time travel capabilies
|
6
|
+
to your application so you can make it so!
|
7
|
+
|
8
|
+
Requirements
|
9
|
+
------------
|
10
|
+
|
11
|
+
rails >= 3.1
|
12
|
+
|
13
|
+
Installation
|
14
|
+
------------
|
15
|
+
|
16
|
+
Add dev-item to your `Gemfile`
|
17
|
+
|
18
|
+
gem 'dev-time'
|
19
|
+
|
20
|
+
|
21
|
+
Then run `bundle install` and start your app as normal.
|
22
|
+
|
23
|
+
Usage
|
24
|
+
-----
|
25
|
+
|
26
|
+
Go to http://localhost:3000/time-machine and get started time travelling!
|
27
|
+
|
28
|
+
Notes
|
29
|
+
-----
|
30
|
+
The time machine understands many ways of talking about time. Both absolute
|
31
|
+
(e.g. November 5, 1999) and relative (e.g. 3 years ago) will work.
|
32
|
+
|
33
|
+
Note that if your development server checks for timeout (like Unicorn does)
|
34
|
+
you may need to start it with a very long timeout setting (e.g. 1 year) in
|
35
|
+
order to avoid having the worker killed while it is time travelling.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,52 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #C0C0C0;
|
3
|
+
padding: 10px;
|
4
|
+
margin: 0px;
|
5
|
+
}
|
6
|
+
|
7
|
+
h1, h3 {
|
8
|
+
margin: 5px 0px;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1 {
|
12
|
+
text-shadow: white 0px 0px 1px;
|
13
|
+
}
|
14
|
+
|
15
|
+
h3 {
|
16
|
+
font-size: 0.9em;
|
17
|
+
color: #333;
|
18
|
+
}
|
19
|
+
|
20
|
+
.time-machine-dashboard {
|
21
|
+
margin: 20px 0px;
|
22
|
+
padding: 20px;
|
23
|
+
border: 1px solid black;
|
24
|
+
float: left;
|
25
|
+
border-radius: 10px;
|
26
|
+
background-color: #F0F0F0;
|
27
|
+
box-shadow: 0px 0px 2px 2px #400090;
|
28
|
+
}
|
29
|
+
|
30
|
+
.time-machine-dashboard > div {
|
31
|
+
margin: 5px 0px;
|
32
|
+
}
|
33
|
+
|
34
|
+
.time-machine-readout {
|
35
|
+
}
|
36
|
+
|
37
|
+
.time-machine-error {
|
38
|
+
color: #A00;
|
39
|
+
}
|
40
|
+
|
41
|
+
.time-machine-message {
|
42
|
+
color: #060;
|
43
|
+
}
|
44
|
+
|
45
|
+
.time-machine-controls {
|
46
|
+
clear: both;
|
47
|
+
}
|
48
|
+
|
49
|
+
.time-machine-instructions {
|
50
|
+
max-width: 500px;
|
51
|
+
}
|
52
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
if Rails.env.development?
|
2
|
+
module DevTime
|
3
|
+
class TimeMachineController < ApplicationController
|
4
|
+
def show
|
5
|
+
render layout: false
|
6
|
+
end
|
7
|
+
|
8
|
+
def travel
|
9
|
+
if params[:destination].blank?
|
10
|
+
flash[:time_machine_error] = "You must specify a destination time!"
|
11
|
+
else
|
12
|
+
begin
|
13
|
+
Delorean.time_travel_to params[:destination]
|
14
|
+
flash[:time_machine_message] = "Time travel successful."
|
15
|
+
rescue => e
|
16
|
+
flash[:time_machine_error] = "The Delorean wasn't able to understand your destination"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
redirect_to :time_machine
|
20
|
+
end
|
21
|
+
|
22
|
+
def return
|
23
|
+
Delorean.back_to_the_present
|
24
|
+
flash[:time_machine_message] = "You are safely back in the present."
|
25
|
+
redirect_to :time_machine
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DevTime
|
2
|
+
module CurrentTimeHelper
|
3
|
+
def dev_time_stylesheet_link_tag
|
4
|
+
if Rails.env.development?
|
5
|
+
stylesheet_link_tag 'dev_time/current_time'
|
6
|
+
else
|
7
|
+
''
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def dev_time_current_time_display
|
12
|
+
if Rails.env.development? &&
|
13
|
+
Delorean.send(:time_travel_offsets).any?
|
14
|
+
content_tag :div, class: "dev-time-current-time" do
|
15
|
+
"Time Travelling<br/>#{Time.now.strftime "%H:%M:%S %Y-%m-%d"}".html_safe
|
16
|
+
end
|
17
|
+
else
|
18
|
+
''
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>DevTime Time Machine</title>
|
4
|
+
<%= stylesheet_link_tag "dev-time" %>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<h1>Welcome to the DevTime Time Machine</h1>
|
8
|
+
<h3>powered by Delorean</h3>
|
9
|
+
|
10
|
+
<div class="time-machine-dashboard">
|
11
|
+
<div class="time-machine-readout">
|
12
|
+
The time is now <%= Time.now.strftime "%H:%M:%S %Y-%m-%d" %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<%- if flash[:time_machine_error].present? %>
|
16
|
+
<div class="time-machine-error">
|
17
|
+
<%= flash[:time_machine_error] %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<%- if flash[:time_machine_message].present? %>
|
22
|
+
<div class="time-machine-message">
|
23
|
+
<%= flash[:time_machine_message] %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="time-machine-controls">
|
29
|
+
<%= form_tag time_machine_travel_path do %>
|
30
|
+
Destination:
|
31
|
+
<%= text_field_tag :destination %>
|
32
|
+
<%= submit_tag "Travel through time!" %>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<%= form_tag time_machine_return_path do %>
|
36
|
+
<%= submit_tag "Go back to the present!" %>
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
<p class="time-machine-instructions">
|
40
|
+
The time machine understands many ways of talking about time.
|
41
|
+
Both absolute (e.g. November 5, 1999) and
|
42
|
+
relative (e.g. 3 years ago) will work.
|
43
|
+
</p>
|
44
|
+
|
45
|
+
<p class="time-machine-instructions">
|
46
|
+
Note that if your development server checks for timeout (like
|
47
|
+
Unicorn does) you may need to start it with a very long timeout
|
48
|
+
setting (e.g. 1 year) in order to avoid having the worker killed
|
49
|
+
while it is time travelling.
|
50
|
+
</p>
|
51
|
+
</div>
|
52
|
+
</body>
|
53
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
if Rails.env.development?
|
2
|
+
Rails.application.routes.draw do
|
3
|
+
get '/time-machine' => 'dev_time/time_machine#show',
|
4
|
+
as: :time_machine
|
5
|
+
|
6
|
+
post '/time-machine/travel' => 'dev_time/time_machine#travel',
|
7
|
+
as: :time_machine_travel
|
8
|
+
|
9
|
+
post '/time-machine/return' => 'dev_time/time_machine#return',
|
10
|
+
as: :time_machine_return
|
11
|
+
end
|
12
|
+
end
|
data/dev-time.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "dev-time/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "dev-time"
|
7
|
+
s.version = Dev::Time::VERSION
|
8
|
+
s.authors = ["David Vollbracht"]
|
9
|
+
s.email = ["david@flipstone.com"]
|
10
|
+
s.homepage = "http://github.com/flipstone/dev-time"
|
11
|
+
s.summary = %q{Give your Rails app the ability to time travel in development mode!}
|
12
|
+
s.description = %q{Ever wish it were last month instead of right now when trying to test
|
13
|
+
your Rails app? DevTime uses the Delorean gem to add time travel capabilies
|
14
|
+
to your application so you can make it so!}
|
15
|
+
|
16
|
+
s.rubyforge_project = "dev-time"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# s.add_development_dependency "rspec"
|
25
|
+
s.add_runtime_dependency "rails", ">= 3.1"
|
26
|
+
s.add_runtime_dependency "delorean", ">= 1.2.0"
|
27
|
+
end
|
data/lib/dev-time.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dev-time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Vollbracht
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &2161468560 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2161468560
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: delorean
|
27
|
+
requirement: &2161467940 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2161467940
|
36
|
+
description: ! 'Ever wish it were last month instead of right now when trying to test
|
37
|
+
|
38
|
+
your Rails app? DevTime uses the Delorean gem to add time travel capabilies
|
39
|
+
|
40
|
+
to your application so you can make it so!'
|
41
|
+
email:
|
42
|
+
- david@flipstone.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- README.markdown
|
50
|
+
- Rakefile
|
51
|
+
- app/assets/stylesheets/dev-time.css
|
52
|
+
- app/assets/stylesheets/dev_time/current_time.css
|
53
|
+
- app/controllers/dev_time/time_machine_controller.rb
|
54
|
+
- app/helpers/dev_time/current_time_helper.rb
|
55
|
+
- app/views/dev_time/time_machine/show.html.erb
|
56
|
+
- config/routes.rb
|
57
|
+
- dev-time.gemspec
|
58
|
+
- lib/dev-time.rb
|
59
|
+
- lib/dev-time/engine.rb
|
60
|
+
- lib/dev-time/version.rb
|
61
|
+
homepage: http://github.com/flipstone/dev-time
|
62
|
+
licenses: []
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project: dev-time
|
81
|
+
rubygems_version: 1.8.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Give your Rails app the ability to time travel in development mode!
|
85
|
+
test_files: []
|