active_record_florder 0.0.1

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.
@@ -0,0 +1,62 @@
1
+ require 'active_record'
2
+ require 'active_record_florder/error'
3
+ require 'active_record_florder/configurable'
4
+ require 'active_record_florder/base'
5
+ require 'active_record_florder/models'
6
+ require 'active_record_florder/version'
7
+
8
+ # ActiveModelFlorder
9
+ # Floating point ActiveRecord models ordering for rich client apps
10
+ # heavily inspirated by Trello's ordering alorithm.
11
+ # DOC: https://github.com/turboMaCk/active-record-florder
12
+ module ActiveRecordFlorder
13
+ class << self
14
+
15
+ # Configure method can be used from initializer
16
+ # ActiveRecordFlorder.confige do |config|
17
+ # config.{attribute} {value}
18
+ # end
19
+ def configure
20
+ yield self if block_given?
21
+ end
22
+
23
+ # DB column name
24
+ def attribute(value)
25
+ @attribute = value
26
+ end
27
+
28
+ def get_attribute
29
+ @attribute || :position
30
+ end
31
+
32
+ # Position scope
33
+ def scope(value)
34
+ @scope = value
35
+ end
36
+
37
+ def get_scope
38
+ @scope || nil
39
+ end
40
+
41
+ # Minimal allowed delata between positions
42
+ def min_delta(value)
43
+ @min_delta = value
44
+ end
45
+
46
+ def get_min_delta
47
+ @min_delta || 0.0005
48
+ end
49
+
50
+ # Optimal and initial delta between positions
51
+ def step(value)
52
+ @step = value
53
+ end
54
+
55
+ def get_step
56
+ @step || 2**16
57
+ end
58
+ end
59
+ end
60
+
61
+ # Extending ActiveRecord::Base with florder method
62
+ ActiveRecord::Base.extend ActiveRecordFlorder::Models
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_record_florder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marek Fajkus
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Floating point ActiveRecord models ordering for rich client apps heavily
56
+ inspirated by Trello's ordering alorithm. ActiveRecordFlorder let client decide
57
+ position of model in collection normalize given value and resolve conflicting positions
58
+ in collection to keep your data clean. It's highly optimalized and generate as small
59
+ SQL queries as possible. The whole philosophy is to load and update as little records
60
+ as possible so in 99% it runs just one SELECT and one UPDATE. In edge cases sanitization
61
+ of all records happens and bring records back to the Garden of Eden. It's implemented
62
+ with both Rails and non-Rails apps in mind and highly configurable.
63
+ email:
64
+ - marek.faj@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - ".editorconfig"
70
+ - ".gitignore"
71
+ - ".rspec"
72
+ - ".ruby-version"
73
+ - ".travis.yml"
74
+ - Gemfile
75
+ - Gemfile.lock
76
+ - LICENSE.txt
77
+ - README.md
78
+ - Rakefile
79
+ - active_record_florder.gemspec
80
+ - bin/bundler
81
+ - bin/cc-tddium-post-worker
82
+ - bin/htmldiff
83
+ - bin/ldiff
84
+ - bin/rake
85
+ - bin/rspec
86
+ - coverage/.last_run.json
87
+ - coverage/.resultset.json
88
+ - coverage/.resultset.json.lock
89
+ - db/config.example.yml
90
+ - db/config.travis.yml
91
+ - db/migrate/20151230204642_create_owners.rb
92
+ - db/migrate/20151230210451_create_movables.rb
93
+ - db/migrate/20160103190528_add_position2_to_movables.rb
94
+ - db/schema.rb
95
+ - lib/active_record_florder.rb
96
+ - lib/active_record_florder/base.rb
97
+ - lib/active_record_florder/configurable.rb
98
+ - lib/active_record_florder/error.rb
99
+ - lib/active_record_florder/models.rb
100
+ - lib/active_record_florder/version.rb
101
+ homepage:
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.5.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Floating point ActiveRecord ordering for rich client apps
125
+ test_files: []