copy_tuner_client 0.0.6 → 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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- copy_tuner_client (0.0.6)
4
+ copy_tuner_client (0.0.7)
5
5
  i18n (>= 0.5.0)
6
6
  json
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mat_aki/gem/copy-tuner-ruby-client
3
3
  specs:
4
- copy_tuner_client (0.0.5)
4
+ copy_tuner_client (0.0.7)
5
5
  i18n (>= 0.5.0)
6
6
  json
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mat_aki/gem/copy-tuner-ruby-client
3
3
  specs:
4
- copy_tuner_client (0.0.5)
4
+ copy_tuner_client (0.0.7)
5
5
  i18n (>= 0.5.0)
6
6
  json
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mat_aki/gem/copy-tuner-ruby-client
3
3
  specs:
4
- copy_tuner_client (0.0.5)
4
+ copy_tuner_client (0.0.7)
5
5
  i18n (>= 0.5.0)
6
6
  json
7
7
 
@@ -15,7 +15,8 @@ module CopyTunerClient
15
15
  OPTIONS = [:api_key, :development_environments, :environment_name, :host,
16
16
  :http_open_timeout, :http_read_timeout, :client_name, :client_url,
17
17
  :client_version, :port, :protocol, :proxy_host, :proxy_pass,
18
- :proxy_port, :proxy_user, :secure, :polling_delay, :sync_interval, :sync_interval_staging, :logger,
18
+ :proxy_port, :proxy_user, :secure, :polling_delay, :sync_interval,
19
+ :sync_interval_staging, :sync_ignore_path_regex, :logger,
19
20
  :framework, :middleware, :disable_middleware, :disable_test_translation, :ca_file].freeze
20
21
 
21
22
  # @return [String] The API key for your project, found on the project edit form.
@@ -78,6 +79,9 @@ module CopyTunerClient
78
79
  # @return [Integer] The time, in seconds, in between each sync to the server in development. Defaults to +60+.
79
80
  attr_accessor :sync_interval_staging
80
81
 
82
+ # @return [Regex] Format ignore hook middleware sync
83
+ attr_accessor :sync_ignore_path_regex
84
+
81
85
  # @return [Logger] Where to log messages. Must respond to same interface as Logger.
82
86
  attr_reader :logger
83
87
 
@@ -186,7 +190,7 @@ module CopyTunerClient
186
190
 
187
191
  if middleware && development? && !disable_middleware
188
192
  logger.info "Using copytuner sync middleware"
189
- middleware.use RequestSync, :cache => cache, :interval => sync_interval
193
+ middleware.use RequestSync, :cache => cache, :interval => sync_interval, :ignore_regex => sync_ignore_path_regex
190
194
  else
191
195
  logger.info "[[[Warn]]] Not useing copytuner sync middleware" unless middleware
192
196
  end
@@ -18,6 +18,7 @@ module CopyTunerClient
18
18
  @app = app
19
19
  @cache = options[:cache]
20
20
  @interval = options[:interval]
21
+ @ignore_regex = options[:ignore_regex]
21
22
  @last_synced = options[:last_synced]
22
23
  end
23
24
 
@@ -29,9 +30,9 @@ module CopyTunerClient
29
30
  if /^\/copytuner/ =~ ::Rack::Request.new(env).path_info
30
31
  dup._call(env)
31
32
  else
32
- @cache.download unless asset_request?(env) or in_interval?
33
+ @cache.download unless cancel_sync?(env)
33
34
  response = @app.call(env)
34
- @cache.flush unless asset_request?(env) or in_interval?
35
+ @cache.flush unless cancel_sync?(env)
35
36
  update_last_synced unless in_interval?
36
37
  response
37
38
  end
@@ -111,6 +112,14 @@ module CopyTunerClient
111
112
  ERB.new(File.read(File.join(VIEW_PATH, 'copytuner', view.to_s + '.html.erb')), nil, nil, 'frobnitz').result(binding)
112
113
  end
113
114
 
115
+ def cancel_sync?(env)
116
+ asset_request?(env) or ignore_regex_request?(env) or in_interval?
117
+ end
118
+
119
+ def ignore_regex_request?(env)
120
+ env['PATH_INFO'] =~ @ignore_regex
121
+ end
122
+
114
123
  def asset_request?(env)
115
124
  env['PATH_INFO'] =~ /^\/assets/
116
125
  end
@@ -1,6 +1,6 @@
1
1
  module CopyTunerClient
2
2
  # Client version
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = '2.0'.freeze
@@ -195,7 +195,7 @@ end
195
195
  share_examples_for 'applied configuration' do
196
196
  subject { CopyTunerClient::Configuration.new }
197
197
  let(:backend) { stub('i18n-backend') }
198
- let(:cache) { stub('cache') }
198
+ let(:cache) { stub('cache', download: "download") }
199
199
  let(:client) { stub('client') }
200
200
  let(:logger) { FakeLogger.new }
201
201
  let(:poller) { stub('poller') }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_tuner_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-25 00:00:00.000000000 Z
12
+ date: 2013-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -362,7 +362,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
362
362
  version: '0'
363
363
  segments:
364
364
  - 0
365
- hash: 1508274453488739820
365
+ hash: 2325387855462933004
366
366
  required_rubygems_version: !ruby/object:Gem::Requirement
367
367
  none: false
368
368
  requirements:
@@ -371,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
371
371
  version: '0'
372
372
  segments:
373
373
  - 0
374
- hash: 1508274453488739820
374
+ hash: 2325387855462933004
375
375
  requirements: []
376
376
  rubyforge_project:
377
377
  rubygems_version: 1.8.23