jruby-ehcache-rails3 1.2.0 → 1.3.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/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +15 -0
- data/History.txt +15 -0
- data/License.txt +23 -0
- data/Manifest.txt +37 -0
- data/PostInstall.txt +2 -0
- data/README.txt +9 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/config/ehcache.yml +22 -0
- data/config/ehcache_manual_rmi.yml +27 -0
- data/examples/ehcache.xml +44 -0
- data/examples/jruby-ehcache.rb +13 -0
- data/ext/ehcache-2.4.6/ehcache-core-2.4.6.jar +0 -0
- data/ext/ehcache-2.4.6/ehcache-terracotta-2.4.6.jar +0 -0
- data/ext/ehcache-2.4.6/slf4j-api-1.6.1.jar +0 -0
- data/ext/ehcache-2.4.6/slf4j-jdk14-1.6.1.jar +0 -0
- data/ext/ehcache-2.4.6/terracotta-toolkit-1.3-runtime-3.3.0.jar +0 -0
- data/ext/marshaled-ruby-object.jar +0 -0
- data/jruby-ehcache-rails2.gemspec +27 -0
- data/jruby-ehcache-rails3.gemspec +27 -0
- data/jruby-ehcache.gemspec +23 -0
- data/lib/ehcache/active_support_store.rb +12 -1
- data/lib/ehcache/cache.rb +74 -0
- data/lib/ehcache/cache_manager.rb +69 -0
- data/lib/ehcache/config.rb +51 -0
- data/lib/ehcache/element.rb +36 -0
- data/lib/ehcache/java.rb +57 -0
- data/lib/ehcache/version.rb +3 -0
- data/lib/ehcache/yaml_config.rb +251 -0
- data/lib/ehcache.rb +22 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/spec/cache_manager_spec.rb +81 -0
- data/spec/cache_spec.rb +86 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +12 -0
- data/src/net/sf/ehcache/MarshaledRubyObject.java +15 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/ehcache.xml +44 -0
- data/test/ehcache.yml +67 -0
- data/test/test_cache.rb +36 -0
- data/test/test_cache_manager.rb +27 -0
- data/test/test_configuration.rb +29 -0
- data/test/test_ehcache.rb +22 -0
- data/test/test_element.rb +37 -0
- data/test/test_helper.rb +22 -0
- data/test/test_yaml_config.rb +159 -0
- data/website/index.html +141 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +76 -97
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
require 'java'
|
|
2
|
+
require 'ehcache'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require 'erb'
|
|
5
|
+
|
|
6
|
+
module Ehcache::Config
|
|
7
|
+
# Support for using YAML for Ehcache configuration.
|
|
8
|
+
#
|
|
9
|
+
# <strong>DEPRECATED:</strong> Please use ehcache.xml instead.
|
|
10
|
+
#
|
|
11
|
+
# YAML configuration is similar to XML configuration, but there are some
|
|
12
|
+
# changes to the names of configuration elements to make them simpler or
|
|
13
|
+
# more idiomatic to Ruby and YAML conventions. The changes are described
|
|
14
|
+
# below. For full documentation on the Ehcache configuration elements,
|
|
15
|
+
# see the Ehcache Cache Configuration documentation:
|
|
16
|
+
# http://ehcache.org/documentation/configuration.html
|
|
17
|
+
#
|
|
18
|
+
# The top level YAML configuration attributes and the corresponding XML
|
|
19
|
+
# elements or attributes are shown in the following table.
|
|
20
|
+
#
|
|
21
|
+
# name:: name attribute on ehcache element
|
|
22
|
+
# update_check:: updateCheck attribute on ehcache element
|
|
23
|
+
# monitoring:: monitoring attribute on ehcache element
|
|
24
|
+
# dynamic_config:: dynamicConfig attribute on ehcache element
|
|
25
|
+
# disk_store:: diskStore element
|
|
26
|
+
# transaction_manager:: transactionManagerLookup element
|
|
27
|
+
# event_listener:: cacheManagerEventListenerFactory element
|
|
28
|
+
# peer_providers (Array):: cacheManagerPeerProviderFactory elements
|
|
29
|
+
# peer_listeners (Array):: cacheManagerPeerListenerFactory elements
|
|
30
|
+
# terracotta_config:: terracottaConfig element
|
|
31
|
+
# default_cache:: defaultCache element
|
|
32
|
+
# caches (Array):: cache elements
|
|
33
|
+
#
|
|
34
|
+
# Each top level configuration attribute contains a set of key/value pairs
|
|
35
|
+
# that are equivalent to the Ehcache XML attributes, except that the
|
|
36
|
+
# attribute names are converted to use underscore_names instead of
|
|
37
|
+
# camelCaseNames. For instance, the Ehcache XML attribute
|
|
38
|
+
# diskSpoolBufferSizeMB becomes disk_spool_buffer_size_mb in YAML.
|
|
39
|
+
#
|
|
40
|
+
# Entries in the above table that are marked as (Array) should be YAML lists
|
|
41
|
+
# to allow for multiple values. So, for example, to configure multiple
|
|
42
|
+
# caches in your YAML configuration, use the following syntax:
|
|
43
|
+
#
|
|
44
|
+
# caches:
|
|
45
|
+
# - name: my_cache
|
|
46
|
+
# time_to_idle_seconds: 360
|
|
47
|
+
# time_to_live_seconds: 1000
|
|
48
|
+
# - name: my_other_cache
|
|
49
|
+
# max_elements_in_memory: 1000
|
|
50
|
+
# eternal: true
|
|
51
|
+
# overflow_to_disk: false
|
|
52
|
+
# disk_persistent: true
|
|
53
|
+
#
|
|
54
|
+
# Note the use of the '-' to separate list elements.
|
|
55
|
+
#
|
|
56
|
+
# One further difference between YAML configuration and XML configuration
|
|
57
|
+
# deals with cache configuration. The XML configuration allows for a set
|
|
58
|
+
# of XML sub elements to configure various aspects of caches (or the default
|
|
59
|
+
# cache). In YAML, these sub elements are translated to attributes within
|
|
60
|
+
# the cache configuration (or default_cache configuration) that
|
|
61
|
+
# refer to Hashes or Arrays. The following table shows the mapping.
|
|
62
|
+
#
|
|
63
|
+
# event_listeners (Array):: cacheEventListenerFactory sub elements
|
|
64
|
+
# extensions (Array):: cacheExtensionFactory sub elements
|
|
65
|
+
# loaders (Array):: cacheLoaderFactory sub elements
|
|
66
|
+
# decorators (Array):: cacheDecoratorFactory sub elements
|
|
67
|
+
# bootstrap_loader (Hash):: bootstrapCacheLoaderFactory sub element
|
|
68
|
+
# exception_handler (Hash):: cacheExceptionHandlerFactory sub element
|
|
69
|
+
# terracotta (Hash):: terracotta sub element
|
|
70
|
+
# cache_writer (Hash):: cacheWriter sub element
|
|
71
|
+
# copy_strategy (Hash):: copyStrategy sub element
|
|
72
|
+
#
|
|
73
|
+
# Those marked as (Array) may take a list of values, while those marked as
|
|
74
|
+
# (Hash) may take a single Hash value (set of key/value pairs). Here is an
|
|
75
|
+
# example of a cache configuration that uses one of each style:
|
|
76
|
+
#
|
|
77
|
+
# caches:
|
|
78
|
+
# - name: some_cache
|
|
79
|
+
# time_to_live_seconds: 100
|
|
80
|
+
# event_listeners:
|
|
81
|
+
# - class: net.sf.ehcache.distribution.RMICacheReplicatorFactory
|
|
82
|
+
# properties: "replicateAsynchronously=false"
|
|
83
|
+
# copy_strategy:
|
|
84
|
+
# class: net.sf.ehcache.store.compound.SerializationCopyStrategy
|
|
85
|
+
#
|
|
86
|
+
# Note again the use of the '-' character to separate list elements in the
|
|
87
|
+
# case of Array values, which is not present for Hash values.
|
|
88
|
+
module YamlConfig
|
|
89
|
+
|
|
90
|
+
InvalidYamlConfiguration = Class.new(StandardError)
|
|
91
|
+
|
|
92
|
+
# Not sure why, but "include Java::NetSfEhcacheConfig" does not work,
|
|
93
|
+
# so define local constants referring to the Ehcache classes
|
|
94
|
+
Configuration = Java::NetSfEhcacheConfig::Configuration
|
|
95
|
+
CacheConfiguration = Java::NetSfEhcacheConfig::CacheConfiguration
|
|
96
|
+
DiskStoreConfiguration = Java::NetSfEhcacheConfig::DiskStoreConfiguration
|
|
97
|
+
FactoryConfiguration = Java::NetSfEhcacheConfig::FactoryConfiguration
|
|
98
|
+
|
|
99
|
+
%w[name update_check monitoring dynamic_config
|
|
100
|
+
disk_store transaction_manager event_listener
|
|
101
|
+
peer_providers peer_listeners
|
|
102
|
+
terracotta_config default_cache caches
|
|
103
|
+
event_listeners extensions loaders decorators
|
|
104
|
+
].each do |attribute|
|
|
105
|
+
const_set(attribute.upcase.to_sym, attribute)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Parses the given yaml_config_file and returns a corresponding
|
|
109
|
+
# Ehcache::Config::Configuration object.
|
|
110
|
+
def self.parse_yaml_config(yaml_config_file)
|
|
111
|
+
Ehcache::LOG.warn("YAML configuration is deprecated. Please use ehcache.xml instead.")
|
|
112
|
+
YamlConfigBuilder.new(yaml_config_file).build
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
class YamlConfigBuilder
|
|
118
|
+
|
|
119
|
+
def initialize(yaml_file)
|
|
120
|
+
@yaml_file = yaml_file
|
|
121
|
+
@data = YAML.load(ERB.new(File.read(yaml_file)).result(binding))
|
|
122
|
+
raise InvalidYamlConfiguration unless valid?(@data)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def build
|
|
126
|
+
@config = Configuration.new
|
|
127
|
+
for attribute in [NAME, UPDATE_CHECK, MONITORING, DYNAMIC_CONFIG]
|
|
128
|
+
set_if_present(attribute)
|
|
129
|
+
end
|
|
130
|
+
set_disk_store
|
|
131
|
+
set_transaction_manager
|
|
132
|
+
set_event_listener
|
|
133
|
+
add_peer_providers
|
|
134
|
+
add_peer_listeners
|
|
135
|
+
set_default_cache
|
|
136
|
+
add_caches
|
|
137
|
+
@config
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
private
|
|
141
|
+
|
|
142
|
+
def valid?(data)
|
|
143
|
+
data.is_a?(Hash)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def set_if_present(key)
|
|
147
|
+
if @data.has_key?(key)
|
|
148
|
+
setter = "#{key}=".to_sym
|
|
149
|
+
@config.send(setter, @data[key])
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def set_attributes(object, attributes)
|
|
154
|
+
attributes ||= []
|
|
155
|
+
attributes.each do |key, value|
|
|
156
|
+
if value.is_a?(Hash) || value.is_a?(Array)
|
|
157
|
+
create_cache_config_factories(object, key, value)
|
|
158
|
+
else
|
|
159
|
+
object.send("#{key}=", value)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
object
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def create_cache_config_factories(cache, key, value)
|
|
166
|
+
[value].flatten.each do |data|
|
|
167
|
+
create_cache_config_factory(cache, key, data)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def names_for_factory(key)
|
|
172
|
+
singular = key.singularize.sub(/s$/, '')
|
|
173
|
+
factory_name = if key == 'bootstrap_loader'
|
|
174
|
+
"BootstrapCacheLoaderFactory"
|
|
175
|
+
else
|
|
176
|
+
"Cache#{singular.camelize}Factory"
|
|
177
|
+
end
|
|
178
|
+
class_name = "#{factory_name}Configuration"
|
|
179
|
+
method_name = "add#{factory_name}"
|
|
180
|
+
return [class_name, method_name]
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def create_cache_config_factory(cache, key, data)
|
|
184
|
+
class_name, method_name = names_for_factory(key)
|
|
185
|
+
factory_class = CacheConfiguration.const_get(class_name)
|
|
186
|
+
factory = factory_class.new
|
|
187
|
+
|
|
188
|
+
cache.send(method_name, factory)
|
|
189
|
+
set_attributes(factory, data)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def apply_config(key, config_class)
|
|
193
|
+
if @data[key]
|
|
194
|
+
[@data[key]].flatten.each do |data|
|
|
195
|
+
config = config_class.new
|
|
196
|
+
set_attributes(config, data)
|
|
197
|
+
yield config
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def set_disk_store
|
|
203
|
+
apply_config(DISK_STORE, DiskStoreConfiguration) do |disk_store|
|
|
204
|
+
@config.add_disk_store(disk_store)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def set_transaction_manager
|
|
209
|
+
apply_config(TRANSACTION_MANAGER, FactoryConfiguration) do |tx_mgr|
|
|
210
|
+
@config.add_transaction_manager_lookup(tx_mgr)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def set_event_listener
|
|
215
|
+
apply_config(EVENT_LISTENER, FactoryConfiguration) do |event_listener|
|
|
216
|
+
@config.addCacheManagerEventListenerFactory(event_listener)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def add_peer_providers
|
|
221
|
+
apply_config(PEER_PROVIDERS, FactoryConfiguration) do |peer_provider|
|
|
222
|
+
@config.addCacheManagerPeerProviderFactory(peer_provider)
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def add_peer_listeners
|
|
227
|
+
apply_config(PEER_LISTENERS, FactoryConfiguration) do |peer_listener|
|
|
228
|
+
@config.addCacheManagerPeerListenerFactory(peer_listener)
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def set_default_cache
|
|
233
|
+
apply_config(DEFAULT_CACHE, CacheConfiguration) do |cache_config|
|
|
234
|
+
@config.default_cache_configuration = cache_config
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def add_caches
|
|
239
|
+
apply_config(CACHES, CacheConfiguration) do |cache_config|
|
|
240
|
+
@config.add_cache(cache_config)
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def create_factory_configuration(data)
|
|
245
|
+
result = FactoryConfiguration.new
|
|
246
|
+
set_attributes(result, data)
|
|
247
|
+
result
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|
data/lib/ehcache.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
unless $:.include?(File.dirname(__FILE__)) ||
|
|
2
|
+
$:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
3
|
+
$:.unshift(File.dirname(__FILE__))
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require 'java'
|
|
7
|
+
|
|
8
|
+
module Ehcache
|
|
9
|
+
unless defined?(EHCACHE_HOME)
|
|
10
|
+
EHCACHE_HOME = File.expand_path(File.dirname(__FILE__) + '/..')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# wraps all native exceptions
|
|
14
|
+
class EhcacheError < RuntimeError; end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
require 'ehcache/extensions'
|
|
18
|
+
require 'ehcache/java'
|
|
19
|
+
require 'ehcache/config'
|
|
20
|
+
require 'ehcache/cache'
|
|
21
|
+
require 'ehcache/cache_manager'
|
|
22
|
+
require 'ehcache/element'
|
data/script/console
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# File: script/console
|
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
|
4
|
+
|
|
5
|
+
libs = " -r irb/completion"
|
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/ehcache.rb'}"
|
|
9
|
+
puts "Loading ehcache gem"
|
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/destroy'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/generate'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
GEM_NAME = 'ehcache' # what ppl will type to install your gem
|
|
4
|
+
RUBYFORGE_PROJECT = 'ehcache'
|
|
5
|
+
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
begin
|
|
8
|
+
require 'newgem'
|
|
9
|
+
require 'rubyforge'
|
|
10
|
+
rescue LoadError
|
|
11
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
|
12
|
+
puts "Install: gem install newgem\n\n"
|
|
13
|
+
exit(1)
|
|
14
|
+
end
|
|
15
|
+
require 'redcloth'
|
|
16
|
+
require 'syntax/convertors/html'
|
|
17
|
+
require 'erb'
|
|
18
|
+
require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
|
|
19
|
+
|
|
20
|
+
version = Ehcache::VERSION::STRING
|
|
21
|
+
download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
|
22
|
+
|
|
23
|
+
def rubyforge_project_id
|
|
24
|
+
RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class Fixnum
|
|
28
|
+
def ordinal
|
|
29
|
+
# teens
|
|
30
|
+
return 'th' if (10..19).include?(self % 100)
|
|
31
|
+
# others
|
|
32
|
+
case self % 10
|
|
33
|
+
when 1: return 'st'
|
|
34
|
+
when 2: return 'nd'
|
|
35
|
+
when 3: return 'rd'
|
|
36
|
+
else return 'th'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class Time
|
|
42
|
+
def pretty
|
|
43
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def convert_syntax(syntax, source)
|
|
48
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
if ARGV.length >= 1
|
|
52
|
+
src, template = ARGV
|
|
53
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
|
54
|
+
else
|
|
55
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
|
56
|
+
exit!
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
template = ERB.new(File.open(template).read)
|
|
60
|
+
|
|
61
|
+
title = nil
|
|
62
|
+
body = nil
|
|
63
|
+
File.open(src) do |fsrc|
|
|
64
|
+
title_text = fsrc.readline
|
|
65
|
+
body_text_template = fsrc.read
|
|
66
|
+
body_text = ERB.new(body_text_template).result(binding)
|
|
67
|
+
syntax_items = []
|
|
68
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
|
69
|
+
ident = syntax_items.length
|
|
70
|
+
element, syntax, source = $1, $2, $3
|
|
71
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
|
72
|
+
"syntax-temp-#{ident}"
|
|
73
|
+
}
|
|
74
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
|
75
|
+
body = RedCloth.new(body_text).to_html
|
|
76
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
|
77
|
+
end
|
|
78
|
+
stat = File.stat(src)
|
|
79
|
+
created = stat.ctime
|
|
80
|
+
modified = stat.mtime
|
|
81
|
+
|
|
82
|
+
$stdout << template.result(binding)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
|
2
|
+
|
|
3
|
+
describe CacheManager do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@manager = Ehcache::CacheManager.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
after(:each) do
|
|
9
|
+
@manager.shutdown
|
|
10
|
+
end
|
|
11
|
+
it "should return false if include? is called with a non-existant cache name" do
|
|
12
|
+
@manager.include?("zomg").should == false
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return false if exists? is called with a non-existant cache name" do
|
|
16
|
+
@manager.exists?("zomg").should == false
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should return true if include? is called with an existant cache name" do
|
|
20
|
+
@manager.include?(Ehcache::Cache::PRIMARY).should == true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should return true if exists? is called with an existant cache name" do
|
|
24
|
+
@manager.exists?(Ehcache::Cache::PRIMARY).should == true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should return all the cache names when caches is called" do
|
|
28
|
+
@manager.caches.length.should == 1
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should remove the cache when remove is called with a cache name" do
|
|
32
|
+
@manager.remove(Ehcache::Cache::PRIMARY)
|
|
33
|
+
@manager.caches.length.should == 0
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should remove all the caches when remove_all is called" do
|
|
37
|
+
@manager.add_cache("mynewcache")
|
|
38
|
+
@manager.caches.length.should == 2
|
|
39
|
+
@manager.remove_all
|
|
40
|
+
@manager.caches.length.should == 0
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should add a cache when cache is called with a cache name" do
|
|
44
|
+
@manager.add_cache("mynewcache")
|
|
45
|
+
@manager.caches.length.should == 2
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should add a cache when cache is called with a cache name" do
|
|
49
|
+
cache = @manager.cache(Ehcache::Cache::PRIMARY)
|
|
50
|
+
cache.put("key", "value")
|
|
51
|
+
cache.get("key").should == "value"
|
|
52
|
+
@manager.flush_all
|
|
53
|
+
cache.get("key").should == nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe CacheManager, "customized" do
|
|
58
|
+
after(:each) do
|
|
59
|
+
@manager.shutdown
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should create a primary cache with values based on default cache" do
|
|
63
|
+
@manager = Ehcache::CacheManager.new
|
|
64
|
+
@manager.cache.max_elements.should == 10000
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should create a cache with cache named steve" do
|
|
68
|
+
@manager = Ehcache::CacheManager.new({"cache" => {"name" => "steve"}})
|
|
69
|
+
@manager.include?("steve").should == true
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should create a custom default and primary cache" do
|
|
73
|
+
@manager = Ehcache::CacheManager.new({
|
|
74
|
+
"default" => {"max_elements_in_memory" => 200000},
|
|
75
|
+
"cache" => {"name" => "cache", "time_to_live_seconds" => 180, "eternal" => true}
|
|
76
|
+
})
|
|
77
|
+
@manager.cache("cache").max_elements.should == 200000
|
|
78
|
+
@manager.cache("cache").ttl.should == 180
|
|
79
|
+
@manager.cache("cache").eternal?.should == true
|
|
80
|
+
end
|
|
81
|
+
end
|
data/spec/cache_spec.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[spec_helper])
|
|
2
|
+
|
|
3
|
+
describe Cache do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@manager = Ehcache::CacheManager.new
|
|
6
|
+
@cache = @manager.cache
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
after(:each) do
|
|
10
|
+
@manager.shutdown
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should have an alive status on creation" do
|
|
14
|
+
@cache.status.should == Ehcache::Status::ALIVE
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should have a shutdown status when its manager shutsdown" do
|
|
18
|
+
@manager.shutdown
|
|
19
|
+
@cache.status.should == Ehcache::Status::SHUTDOWN
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should return an element value from get when given a valid key" do
|
|
23
|
+
@cache.put("lol", "123456")
|
|
24
|
+
@cache.get("lol").should == "123456"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should return true when removing an element from the cache given a valid key" do
|
|
28
|
+
@cache.put("lol", "123456")
|
|
29
|
+
@cache.remove("lol").should == true
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should return false when removing an element from the cache given a valid key" do
|
|
33
|
+
@cache.put("lol", "123456")
|
|
34
|
+
@cache.remove("rofl").should == false
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should remove all elements from the cache on a call to remove_all" do
|
|
38
|
+
@cache.put("lol", "123456")
|
|
39
|
+
@cache.put("rofl", "123456")
|
|
40
|
+
@cache.remove_all
|
|
41
|
+
@cache.size.should == 0
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should return true when exist? is called when a valid key is in the cache" do
|
|
45
|
+
@cache.put("lol", "123456")
|
|
46
|
+
@cache.exist?("lol").should == true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should return false when exist? is called when a valid key is in the cache" do
|
|
50
|
+
@cache.put("lol", "123456")
|
|
51
|
+
@cache.exist?("rofl").should == false
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should raise an EhcacheArgumentException when given an empty key" do
|
|
55
|
+
lambda { @cache.put("", "123456") }.should raise_error(EhcacheError)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should raise an EhcacheArgumentException when given nil key" do
|
|
59
|
+
lambda { @cache.put(nil, "123456") }.should raise_error(EhcacheError)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should allow adding an element to the cache with a time to live" do
|
|
63
|
+
@cache.put("lol", "123456", { :ttl => 60 })
|
|
64
|
+
@cache.element("lol").ttl.should == 60
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should return an element from a call to element when given a valid key" do
|
|
68
|
+
@cache.put("lol", "123456")
|
|
69
|
+
@cache.element("lol").class.should == Ehcache::Element
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should return the number of elements in the cache" do
|
|
73
|
+
@cache.size.should == 0
|
|
74
|
+
@cache.put("lol", "123456")
|
|
75
|
+
@cache.size.should == 1
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should return all the keys in the cache" do
|
|
79
|
+
@cache.put("lol", "123456")
|
|
80
|
+
@cache.put("rofl", "123456")
|
|
81
|
+
@cache.keys.size.should == 2
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should return the number of elements in the memory store"
|
|
85
|
+
it "should return the number of elements in the disk store"
|
|
86
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'spec'
|
|
3
|
+
require 'spec/story'
|
|
4
|
+
require 'java'
|
|
5
|
+
|
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ehcache]))
|
|
7
|
+
include Ehcache
|
|
8
|
+
include Ehcache::Java
|
|
9
|
+
|
|
10
|
+
Spec::Runner.configure do |config|
|
|
11
|
+
#config.mock_with :mocha
|
|
12
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package net.sf.ehcache;
|
|
2
|
+
|
|
3
|
+
import java.io.Serializable;
|
|
4
|
+
|
|
5
|
+
public class MarshaledRubyObject implements Serializable {
|
|
6
|
+
private byte[] bytes;
|
|
7
|
+
|
|
8
|
+
public MarshaledRubyObject(byte[] bytes) {
|
|
9
|
+
this.bytes = bytes;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public byte[] getBytes() {
|
|
13
|
+
return this.bytes;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
desc 'Release the website and new gem version'
|
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
|
3
|
+
puts "Remember to create SVN tag:"
|
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
|
6
|
+
puts "Suggested comment:"
|
|
7
|
+
puts "Tagging release #{CHANGES}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
|
12
|
+
|
|
13
|
+
task :check_version do
|
|
14
|
+
unless ENV['VERSION']
|
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
|
16
|
+
exit
|
|
17
|
+
end
|
|
18
|
+
unless ENV['VERSION'] == VERS
|
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
|
20
|
+
exit
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
namespace :manifest do
|
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
|
31
|
+
task :refresh do
|
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
|
33
|
+
end
|
|
34
|
+
end
|
data/tasks/website.rake
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
desc 'Generate website files'
|
|
2
|
+
task :website_generate => :ruby_env do
|
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
desc 'Upload website files to rubyforge'
|
|
9
|
+
task :website_upload do
|
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
|
12
|
+
local_dir = 'website'
|
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'Generate and upload website files'
|
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|