moneta 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -8
  3. data/CHANGES +6 -0
  4. data/CONTRIBUTORS +2 -1
  5. data/Gemfile +7 -5
  6. data/README.md +2 -6
  7. data/feature_matrix.yaml +0 -10
  8. data/lib/moneta.rb +9 -9
  9. data/lib/moneta/adapters/mongo.rb +256 -7
  10. data/lib/moneta/adapters/redis.rb +5 -1
  11. data/lib/moneta/adapters/sequel.rb +45 -464
  12. data/lib/moneta/adapters/sequel/mysql.rb +66 -0
  13. data/lib/moneta/adapters/sequel/postgres.rb +80 -0
  14. data/lib/moneta/adapters/sequel/postgres_hstore.rb +240 -0
  15. data/lib/moneta/adapters/sequel/sqlite.rb +57 -0
  16. data/lib/moneta/adapters/sqlite.rb +7 -7
  17. data/lib/moneta/create_support.rb +21 -0
  18. data/lib/moneta/dbm_adapter.rb +31 -0
  19. data/lib/moneta/{mixins.rb → defaults.rb} +1 -302
  20. data/lib/moneta/each_key_support.rb +27 -0
  21. data/lib/moneta/expires_support.rb +60 -0
  22. data/lib/moneta/hash_adapter.rb +68 -0
  23. data/lib/moneta/increment_support.rb +16 -0
  24. data/lib/moneta/nil_values.rb +35 -0
  25. data/lib/moneta/option_support.rb +51 -0
  26. data/lib/moneta/transformer/helper/bson.rb +5 -15
  27. data/lib/moneta/version.rb +1 -1
  28. data/lib/rack/cache/moneta.rb +14 -15
  29. data/moneta.gemspec +7 -9
  30. data/script/benchmarks +1 -2
  31. data/script/contributors +11 -6
  32. data/spec/active_support/cache_moneta_store_spec.rb +27 -29
  33. data/spec/features/concurrent_increment.rb +2 -3
  34. data/spec/features/create_expires.rb +15 -15
  35. data/spec/features/default_expires.rb +11 -12
  36. data/spec/features/expires.rb +215 -210
  37. data/spec/helper.rb +16 -33
  38. data/spec/moneta/adapters/mongo/adapter_mongo_spec.rb +16 -1
  39. data/spec/moneta/adapters/mongo/adapter_mongo_with_default_expires_spec.rb +1 -1
  40. data/spec/moneta/adapters/mongo/standard_mongo_spec.rb +1 -1
  41. data/spec/moneta/adapters/sequel/adapter_sequel_spec.rb +7 -34
  42. data/spec/moneta/adapters/sequel/helper.rb +37 -0
  43. data/spec/moneta/adapters/sequel/standard_sequel_spec.rb +4 -10
  44. data/spec/moneta/adapters/sequel/standard_sequel_with_expires_spec.rb +7 -8
  45. data/spec/moneta/proxies/shared/shared_unix_spec.rb +10 -0
  46. data/spec/restserver.rb +15 -0
  47. metadata +39 -58
  48. data/lib/moneta/adapters/mongo/base.rb +0 -103
  49. data/lib/moneta/adapters/mongo/moped.rb +0 -166
  50. data/lib/moneta/adapters/mongo/official.rb +0 -156
  51. data/spec/moneta/adapters/mongo/adapter_mongo_moped_spec.rb +0 -26
  52. data/spec/moneta/adapters/mongo/adapter_mongo_moped_with_default_expires_spec.rb +0 -14
  53. data/spec/moneta/adapters/mongo/adapter_mongo_official_spec.rb +0 -27
  54. data/spec/moneta/adapters/mongo/adapter_mongo_official_with_default_expires_spec.rb +0 -14
  55. data/spec/moneta/adapters/mongo/standard_mongo_moped_spec.rb +0 -7
  56. data/spec/moneta/adapters/mongo/standard_mongo_official_spec.rb +0 -7
  57. data/spec/quality_spec.rb +0 -51
