snippr 0.15.10 → 0.15.11

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTM3MjI1MmNmMmIxYmEzYTY4Nzk1MjI3MDFlNjVhNzEzZTQyYmFiZA==
4
+ MGFjMTEwNGFiZTU4OTNmNDczNmZiYjk2MWQxNjFjZDRkOWRjNDlmNA==
5
5
  data.tar.gz: !binary |-
6
- MjJkYWVmM2Q2ZWVjOGUzNTdjZmY2OGZkMDQ4ODhmYWI4OGY1NmIzNQ==
6
+ YjE1ZDg5NjZlZDdkOTQzMmZmMDBmMWE1ZTVmZTM5N2NhYTQ5NTE0Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTA3NjY3YmVkODRjZjlkYmJkMzIzNTE5NjY4NThiOTBlMjY2Y2JhYzJhMTQy
10
- OGExN2Y4NTBkZjUyNjk1OTYxYTM3YTRjNWNjN2ZmZDFjN2I5OWUzZjRiYzBh
11
- NjJjMjJiODQ3MmRkNWZhMzJjMjljNmQ0NDk0NjYyNTg2YzhkYmM=
9
+ YmRkYWI0YjAzMWJhMWU2ZjE4ZTI5NGFiNGU1YjU0OTYyMzdhODI1MDg5OGJl
10
+ OWI5YTI4MTFmODM5ZjcyZTQ5ZDg4YzZlZmI1NWMwNTMyMzUxN2EzMWY2NGZj
11
+ Y2FlYzQxOWMyNjBiMjI4OGZlMjJkZjFkMmVmNGUzZmM1Nzk3N2Q=
12
12
  data.tar.gz: !binary |-
13
- YjM5NWEyZmM0MDY1OWUzNWZmZWVkNTA4ZTM2NjBjODk4MzBkYjQ2ZjRmNjY0
14
- YjQxZjE4NmYzMjFmNjc5OWM3ODAzYmJhODIzYzdkYWMyMzU2OGRiMjcwNDQy
15
- ZTY4M2Y2NmUxMWVhZWRkM2QwMWQwYTc0MjQ2NTNhN2EzOThlMTk=
13
+ OTc3OTY4OTMyNWE4YTFjZWJmMzU2MWE5ODc0MmI3MGQ5ZjY2MTkzYTQwYzQ0
14
+ YmE0NGEyMTdlMzU5YWVjYjM0MDI0YzU1YTFlNzczODA5NjZiZjUyZDcxYWM4
15
+ NjU5MzI2M2Q3NjYzNTY2NGU4NGE5MTMyYzRmMjIzZDBiNTUyOGI=
data/README.md CHANGED
@@ -209,3 +209,30 @@ Edit `application.rb` (or the environment specific files in config/environments)
209
209
  # or even for defered configuration with a lambda:
210
210
  # config.snippr.path = lambda { SomeClassThatsAvailableLater.path }
211
211
  end
