culturecode_hindsight 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +8 -0
- data/Rakefile +18 -0
- data/lib/hindsight.rb +8 -0
- data/lib/hindsight/has_hindsight.rb +38 -0
- data/lib/hindsight/version.rb +3 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de44fd51bf33b48c2b49d3f8dc0ff448e4dbc13a
|
4
|
+
data.tar.gz: 494da91f0c36bfbddba7d9276636493ba706a45a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c2a968ab262d59a73c0f3d764bfea65b04ca50d791815183cd8c8209f5d8094a369d638fa7424016a3ef9fa45750ae6a5ce12729b8d8a52e70a6b44ac73273a
|
7
|
+
data.tar.gz: b31006d133e441949af8564021d631207f9e2c5eafe15c85ce1e60dbd5141872eb764b973a9719c3395a6ca127a0986642bb2822c33628da08d3c4112cd58c89
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Culture Code Software Consulting Ltd.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
require 'bundler/gem_tasks'
|
11
|
+
|
12
|
+
# Default directory to look in is `/specs`
|
13
|
+
# Run with `rake spec`
|
14
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
15
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => :spec
|
data/lib/hindsight.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Hindsight
|
2
|
+
module ActMethod
|
3
|
+
def has_hindsight(options = {})
|
4
|
+
extend Hindsight::ClassMethods
|
5
|
+
include Hindsight::InstanceMethods
|
6
|
+
|
7
|
+
has_many :versions, :class_name => name, :primary_key => :versioned_record_id, :foreign_key => :versioned_record_id
|
8
|
+
|
9
|
+
before_save :prepare_version
|
10
|
+
after_create :init_versioned_record_id
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
end
|
16
|
+
|
17
|
+
module InstanceMethods
|
18
|
+
private
|
19
|
+
|
20
|
+
def prepare_version
|
21
|
+
new_record!
|
22
|
+
increment_version
|
23
|
+
end
|
24
|
+
|
25
|
+
def new_record!
|
26
|
+
self.id = nil
|
27
|
+
@new_record = true
|
28
|
+
end
|
29
|
+
|
30
|
+
def increment_version
|
31
|
+
self.version += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
def init_versioned_record_id
|
35
|
+
update_column(:versioned_record_id, id) unless versioned_record_id?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: culturecode_hindsight
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Wallace
|
8
|
+
- Nicholas Jakobsen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.1'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.1'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: pg
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: Versioning for your ActiveRecord models
|
57
|
+
email:
|
58
|
+
- contact@culturecode.ca
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- lib/hindsight.rb
|
67
|
+
- lib/hindsight/has_hindsight.rb
|
68
|
+
- lib/hindsight/version.rb
|
69
|
+
homepage: https://github.com/culturecode/hindsight
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.4.6
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Versioning for your ActiveRecord models
|
93
|
+
test_files: []
|