zermelo 1.0.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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +10 -0
  4. data/.travis.yml +27 -0
  5. data/Gemfile +20 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +512 -0
  8. data/Rakefile +1 -0
  9. data/lib/zermelo/associations/association_data.rb +24 -0
  10. data/lib/zermelo/associations/belongs_to.rb +115 -0
  11. data/lib/zermelo/associations/class_methods.rb +244 -0
  12. data/lib/zermelo/associations/has_and_belongs_to_many.rb +128 -0
  13. data/lib/zermelo/associations/has_many.rb +120 -0
  14. data/lib/zermelo/associations/has_one.rb +109 -0
  15. data/lib/zermelo/associations/has_sorted_set.rb +124 -0
  16. data/lib/zermelo/associations/index.rb +50 -0
  17. data/lib/zermelo/associations/index_data.rb +18 -0
  18. data/lib/zermelo/associations/unique_index.rb +44 -0
  19. data/lib/zermelo/backends/base.rb +115 -0
  20. data/lib/zermelo/backends/influxdb_backend.rb +178 -0
  21. data/lib/zermelo/backends/redis_backend.rb +281 -0
  22. data/lib/zermelo/filters/base.rb +235 -0
  23. data/lib/zermelo/filters/influxdb_filter.rb +162 -0
  24. data/lib/zermelo/filters/redis_filter.rb +558 -0
  25. data/lib/zermelo/filters/steps/base_step.rb +22 -0
  26. data/lib/zermelo/filters/steps/diff_range_step.rb +17 -0
  27. data/lib/zermelo/filters/steps/diff_step.rb +17 -0
  28. data/lib/zermelo/filters/steps/intersect_range_step.rb +17 -0
  29. data/lib/zermelo/filters/steps/intersect_step.rb +17 -0
  30. data/lib/zermelo/filters/steps/limit_step.rb +17 -0
  31. data/lib/zermelo/filters/steps/offset_step.rb +17 -0
  32. data/lib/zermelo/filters/steps/sort_step.rb +17 -0
  33. data/lib/zermelo/filters/steps/union_range_step.rb +17 -0
  34. data/lib/zermelo/filters/steps/union_step.rb +17 -0
  35. data/lib/zermelo/locks/no_lock.rb +16 -0
  36. data/lib/zermelo/locks/redis_lock.rb +221 -0
  37. data/lib/zermelo/records/base.rb +62 -0
  38. data/lib/zermelo/records/class_methods.rb +127 -0
  39. data/lib/zermelo/records/collection.rb +14 -0
  40. data/lib/zermelo/records/errors.rb +24 -0
  41. data/lib/zermelo/records/influxdb_record.rb +35 -0
  42. data/lib/zermelo/records/instance_methods.rb +224 -0
  43. data/lib/zermelo/records/key.rb +19 -0
  44. data/lib/zermelo/records/redis_record.rb +27 -0
  45. data/lib/zermelo/records/type_validator.rb +20 -0
  46. data/lib/zermelo/version.rb +3 -0
  47. data/lib/zermelo.rb +102 -0
  48. data/spec/lib/zermelo/associations/belongs_to_spec.rb +6 -0
  49. data/spec/lib/zermelo/associations/has_many_spec.rb +6 -0
  50. data/spec/lib/zermelo/associations/has_one_spec.rb +6 -0
  51. data/spec/lib/zermelo/associations/has_sorted_set.spec.rb +6 -0
  52. data/spec/lib/zermelo/associations/index_spec.rb +6 -0
  53. data/spec/lib/zermelo/associations/unique_index_spec.rb +6 -0
  54. data/spec/lib/zermelo/backends/influxdb_backend_spec.rb +0 -0
  55. data/spec/lib/zermelo/backends/moneta_backend_spec.rb +0 -0
  56. data/spec/lib/zermelo/filters/influxdb_filter_spec.rb +0 -0
  57. data/spec/lib/zermelo/filters/redis_filter_spec.rb +0 -0
  58. data/spec/lib/zermelo/locks/redis_lock_spec.rb +170 -0
  59. data/spec/lib/zermelo/records/influxdb_record_spec.rb +258 -0
  60. data/spec/lib/zermelo/records/key_spec.rb +6 -0
  61. data/spec/lib/zermelo/records/redis_record_spec.rb +1426 -0
  62. data/spec/lib/zermelo/records/type_validator_spec.rb +6 -0
  63. data/spec/lib/zermelo/version_spec.rb +6 -0
  64. data/spec/lib/zermelo_spec.rb +6 -0
  65. data/spec/spec_helper.rb +67 -0
  66. data/spec/support/profile_all_formatter.rb +44 -0
  67. data/spec/support/uncolored_doc_formatter.rb +74 -0
  68. data/zermelo.gemspec +30 -0
  69. metadata +174 -0
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+ require 'zermelo/records/type_validator'
3
+
4
+ describe Zermelo::Records::TypeValidator do
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+ require 'zermelo/version'
3
+
4
+ describe Zermelo do
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+ require 'zermelo'
3
+
4
+ describe Zermelo do
5
+
6
+ end
@@ -0,0 +1,67 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start do
5
+ add_filter '/spec/'
6
+ end
7
+ end
8
+
9
+ require 'bundler'
10
+ Bundler.require(:default, :test)
11
+
12
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
13
+
14
+ # Requires supporting files with custom matchers and macros, etc,
15
+ # in ./support/ and its subdirectories.
16
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
17
+
18
+ # silence deprecation warning
19
+ require 'i18n'
20
+ I18n.enforce_available_locales = true
21
+
22
+ require 'redis'
23
+ require 'influxdb'
24
+
25
+ # This file was generated by the `rspec --init` command. Conventionally, all
26
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
27
+ # Require this file using `require "spec_helper"` to ensure that it is only
28
+ # loaded once.
29
+ #
30
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
31
+ RSpec.configure do |config|
32
+ config.run_all_when_everything_filtered = true
33
+ config.filter_run :focus
34
+
35
+ # Run specs in random order to surface order dependencies. If you find an
36
+ # order dependency and want to debug it, you can fix the order by providing
37
+ # the seed, which is printed after each run.
38
+ # --seed 1234
39
+ config.order = 'random'
40
+
41
+ config.around(:each, :redis => true) do |example|
42
+ # Zermelo.logger = ::Logger.new('tmp/spec.log')
43
+ Zermelo.redis = ::Redis.new(:db => 14)
44
+ Zermelo.redis.flushdb
45
+ example.run
46
+ Zermelo.redis.quit
47
+ # Zermelo.logger.debug('----')
48
+ # Zermelo.logger = nil
49
+ end
50
+
51
+ config.around(:each, :influxdb => true) do |example|
52
+ # Zermelo.logger = ::Logger.new('tmp/spec.log')
53
+ Zermelo.influxdb = InfluxDB::Client.new('zermelo_test',
54
+ :username => 'zermelo', :password => 'zermelo', :retry => false)
55
+ Zermelo.influxdb.query('list series')['list_series_result'].each do |ser|
56
+ Zermelo.influxdb.query("DELETE FROM \"#{ser['name']}\"")
57
+ end
58
+ example.run
59
+ # Zermelo.logger.debug('----')
60
+ # Zermelo.logger = nil
61
+ end
62
+
63
+ config.after(:each, :time => true) do
64
+ Timecop.return
65
+ end
66
+
67
+ end
@@ -0,0 +1,44 @@
1
+ require 'rspec/core/formatters/base_formatter'
2
+
3
+ class ProfileAllFormatter < RSpec::Core::Formatters::BaseFormatter
4
+
5
+ RSpec::Core::Formatters.register self,
6
+ :example_started, :example_passed, :start_dump
7
+
8
+ def initialize(output)
9
+ super(output)
10
+ @example_times = []
11
+ end
12
+
13
+ def start(notification)
14
+ super(notification)
15
+ @output.puts "Profiling enabled."
16
+ end
17
+
18
+ def example_started(notification)
19
+ @time = ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now)
20
+ end
21
+
22
+ def example_passed(notification)
23
+ @example_times << [
24
+ notification.example.example_group.description,
25
+ notification.example.description,
26
+ ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now) - @time
27
+ ]
28
+ end
29
+
30
+ def start_dump(notification)
31
+ @output.puts "\n\nExample times:\n"
32
+
33
+ @example_times = @example_times.sort_by do |description, example, time|
34
+ time
35
+ end.reverse
36
+
37
+ @example_times.each do |description, example, time|
38
+ @output.print sprintf("%.7f", time)
39
+ @output.puts " #{description} #{example}"
40
+ end
41
+ @output.flush
42
+ end
43
+
44
+ end
@@ -0,0 +1,74 @@
1
+ require 'rspec/core/formatters/base_text_formatter'
2
+
3
+ module NoColorizer
4
+ def self.wrap(text, color)
5
+ text
6
+ end
7
+ end
8
+
9
+ class UncoloredDocFormatter < RSpec::Core::Formatters::BaseTextFormatter
10
+ RSpec::Core::Formatters.register(self, :example_group_started,
11
+ :example_group_finished,
12
+ :example_passed, :example_pending,
13
+ :example_failed, :dump_failures,
14
+ :dump_pending, :dump_summary)
15
+
16
+ def initialize(output)
17
+ super
18
+ @group_level = 0
19
+ end
20
+
21
+ def example_group_started(notification)
22
+ output.puts if @group_level == 0
23
+ output.puts "#{current_indentation}#{notification.group.description.strip}"
24
+
25
+ @group_level += 1
26
+ end
27
+
28
+ def example_group_finished(notification)
29
+ @group_level -= 1
30
+ end
31
+
32
+ def example_passed(passed)
33
+ output.puts "#{current_indentation}#{passed.example.description.strip}"
34
+ end
35
+
36
+ def example_pending(pending)
37
+ output.puts "#{current_indentation}#{pending.example.description.strip} " +
38
+ "(PENDING: #{pending.example.execution_result.pending_message})"
39
+ end
40
+
41
+ def example_failed(failure)
42
+ output.puts "#{current_indentation}#{failure.example.description.strip} " +
43
+ "(FAILED - #{next_failure_index})"
44
+ end
45
+
46
+ def dump_failures(notification)
47
+ return if notification.failure_notifications.empty?
48
+ output.puts notification.fully_formatted_failed_examples(NoColorizer)
49
+ end
50
+
51
+ def dump_pending(notification)
52
+ return if notification.pending_examples.empty?
53
+ output.puts notification.fully_formatted_pending_examples(NoColorizer)
54
+ end
55
+
56
+ def dump_summary(notification)
57
+ output.puts notification.fully_formatted(NoColorizer)
58
+ end
59
+
60
+ private
61
+
62
+ def next_failure_index
63
+ @next_failure_index ||= 0
64
+ @next_failure_index += 1
65
+ end
66
+
67
+ def current_indentation
68
+ ' ' * @group_level
69
+ end
70
+
71
+ def example_group_chain
72
+ example_group.parent_groups.reverse
73
+ end
74
+ end
data/zermelo.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zermelo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.version = Zermelo::VERSION
8
+ spec.authors = ['Ali Graham']
9
+ spec.email = ['ali.graham@bulletproof.net']
10
+ spec.description = %q{ActiveModel-based set-theoretic ORM for Redis/InfluxDB}
11
+ spec.summary = %q{ActiveModel-based set-theoretic ORM for Redis/InfluxDB}
12
+ spec.homepage = 'https://github.com/flapjack/zermelo'
13
+ spec.license = 'MIT'
14
+
15
+ # see http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
16
+ # following a middle road here, not shipping it with the gem :)
17
+ spec.files = `git ls-files`.split($\) - ['Gemfile.lock']
18
+
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.name = 'zermelo'
24
+ spec.add_dependency 'activemodel'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
+ spec.add_development_dependency 'rake'
28
+
29
+ spec.requirements << "Redis and/or InfluxDB, and the related gems"
30
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zermelo
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ali Graham
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ActiveModel-based set-theoretic ORM for Redis/InfluxDB
56
+ email:
57
+ - ali.graham@bulletproof.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/zermelo.rb
70
+ - lib/zermelo/associations/association_data.rb
71
+ - lib/zermelo/associations/belongs_to.rb
72
+ - lib/zermelo/associations/class_methods.rb
73
+ - lib/zermelo/associations/has_and_belongs_to_many.rb
74
+ - lib/zermelo/associations/has_many.rb
75
+ - lib/zermelo/associations/has_one.rb
76
+ - lib/zermelo/associations/has_sorted_set.rb
77
+ - lib/zermelo/associations/index.rb
78
+ - lib/zermelo/associations/index_data.rb
79
+ - lib/zermelo/associations/unique_index.rb
80
+ - lib/zermelo/backends/base.rb
81
+ - lib/zermelo/backends/influxdb_backend.rb
82
+ - lib/zermelo/backends/redis_backend.rb
83
+ - lib/zermelo/filters/base.rb
84
+ - lib/zermelo/filters/influxdb_filter.rb
85
+ - lib/zermelo/filters/redis_filter.rb
86
+ - lib/zermelo/filters/steps/base_step.rb
87
+ - lib/zermelo/filters/steps/diff_range_step.rb
88
+ - lib/zermelo/filters/steps/diff_step.rb
89
+ - lib/zermelo/filters/steps/intersect_range_step.rb
90
+ - lib/zermelo/filters/steps/intersect_step.rb
91
+ - lib/zermelo/filters/steps/limit_step.rb
92
+ - lib/zermelo/filters/steps/offset_step.rb
93
+ - lib/zermelo/filters/steps/sort_step.rb
94
+ - lib/zermelo/filters/steps/union_range_step.rb
95
+ - lib/zermelo/filters/steps/union_step.rb
96
+ - lib/zermelo/locks/no_lock.rb
97
+ - lib/zermelo/locks/redis_lock.rb
98
+ - lib/zermelo/records/base.rb
99
+ - lib/zermelo/records/class_methods.rb
100
+ - lib/zermelo/records/collection.rb
101
+ - lib/zermelo/records/errors.rb
102
+ - lib/zermelo/records/influxdb_record.rb
103
+ - lib/zermelo/records/instance_methods.rb
104
+ - lib/zermelo/records/key.rb
105
+ - lib/zermelo/records/redis_record.rb
106
+ - lib/zermelo/records/type_validator.rb
107
+ - lib/zermelo/version.rb
108
+ - spec/lib/zermelo/associations/belongs_to_spec.rb
109
+ - spec/lib/zermelo/associations/has_many_spec.rb
110
+ - spec/lib/zermelo/associations/has_one_spec.rb
111
+ - spec/lib/zermelo/associations/has_sorted_set.spec.rb
112
+ - spec/lib/zermelo/associations/index_spec.rb
113
+ - spec/lib/zermelo/associations/unique_index_spec.rb
114
+ - spec/lib/zermelo/backends/influxdb_backend_spec.rb
115
+ - spec/lib/zermelo/backends/moneta_backend_spec.rb
116
+ - spec/lib/zermelo/filters/influxdb_filter_spec.rb
117
+ - spec/lib/zermelo/filters/redis_filter_spec.rb
118
+ - spec/lib/zermelo/locks/redis_lock_spec.rb
119
+ - spec/lib/zermelo/records/influxdb_record_spec.rb
120
+ - spec/lib/zermelo/records/key_spec.rb
121
+ - spec/lib/zermelo/records/redis_record_spec.rb
122
+ - spec/lib/zermelo/records/type_validator_spec.rb
123
+ - spec/lib/zermelo/version_spec.rb
124
+ - spec/lib/zermelo_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/support/profile_all_formatter.rb
127
+ - spec/support/uncolored_doc_formatter.rb
128
+ - zermelo.gemspec
129
+ homepage: https://github.com/flapjack/zermelo
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements:
148
+ - Redis and/or InfluxDB, and the related gems
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.5
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: ActiveModel-based set-theoretic ORM for Redis/InfluxDB
154
+ test_files:
155
+ - spec/lib/zermelo/associations/belongs_to_spec.rb
156
+ - spec/lib/zermelo/associations/has_many_spec.rb
157
+ - spec/lib/zermelo/associations/has_one_spec.rb
158
+ - spec/lib/zermelo/associations/has_sorted_set.spec.rb
159
+ - spec/lib/zermelo/associations/index_spec.rb
160
+ - spec/lib/zermelo/associations/unique_index_spec.rb
161
+ - spec/lib/zermelo/backends/influxdb_backend_spec.rb
162
+ - spec/lib/zermelo/backends/moneta_backend_spec.rb
163
+ - spec/lib/zermelo/filters/influxdb_filter_spec.rb
164
+ - spec/lib/zermelo/filters/redis_filter_spec.rb
165
+ - spec/lib/zermelo/locks/redis_lock_spec.rb
166
+ - spec/lib/zermelo/records/influxdb_record_spec.rb
167
+ - spec/lib/zermelo/records/key_spec.rb
168
+ - spec/lib/zermelo/records/redis_record_spec.rb
169
+ - spec/lib/zermelo/records/type_validator_spec.rb
170
+ - spec/lib/zermelo/version_spec.rb
171
+ - spec/lib/zermelo_spec.rb
172
+ - spec/spec_helper.rb
173
+ - spec/support/profile_all_formatter.rb
174
+ - spec/support/uncolored_doc_formatter.rb