212
+
213
+ ## Bigger on the inside
214
+ Starting with 0.15.11 the gem supports rewinding and advancing time to display the state of a webpage on that moment.
215
+ This is especially useful when using `valid_from` or `valid_to`time based segment filters.
216
+
217
+ For that to work you need to configure the so called "snippr tardis" to be active.
218
+ Configuration is done via application.rb like so:
219
+
220
+ class Application < Rails::Application
221
+ config.snippr.tardis_enabled = true # or false or a Proc
222
+ end
223
+
224
+ Then call the `snippr_tardis` helper in your view:
225
+
226
+ <%= snippr_tardis if Rails.env.development? %>
227
+
228
+ You will then see the tardis appear in the upper right corner after a server restart.
229
+ Click on the tardis icon.
230
+
231
+ Now use one of the following and click "warp":
232
+
233
+ +1d : advance time one day
234
+ -4d : rewind time four days
235
+ -7h : rewind time 7 hours
236
+ +10m : advance ten minutes
237
+
238
+ You get the idea. Exterminate!
@@ -0,0 +1,19 @@
1
+ $(function snipprTardisScope() {
2
+ 'use strict';
3
+ var tardis = $('#snippr_tardis');
4
+
5
+ tardis.find('button.warp').on('click', function (e) {
6
+ e.preventDefault();
7
+ window.location.href = '?snippr_tardis=' + encodeURIComponent(tardis.find('.interval').val());
8
+ });
9
+
10
+ tardis.find('button.reset').on('click', function (e) {
11
+ e.preventDefault();
12
+ window.location.href = '?snippr_tardis=0';
13
+ });
14
+
15
+ tardis.find('.tardis').on('click', function (e) {
16
+ e.preventDefault();
17
+ tardis.find('.content').toggle();
18
+ });
19
+ });
@@ -0,0 +1,33 @@
1
+ #snippr_tardis {
2
+ background-color: #fff;
3
+ position: absolute;
4
+ top: 0;
5
+ right: 0;
6
+ padding: 4px 5px 5px 5px;
7
+ min-height: 18px;
8
+ border-left: 1px solid #000;
9
+ border-bottom: 1px solid #000;
10
+ z-index: 10000;
11
+ }
12
+
13
+ #snippr_tardis .tardis, #snippr_tardis .headline {
14
+ float: left;
15
+ }
16
+
17
+ #snippr_tardis .header {
18
+ margin-bottom: 5px;
19
+ overflow: hidden;
20
+ }
21
+
22
+ #snippr_tardis .hinterval {
23
+ width: 40px;
24
+ }
25
+
26
+ #snippr_tardis .current {
27
+ margin-bottom: 5px;
28
+ }
29
+
30
+ #snippr_tardis .content {
31
+ display: none;
32
+ width: 200px;
33
+ }
@@ -0,0 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module SnipprTardisHelper
3
+ def snippr_tardis
4
+ render "partials/snippr_tardis"
5
+ end
6
+ end
@@ -0,0 +1,17 @@
1
+ <%# encoding: utf-8 %>
2
+ <%= stylesheet_link_tag 'snippr_tardis/snippr_tardis' %>
3
+ <%= javascript_include_tag 'snippr_tardis/snippr_tardis' %>
4
+ <div id="snippr_tardis">
5
+ <div class="header">
6
+ <%= image_tag("snippr_tardis/icon-close.png", class: "tardis") %>
7
+ <div class="headline content">
8
+ Snippr Timewarp:
9
+ </div>
10
+ </div>
11
+ <div class="content">
12
+ <%= Snippr::Clock.now %>
13
+ <input class="interval" type="text" placeholder="<%= session[:snippr_tardis_interval] || "+1d" %>" />
14
+ <button class="warp">Warp</botton>
15
+ <button class="reset">Reset</botton>
16
+ </div>
17
+ </div>
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Snippr
3
+ module Rails
4
+ module ControllerExtension
5
+
6
+ private
7
+
8
+ def activate_snippr_tardis
9
+ if params[:snippr_tardis].present?
10
+ session[:snippr_tardis_interval] = params[:snippr_tardis]
11
+ Snippr::Clock.interval = session[:snippr_tardis_interval]
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -1,15 +1,32 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Snippr
3
-
4
3
  class Railtie < Rails::Railtie
5
4
 
6
5
  config.snippr = ActiveSupport::OrderedOptions.new
7
6
 
7
+ config.before_configuration do |app|
8
+ app.config.paths["app/helpers"] << File.expand_path("../../app/helpers", __FILE__)
9
+ app.config.paths["app/views"] << File.expand_path("../../app/views", __FILE__)
10
+ end
11
+
8
12
  initializer :setup_snippr, :group => :all do |app|
9
13
  Snippr.i18n = app.config.snippr.i18n
10
14
  Snippr.path = app.config.snippr.path
15
+ Snippr.tardis_enabled = app.config.snippr.tardis_enabled
16
+
11
17
  Snippr::Normalizer.add app.config.snippr.normalizers if app.config.snippr.normalizers
12
18
  Snippr.adjust_urls_except += Array(app.config.snippr.adjust_urls_except) if app.config.snippr.adjust_urls_except
19
+
20
+ if Snippr.tardis_enabled
21
+ require "snippr/rails/controller_extension"
22
+
23
+ app.config.paths["app/assets"] << File.expand_path("../../app/assets", __FILE__)
24
+ app.config.assets.precompile << "snippr_tardis/snippr_tardis.css"
25
+ app.config.assets.precompile << "snippr_tardis/snippr_tardis.js"
26
+
27
+ ActionController::Base.send(:include, Snippr::Rails::ControllerExtension)
28
+ ActionController::Base.send(:prepend_before_filter, :activate_snippr_tardis)
29
+ end
13
30
  end
14
31
 
15
32
  end
data/lib/snippr/snippr.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require "logger"
2
3
 
3
4
  # = Snippr
@@ -18,6 +19,14 @@ module Snippr
18
19
  Path.path = path
19
20
  end
20
21
 
22
+ def tardis_enabled=(bool_or_block)
23
+ Tardis.enabled = bool_or_block
24
+ end
25
+
26
+ def tardis_enabled
27
+ Tardis.enabled
28
+ end
29
+
21
30
  # Returns whether to use I18n snippr files.
22
31
  def i18n?
23
32
  I18n.enabled?
@@ -54,7 +63,7 @@ module Snippr
54
63
 
55
64
  # Lists all snips inside a snippr directory specified by path parts.
56
65
  def list(*args)
57
- Path.list *args
66
+ Path.list(*args)
58
67
  end
59
68
 
60
69
  end
@@ -0,0 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Snippr
3
+ class Tardis
4
+ def self.enabled=(bool_or_block)
5
+ if bool_or_block.kind_of?(Proc)
6
+ @enabled_condition = bool_or_block
7
+ else
8
+ @enabled_condition = -> { !!bool_or_block }
9
+ end
10
+ end
11
+
12
+ def self.enabled
13
+ @enabled_condition.call
14
+ end
15
+ end
16
+ end
data/lib/snippr.rb CHANGED
@@ -8,6 +8,7 @@ require 'snippr/links'
8
8
  require 'snippr/meta_data'
