has_archive 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +33 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/has_archive.gemspec +24 -0
- data/lib/has_archive.rb +29 -0
- data/lib/has_archive/hook.rb +7 -0
- data/lib/has_archive/railtie.rb +20 -0
- data/lib/has_archive/version.rb +3 -0
- metadata +98 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d30459b9c94c042cf66564e1132d8609681a42a8
|
|
4
|
+
data.tar.gz: fcd801fa02fb0ca4ef7beef60a4e47f5440b2f19
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f830391c6d1bdcac4c17f0e3bcd7c39d6d43ce6c022d4f9980e7c96b2d5a53e9c5eb445fbbf990a0a4a673791c87cc7302a7e6293cd6b386b336ca1187fc224b
|
|
7
|
+
data.tar.gz: db090918e4a303c9ceb2a1b3071ceb5f9567460c3a33d790e3e363537072ca519b56936bc2ee9deaa0ff820dfd5bf3545c27a4fbd0c1f0e574ecfc96fff2adbd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# HasArchive
|
|
2
|
+
|
|
3
|
+
This project was born out of frustration with all the options I've found so far for archiving non-current ActiveRecord backed records, so I'm going to give it a go.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'has_archive'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install has_archive
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
TODO: Halp. This is ready for nothing, so far, but if this seems like a useful/worthwhile project to you, please feel free to dig and lend a hand.
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
28
|
+
|
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/matt-morris/has_archive.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "has_archive"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/has_archive.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'has_archive/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "has_archive"
|
|
8
|
+
spec.version = HasArchive::VERSION
|
|
9
|
+
spec.authors = ["Matt Morris"]
|
|
10
|
+
spec.email = ["double.emms@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Add archives to your ActiveRecord models}
|
|
13
|
+
spec.description = %q{Add archives to your ActiveRecord models}
|
|
14
|
+
spec.homepage = "http://github.com/matt-morris/has_archive"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
|
+
spec.bindir = "exe"
|
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
spec.add_development_dependency "rspec"
|
|
24
|
+
end
|
data/lib/has_archive.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "has_archive/version"
|
|
2
|
+
require "has_archive/hook"
|
|
3
|
+
require "has_archive/railtie" if defined?(Rails)
|
|
4
|
+
|
|
5
|
+
module HasArchive
|
|
6
|
+
def self.included(base)
|
|
7
|
+
base.send :extend, ClassMethods
|
|
8
|
+
base.send :include, InstanceMethods
|
|
9
|
+
|
|
10
|
+
eval <<-EVAL
|
|
11
|
+
class #{base}::Archive < #{base}
|
|
12
|
+
self.table_name = "#{base.to_s.underscore}_archives"
|
|
13
|
+
end
|
|
14
|
+
EVAL
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module ClassMethods
|
|
18
|
+
def archived
|
|
19
|
+
# i can haz archived records??
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module InstanceMethods
|
|
24
|
+
def archive
|
|
25
|
+
archived_at = Time.now
|
|
26
|
+
save
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module HasArchive
|
|
2
|
+
class Railtie < Rails::Railtie
|
|
3
|
+
initializer "railtie.configure_rails_initialization" do #|app|
|
|
4
|
+
# TODO is there actually anything we need to do with an initializer?
|
|
5
|
+
puts "///////////////////////////////////////////////////////////////////////////////////////////////"
|
|
6
|
+
puts "////// initializing has_archive ///////////////////////////////////////////////////////////////"
|
|
7
|
+
puts "///////////////////////////////////////////////////////////////////////////////////////////////"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# TODO is this where we want to pass in initialization options?
|
|
11
|
+
# are there even any options we need, yet?
|
|
12
|
+
config.has_archive = ActiveSupport::OrderedOptions.new
|
|
13
|
+
|
|
14
|
+
config.to_prepare do
|
|
15
|
+
class ActiveRecord::Base
|
|
16
|
+
ActiveRecord::Base.send :extend, HasArchive::Hook
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: has_archive
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Matt Morris
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-01-21 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.10'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.10'
|
|
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: '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: Add archives to your ActiveRecord models
|
|
56
|
+
email:
|
|
57
|
+
- double.emms@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- ".travis.yml"
|
|
65
|
+
- Gemfile
|
|
66
|
+
- README.md
|
|
67
|
+
- Rakefile
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/setup
|
|
70
|
+
- has_archive.gemspec
|
|
71
|
+
- lib/has_archive.rb
|
|
72
|
+
- lib/has_archive/hook.rb
|
|
73
|
+
- lib/has_archive/railtie.rb
|
|
74
|
+
- lib/has_archive/version.rb
|
|
75
|
+
homepage: http://github.com/matt-morris/has_archive
|
|
76
|
+
licenses: []
|
|
77
|
+
metadata: {}
|
|
78
|
+
post_install_message:
|
|
79
|
+
rdoc_options: []
|
|
80
|
+
require_paths:
|
|
81
|
+
- lib
|
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: '0'
|
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
requirements: []
|
|
93
|
+
rubyforge_project:
|
|
94
|
+
rubygems_version: 2.4.5
|
|
95
|
+
signing_key:
|
|
96
|
+
specification_version: 4
|
|
97
|
+
summary: Add archives to your ActiveRecord models
|
|
98
|
+
test_files: []
|