arturo 1.7.0 → 1.8.0
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/app/assets/javascripts/arturo.js +1 -2
- data/lib/arturo/feature_caching.rb +57 -15
- data/lib/arturo/test_support.rb +2 -0
- data/lib/generators/arturo/assets_generator.rb +2 -2
- metadata +19 -30
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -0
@@ -8,7 +8,6 @@ if (typeof(jQuery) === 'function') {
|
|
8
8
|
var output = jQuery(output);
|
9
9
|
var input = jQuery('#' + output.attr('for'));
|
10
10
|
input.change(function() {
|
11
|
-
console.log('input value changed to ' + input.val());
|
12
11
|
output.val(input.val());
|
13
12
|
});
|
14
13
|
output.removeClass('no_js');
|
@@ -16,7 +15,7 @@ if (typeof(jQuery) === 'function') {
|
|
16
15
|
}
|
17
16
|
}
|
18
17
|
};
|
19
|
-
|
18
|
+
|
20
19
|
jQuery(function() {
|
21
20
|
jQuery.arturo.linkAndShowOutputs();
|
22
21
|
});
|
@@ -19,12 +19,16 @@ module Arturo
|
|
19
19
|
module FeatureCaching
|
20
20
|
|
21
21
|
def self.extended(base)
|
22
|
-
class <<base
|
22
|
+
class << base
|
23
23
|
alias_method_chain :to_feature, :caching
|
24
|
-
attr_accessor :cache_ttl, :feature_cache
|
24
|
+
attr_accessor :cache_ttl, :feature_cache, :feature_caching_strategy
|
25
|
+
end
|
26
|
+
base.send(:after_save) do |f|
|
27
|
+
f.class.feature_caching_strategy.expire(f.class.feature_cache, f.symbol.to_sym) if f.class.caches_features?
|
25
28
|
end
|
26
29
|
base.cache_ttl = 0
|
27
30
|
base.feature_cache = Arturo::FeatureCaching::Cache.new
|
31
|
+
base.feature_caching_strategy = AllStrategy
|
28
32
|
end
|
29
33
|
|
30
34
|
def caches_features?
|
@@ -35,30 +39,64 @@ module Arturo
|
|
35
39
|
def to_feature_with_caching(feature_or_symbol)
|
36
40
|
if !caches_features?
|
37
41
|
to_feature_without_caching(feature_or_symbol)
|
38
|
-
elsif
|
39
|
-
feature_cache.write(feature_or_symbol.symbol.to_sym, feature_or_symbol, :expires_in => cache_ttl)
|
42
|
+
elsif feature_or_symbol.kind_of?(Arturo::Feature)
|
40
43
|
feature_or_symbol
|
41
|
-
elsif (cached_feature = feature_cache.read(feature_or_symbol.to_sym))
|
42
|
-
cached_feature
|
43
44
|
else
|
44
45
|
symbol = feature_or_symbol.to_sym
|
45
|
-
|
46
|
-
feature_cache.write(symbol, feature, :expires_in => cache_ttl)
|
47
|
-
feature
|
46
|
+
feature_caching_strategy.fetch(feature_cache, symbol) { to_feature_without_caching(symbol) }
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
# Warms the cache by fetching all `Feature`s and caching them.
|
52
|
-
# This is perfect for use in an initializer.
|
53
50
|
def warm_cache!
|
54
|
-
|
51
|
+
warn "Deprecated, no longer necessary!"
|
52
|
+
end
|
53
|
+
|
54
|
+
class AllStrategy
|
55
|
+
class << self
|
56
|
+
def fetch(cache, symbol, &block)
|
57
|
+
features = cache.read("arturo.all")
|
58
|
+
|
59
|
+
unless cache_is_current?(cache, features)
|
60
|
+
features = Hash[Arturo::Feature.all.map { |f| [f.symbol.to_sym, f] }]
|
61
|
+
mark_as_current!(cache)
|
62
|
+
cache.write("arturo.all", features, :expires_in => Arturo::Feature.cache_ttl * 10)
|
63
|
+
end
|
64
|
+
|
65
|
+
features[symbol] || Arturo::NoSuchFeature.new(symbol)
|
66
|
+
end
|
67
|
+
|
68
|
+
def expire(cache, symbol)
|
69
|
+
cache.delete("arturo.all")
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def cache_is_current?(cache, features)
|
75
|
+
return unless features
|
76
|
+
return true if cache.read("arturo.current")
|
77
|
+
return false if features.values.map(&:updated_at).compact.max != Arturo::Feature.maximum(:updated_at)
|
78
|
+
mark_as_current!(cache)
|
79
|
+
end
|
55
80
|
|
56
|
-
|
57
|
-
|
81
|
+
def mark_as_current!(cache)
|
82
|
+
cache.write("arturo.current", true, :expires_in => Arturo::Feature.cache_ttl)
|
83
|
+
end
|
58
84
|
end
|
59
85
|
end
|
60
86
|
|
61
|
-
|
87
|
+
class OneStrategy
|
88
|
+
def self.fetch(cache, symbol, &block)
|
89
|
+
if feature = cache.read("arturo.#{symbol}")
|
90
|
+
feature
|
91
|
+
else
|
92
|
+
cache.write("arturo.#{symbol}", yield || Arturo::NoSuchFeature.new(symbol), :expires_in => Arturo::Feature.cache_ttl)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.expire(cache, symbol)
|
97
|
+
cache.delete("arturo.#{symbol}")
|
98
|
+
end
|
99
|
+
end
|
62
100
|
|
63
101
|
# Quack like a Rails cache.
|
64
102
|
class Cache
|
@@ -75,6 +113,10 @@ module Arturo
|
|
75
113
|
end
|
76
114
|
end
|
77
115
|
|
116
|
+
def delete(name)
|
117
|
+
@data.delete(name)
|
118
|
+
end
|
119
|
+
|
78
120
|
def write(name, value, options = nil)
|
79
121
|
expires_at = if options && options.respond_to?(:[]) && options[:expires_in]
|
80
122
|
Time.now + options.delete(:expires_in)
|
data/lib/arturo/test_support.rb
CHANGED
@@ -8,6 +8,7 @@ Arturo.instance_eval do
|
|
8
8
|
# @param [Symbol, String] name the feature name
|
9
9
|
def enable_feature!(name)
|
10
10
|
if feature = Arturo::Feature.find_feature(name)
|
11
|
+
feature = feature.class.find(feature.id) if feature.frozen?
|
11
12
|
feature.update_attributes(:deployment_percentage => 100)
|
12
13
|
else
|
13
14
|
Arturo::Feature.create!(:symbol => name, :deployment_percentage => 100)
|
@@ -22,6 +23,7 @@ Arturo.instance_eval do
|
|
22
23
|
# @param [Symbol, String] name the feature name
|
23
24
|
def disable_feature!(name)
|
24
25
|
if feature = Arturo::Feature.find_feature(name)
|
26
|
+
feature = feature.class.find(feature.id) if feature.frozen?
|
25
27
|
feature.update_attributes(:deployment_percentage => 0)
|
26
28
|
end
|
27
29
|
end
|
@@ -4,11 +4,11 @@ module Arturo
|
|
4
4
|
class AssetsGenerator < Rails::Generators::Base
|
5
5
|
|
6
6
|
def self.source_root
|
7
|
-
|
7
|
+
File.join(File.dirname(__FILE__), 'templates')
|
8
8
|
end
|
9
9
|
|
10
10
|
def copy_assets
|
11
|
-
copy_file '
|
11
|
+
copy_file 'arturo_customizations.css', 'public/stylesheets/arturo_customizations.css', :skip => true
|
12
12
|
|
13
13
|
unless defined?(Sprockets)
|
14
14
|
copy_file 'app/assets/stylesheets/arturo.css', 'public/stylesheets/arturo.css', :force => true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arturo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,35 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain:
|
12
|
-
-
|
13
|
-
|
14
|
-
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJFTVJZd0ZBWURWUVFEREExcVlX
|
15
|
-
MWwKY3k1aExuSnZjMlZ1TVJVd0V3WUtDWkltaVpQeUxHUUJHUllGWjIxaGFX
|
16
|
-
d3hFekFSQmdvSmtpYUprL0lzWkFFWgpGZ05qYjIwd0hoY05NVE13TlRBeE1q
|
17
|
-
SXhNek14V2hjTk1UUXdOVEF4TWpJeE16TXhXakJFTVJZd0ZBWURWUVFECkRB
|
18
|
-
MXFZVzFsY3k1aExuSnZjMlZ1TVJVd0V3WUtDWkltaVpQeUxHUUJHUllGWjIx
|
19
|
-
aGFXd3hFekFSQmdvSmtpYUoKay9Jc1pBRVpGZ05qYjIwd2dnRWlNQTBHQ1Nx
|
20
|
-
R1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUURSUUxTTQppd05IaUY3
|
21
|
-
WGNiRlR1TGp1Y0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pNNlViVEEvUDcKL1dySHNYS2hZZk44
|
37
|
-
eExwbFhYR2tTdDNOUzhSRmhRRkNPSWRnc1hFbGpFdlpwVnh1cmk1T2JIMHpx
|
38
|
-
eFVOWE9scQo1bEVpNTZuM0tra0tSaHUxY0U2MWdBPT0KLS0tLS1FTkQgQ0VS
|
39
|
-
VElGSUNBVEUtLS0tLQo=
|
40
|
-
date: 2013-07-08 00:00:00.000000000 Z
|
12
|
+
- gem-public_cert.pem
|
13
|
+
date: 2013-10-12 00:00:00.000000000 Z
|
41
14
|
dependencies:
|
42
15
|
- !ruby/object:Gem::Dependency
|
43
16
|
name: rails
|
@@ -93,6 +66,22 @@ dependencies:
|
|
93
66
|
- - ! '>='
|
94
67
|
- !ruby/object:Gem::Version
|
95
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - <
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '5'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - <
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '5'
|
96
85
|
- !ruby/object:Gem::Dependency
|
97
86
|
name: minitest-rg
|
98
87
|
requirement: !ruby/object:Gem::Requirement
|
data.tar.gz.sig
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
9����.e44jdrnKL�6;�<Ty�W�+�~�F��}Ȳ8r�)��]����ɒ�{s��N\�b4�K�9�ˎ��Q�Y����ZN��cZ�*�v�$�K)!|*��,�v�����p�J�X3���c�[���~FG�M��$�0qꑪL��$�J0�tJ��c�͉�T���)�*�:Ĵ�e@"��XWa�K�R�Y�f�eXBD���НuR%�̏g._�jU?�S���ƫ����pX��@�}�
|
metadata.gz.sig
DELETED
Binary file
|