@@ -1,14 +0,0 @@
1
- describe 'adapter_mongo_moped_with_default_expires', isolate: true, adapter: :Mongo do
2
- let(:t_res) { 0.125 }
3
- let(:min_ttl) { t_res }
4
-
5
- moneta_build do
6
- Moneta::Adapters::MongoMoped.new(mongo_config(
7
- db: File.basename(__FILE__, '.rb'),
8
- collection: 'moped_with_default_expires',
9
- expires: min_ttl
10
- ))
11
- end
12
-
13
- moneta_specs ADAPTER_SPECS.with_each_key.with_expires.with_default_expires.simplevalues_only
14
- end
@@ -1,27 +0,0 @@
1
- describe 'adapter_mongo_official', adapter: :Mongo do
2
- let(:t_res) { 0.125 }
3
- let(:min_ttl) { t_res }
4
-
5
- moneta_build do
6
- Moneta::Adapters::MongoOfficial.new(mongo_config(
7
- db: File.basename(__FILE__, '.rb'),
8
- collection: 'official'
9
- ))
10
- end
11
-
12
- moneta_specs ADAPTER_SPECS.with_each_key.with_native_expires.simplevalues_only
13
-
14
- it 'automatically deletes expired document' do
15
- store.store('key', 'val', expires: 5)
16
-
17
- i = 0
18
- query = store.instance_variable_get(:@collection).find(_id: ::BSON::Binary.new('key'))
19
- while i < 70 && query.first
20
- i += 1
21
- sleep 1 # Mongo needs up to 60 seconds
22
- end
23
-
24
- i.should be > 0 # Indicates that it took at least one sleep to expire
25
- query.count.should == 0
26
- end
27
- end
@@ -1,14 +0,0 @@
1
- describe 'adapter_mongo_official_with_default_expires', isolate: true, adapter: :Mongo do
2
- let(:t_res) { 0.125 }
3
- let(:min_ttl) { t_res }
4
-
5
- moneta_build do
6
- Moneta::Adapters::MongoOfficial.new(mongo_config(
7
- db: File.basename(__FILE__, '.rb'),
8
- collection: 'official_with_default_expires',
9
- expires: min_ttl
10
- ))
11
- end
12
-
13
- moneta_specs ADAPTER_SPECS.with_each_key.with_expires.with_default_expires.simplevalues_only
14
- end
@@ -1,7 +0,0 @@
1
- describe 'standard_mongo_moped', adapter: :Mongo do
2
- let(:t_res) { 0.125 }
3
- let(:min_ttl) { t_res }
4
-
5
- moneta_store :MongoMoped, MongoHelper::mongo_config(db: File.basename(__FILE__, '.rb'), collection: 'moped')
6
- moneta_specs STANDARD_SPECS.with_native_expires.with_each_key
7
- end
@@ -1,7 +0,0 @@
1
- describe 'standard_mongo_official', adapter: :Mongo do
2
- let(:t_res) { 0.125 }
3
- let(:min_ttl) { t_res }
4
-
5
- moneta_store :MongoOfficial, MongoHelper::mongo_config(db: File.basename(__FILE__, '.rb'), collection: 'official')
6
- moneta_specs STANDARD_SPECS.with_native_expires.with_each_key
7
- end
@@ -1,51 +0,0 @@
1
- if defined?(Encoding) && Encoding.default_external != "UTF-8"
2
- Encoding.default_external = "UTF-8"
3
- end
4
-
5
- describe "The library itself", skip: true do
6
- def check_for_tab_characters(filename)
7
- failing_lines = []
8
- File.readlines(filename).each_with_index do |line,number|
9
- failing_lines << number + 1 if line =~ /\t/
10
- end
11
-
12
- unless failing_lines.empty?
13
- "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
14
- end
15
- end
16
-
17
- def check_for_extra_spaces(filename)
18
- failing_lines = []
19
- File.readlines(filename).each_with_index do |line,number|
20
- next if line =~ /^\s+#.*\s+\n$/
21
- failing_lines << number + 1 if line =~ /\s+\n$/
22
- end
23
-
24
- unless failing_lines.empty?
25
- "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
26
- end
27
- end
28
-
29
- RSpec::Matchers.define :be_well_formed do
30
- failure_message_for_should do |actual|
31
- actual.join("\n")
32
- end
33
-
34
- match do |actual|
35
- actual.empty?
36
- end
37
- end
38
-
39
- it "has no malformed whitespace" do
40
- exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|kill|LICENSE/
41
- error_messages = []
42
- Dir.chdir(File.expand_path("../..", __FILE__)) do
43
- `git ls-files`.split("\n").each do |filename|
44
- next if filename =~ exempt
45
- error_messages << check_for_tab_characters(filename)
46
- error_messages << check_for_extra_spaces(filename)
47
- end
48
- end
49
- expect(error_messages.compact).to be_well_formed
50
- end
51
- end