9
9
  require 'snippr/normalizer'
10
10
  require 'snippr/path'
11
+ require 'snippr/tardis'
11
12
  require 'snippr/processor'
12
13
  require 'snippr/railtie' if defined?(Rails)
13
14
  require 'snippr/view_helper'
data/snippr.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "snippr"
4
- s.version = "0.15.10"
4
+ s.version = "0.15.11"
5
5
  s.date = Time.now
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Daniel Harrington", "Thomas Jachmann", "Frank Schumacher"]
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "rake", "~> 10.0"
23
23
 
24
24
  unless ENV["CI"]
25
- s.add_development_dependency "debugger"
25
+ s.add_development_dependency "pry-debugger"
26
26
  end
27
27
 
28
28
  s.files = `git ls-files`.split("\n").reject{ |a| a.start_with?("\"") }
@@ -15,6 +15,17 @@ describe Snippr do
15
15
  subject.path = 'path'
16
16
  end
17
17
 
18
+ it "delegates tardis= to Snippr::Tardis.enabled=" do
19
+ Snippr::Tardis.expects(:enabled=).with(true)
20
+ subject.tardis_enabled = true
21
+ end
22
+
23
+ it "delegates tardis to Snippr::Tardis.enabled" do
24
+ Snippr::Tardis.should respond_to(:enabled)
25
+ Snippr::Tardis.expects(:enabled)
26
+ subject.tardis_enabled
27
+ end
28
+
18
29
  it "delegates i18n? to Snippr::I18n.enabled?" do
19
30
  Snippr::I18n.should respond_to(:enabled?)
20
31
  Snippr::I18n.expects(:enabled?).returns(true)
@@ -0,0 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require "spec_helper"
3
+
4
+ describe Snippr::Tardis do
5
+ describe ".enabled=" do
6
+ it "accepts a block" do
7
+ Snippr::Tardis.enabled = -> { "truthy" }
8
+ Snippr::Tardis.enabled.should eq "truthy"
9
+ end
10
+
11
+ it "accepts simple values" do
12
+ Snippr::Tardis.enabled = "truthy"
13
+ Snippr::Tardis.enabled.should be_true
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snippr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.10
4
+ version: 0.15.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -97,7 +97,7 @@ dependencies:
97
97
  - !ruby/object:Gem::Version
98
98
  version: '10.0'
99
99
  - !ruby/object:Gem::Dependency
100
- name: debugger
100
+ name: pry-debugger
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - ! '>='
@@ -127,6 +127,11 @@ files:
127
127
  - LICENSE
128
128
  - README.md
129
129
  - Rakefile
130
+ - lib/app/assets/images/snippr_tardis/icon-close.png
131
+ - lib/app/assets/javascripts/snippr_tardis/snippr_tardis.js
132
+ - lib/app/assets/stylesheets/snippr_tardis/snippr_tardis.css
133
+ - lib/app/helpers/snippr_tardis_helper.rb
134
+ - lib/app/views/partials/_snippr_tardis.html.erb
130
135
  - lib/snippr.rb
131
136
  - lib/snippr/clock.rb
132
137
  - lib/snippr/i18n.rb
@@ -142,6 +147,7 @@ files:
142
147
  - lib/snippr/processor/functions.rb
143
148
  - lib/snippr/processor/links.rb
144
149
  - lib/snippr/processor/wikilinks.rb
150
+ - lib/snippr/rails/controller_extension.rb
145
151
  - lib/snippr/railtie.rb
146
152
  - lib/snippr/segment_filter/base.rb
147
153
  - lib/snippr/segment_filter/on_host.rb
@@ -151,6 +157,7 @@ files:
151
157
  - lib/snippr/segment_parser.rb
152
158
  - lib/snippr/snip.rb
153
159
  - lib/snippr/snippr.rb
160
+ - lib/snippr/tardis.rb
154
161
  - lib/snippr/view_helper.rb
155
162
  - snippr.gemspec
156
163
  - spec/fixtures/a/path/aSnippet.snip
@@ -190,6 +197,7 @@ files:
190
197
  - spec/snippr/segment_parser_spec.rb
191
198
  - spec/snippr/snip_spec.rb
192
199
  - spec/snippr/snippr_spec.rb
200
+ - spec/snippr/tardis_spec.rb
193
201
  - spec/snippr/view_helper_spec.rb
194
202
  - spec/spec_helper.rb
195
203
  homepage: http://github.com/blaulabs/snippr
@@ -254,6 +262,7 @@ test_files:
254
262
  - spec/snippr/segment_parser_spec.rb
255
263
  - spec/snippr/snip_spec.rb
256
264
  - spec/snippr/snippr_spec.rb
265
+ - spec/snippr/tardis_spec.rb
257
266
  - spec/snippr/view_helper_spec.rb
258
267
  - spec/spec_helper.rb
259
268
  has_rdoc: