timecop_web 0.0.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 48cf96274212c0882aec879eca038992422c519c
4
+ data.tar.gz: 13a2a9bba8908b0d77c38035064261e49e65a573
5
+ SHA512:
6
+ metadata.gz: 6ab01f03ea6fd3471be91769e5eaa76a6d815530521a3a9ee4fae71259f0a19fd580a05a743da0738432dd7d39779db54fc6c3bb89c18d1ba980e4a3cbd09f54
7
+ data.tar.gz: 6fcc5711b32d91762328ca0b4010ae4f06043bfcfcc2e27264392f9294af212d2fada97152c3fd3c8b98b8f17dd88f3b99d70b9f4d9ddc42281aeb42be60cc17
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Yoshiyuki Hirano
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # timecop_web
2
+
3
+ A web interface for Timecop. This is especially useful during development and QA.
4
+
5
+ ![](https://i.gyazo.com/4ae9e109c18713958342c93744ea4194.png)
6
+
7
+ ## Installation
8
+
9
+ First add the gem to your development environment and run the `bundle` command to install it.
10
+
11
+ ```ruby
12
+ gem 'timecop_web', group: :development
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Add to your routes.rb:
18
+
19
+ ```ruby
20
+ Your::App.routes.draw do
21
+ if Rails.env.development?
22
+ mount TimecopWeb::Engine, at: '/timecop_web'
23
+ end
24
+ end
25
+ ```
26
+
27
+ Then visit `http://localhost:3000/timecop_web`, you can use Timecop through web interface.
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'TimecopWeb'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
@@ -0,0 +1,5 @@
1
+ module TimecopWeb
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ require_dependency "timecop_web/application_controller"
2
+
3
+ module TimecopWeb
4
+ class MainController < ApplicationController
5
+ def index
6
+ end
7
+
8
+ def travel
9
+ case params[:commit]
10
+ when "travel" then Timecop.travel(move_at)
11
+ when "freeze" then Timecop.freeze(move_at)
12
+ else Timecop.return
13
+ end
14
+
15
+ redirect_to root_path
16
+ end
17
+
18
+ private
19
+
20
+ def move_at
21
+ @more_at ||= begin
22
+ Time.zone.parse %(#{travel_params["m(1i)"]}-#{travel_params["m(2i)"]}-#{travel_params["m(3i)"]} #{travel_params["m(4i)"]}:#{travel_params["m(5i)"]})
23
+ end
24
+ end
25
+
26
+ def travel_params
27
+ params.require(:travel).permit(:"m(1i)", :"m(2i)", :"m(3i)", :"m(4i)", :"m(5i)")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ module TimecopWeb
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,29 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title timecop web
5
+ meta name="viewport" content="width=device-width,initial-scale=1"
6
+ = csrf_meta_tags
7
+ = stylesheet_link_tag "//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/css/bootstrap.min.css"
8
+ css:
9
+ #main {
10
+ margin-top: 5.5rem;
11
+ }
12
+ footer {
13
+ padding: 1.5rem 0;
14
+ font-size: 80%;
15
+ color: #888;
16
+ }
17
+ body
18
+ = render partial: "shared/timecop_web/header"
19
+
20
+ .container-fluid#main
21
+ - if notice
22
+ .alert.alert-success role="alert"
23
+ small = notice
24
+ - if alert
25
+ .alert.alert-warning role="alert"
26
+ small = alert
27
+ = yield
28
+
29
+ = render partial: "shared/timecop_web/footer"
@@ -0,0 +1,4 @@
1
+ footer
2
+ .container-fluid
3
+ ul.nav.nav-inline
4
+ li.nav-item Powered by #{link_to "timecop web", "https://github.com/yhirano55/timecop_web", class: "nav-link"} #{TimecopWeb::VERSION}
@@ -0,0 +1,4 @@
1
+ header
2
+ nav.navbar.navbar-fixed-top.navbar-dark.bg-inverse
3
+ .nav.navbar-nav
4
+ = link_to "timecop web", root_path, class: "nav-item nav-link active"
@@ -0,0 +1,16 @@
1
+ .row
2
+ .col-md-12
3
+ .card
4
+ .card-block
5
+ - if stack_item = Timecop.top_stack_item
6
+ p.card-text #{I18n.l(stack_item.time, format: :long)} <span class="tag tag-danger">#{stack_item.mock_type}</span>
7
+ - else
8
+ p.card-text #{I18n.l(Time.current, format: :long)} <span class="tag tag-info">present</span>
9
+ = form_for(OpenStruct.new, as: :travel, url: travel_path, html: { class: "form-inline" }) do |f|
10
+ .form-group
11
+ = f.datetime_select :m, { start_year: 1940 }, class: "form-control"
12
+ .btn-group.m-l-1 role="group"
13
+ = f.submit :travel, class: "btn btn-outline-primary"
14
+ = f.submit :freeze, class: "btn btn-outline-primary"
15
+ = f.submit :return, class: "btn btn-outline-primary"
16
+
@@ -0,0 +1,4 @@
1
+ TimecopWeb::Engine.routes.draw do
2
+ root "main#index"
3
+ post "/" => "main#travel", as: :travel
4
+ end
@@ -0,0 +1,7 @@
1
+ require "timecop_web/engine"
2
+ require "timecop_web/version"
3
+ require "slim"
4
+ require "timecop"
5
+
6
+ module TimecopWeb
7
+ end
@@ -0,0 +1,11 @@
1
+ module TimecopWeb
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace TimecopWeb
4
+
5
+ config.generators do |g|
6
+ g.template_engine :slim
7
+ g.assets false
8
+ g.helper false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module TimecopWeb
2
+ VERSION = "0.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timecop_web
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Yoshiyuki Hirano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: slim
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: timecop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A web interface for timecop
56
+ email:
57
+ - yhirano@me.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/controllers/timecop_web/application_controller.rb
66
+ - app/controllers/timecop_web/main_controller.rb
67
+ - app/helpers/timecop_web/application_helper.rb
68
+ - app/views/layouts/timecop_web/application.html.slim
69
+ - app/views/shared/timecop_web/_footer.html.slim
70
+ - app/views/shared/timecop_web/_header.html.slim
71
+ - app/views/timecop_web/main/index.html.slim
72
+ - config/routes.rb
73
+ - lib/timecop_web.rb
74
+ - lib/timecop_web/engine.rb
75
+ - lib/timecop_web/version.rb
76
+ homepage: https://github.com/yhirano55/timecop_web
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.5.1
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: A web interface for timecop
100
+ test_files: []