acts_as_journalized 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d506e23a40b3c83e33a0f05e57154ef7d0eab07e
4
+ data.tar.gz: 1afe44e8edbfdd2a9b455311fb6ce506383eb63b
5
+ SHA512:
6
+ metadata.gz: d468aa5e3988a6883d93a3a737eeb8d67521da84512281e4f8a3f0606f78374ddf13097633af361a4d955112c750f48fd3c706fd4db8ef55fcc4958bc537d384
7
+ data.tar.gz: 0382efc123e3c44c7000b77ad955b569aaa5dab2ab429ce549a2121c8640d1e417b1bbdb143bba29ccf5500a28f375484d94cd0d56fcc08f72500c860a4e3f17
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .*
19
+ *~
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in acts_as_journalized.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Roman Shipiev
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # ActsAsJournalized
2
+
3
+ Plug-in for Redmine. It's used for tracking and recording changes in model attributes.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'acts_as_journalized'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install acts_as_journalized
18
+
19
+ ## Usage
20
+
21
+ ### Model
22
+
23
+ class MyModel < ActiveRecord::Base
24
+ ...
25
+ acts_as_journalized
26
+ ...
27
+ end
28
+
29
+ Or
30
+
31
+ class MyModel < ActiveRecord::Base
32
+ ...
33
+ acts_as_journalized name: 'journals', excepted_attributes: [:updated_at, :updated_on], find_options: {}
34
+ ...
35
+ end
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it ( http://github.com/shipiev/acts_as_journalized/fork )
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -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 'acts_as_journalized/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'acts_as_journalized'
8
+ spec.version = ActsAsJournalized::VERSION
9
+ spec.authors = ['Roman Shipiev']
10
+ spec.email = ['roman@shipiev.pro']
11
+ spec.summary = %q{Plug-in for Redmine}
12
+ spec.description = %q{Used for tracking and recording changes in model attributes}
13
+ spec.homepage = 'https://github.com/rubynovich/acts_as_journalized'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.5'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rails', '3.2.13'
24
+ end
@@ -0,0 +1,30 @@
1
+ module Redmine
2
+ module Acts
3
+ module Journalized
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+ def acts_as_journalized(options = {})
8
+ cattr_accessor :journalized_options
9
+
10
+ options.assert_valid_keys(:excepted_attributes, :name, :find_options)
11
+ self.journalized_options = {
12
+ excepted_attributes: [:updated_at, :updated_on],
13
+ name: 'journals',
14
+ find_options: {}
15
+ }.merge(options)
16
+
17
+ find_options = {class_name: 'Journal', as: :journalized, dependent: :destroy}.
18
+ merge(self.journalized_options[:find_options])
19
+
20
+ has_many self.journalized_options[:name].to_sym, find_options
21
+
22
+ send :include, Redmine::Acts::Journalized::Callbacks
23
+
24
+ before_update :journalize_attributes
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ module Redmine
2
+ module Acts
3
+ module Journalized
4
+ module Callbacks
5
+ extend ActiveSupport::Concern
6
+
7
+ def init_journal(user = User.current, notes = '')
8
+ @journal ||= send(self.journalized_options[:name]).build(user: user, notes: notes)
9
+ end
10
+
11
+ def excepted_attributes
12
+ self.class.journalized_options[:excepted_attributes]
13
+ end
14
+
15
+ def journalize_attributes(user = User.current, notes = '')
16
+ init_journal(user, notes)
17
+ changes.except(*excepted_attributes).each_pair do |column, values|
18
+ @journal.details.build(property: 'attr', prop_key: column, old_value: values.first, value: values.last)
19
+ end
20
+ end
21
+
22
+ private :journalize_attributes, :excepted_attributes
23
+
24
+ module ClassMethods; end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module ActsAsJournalized
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'acts_as_journalized/version'
2
+ require 'acts_as_journalized/callbacks'
3
+ require 'acts_as_journalized/acts_as_journalized'
4
+
5
+ ActiveRecord::Base.send(:include, Redmine::Acts::Journalized)
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts_as_journalized
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Roman Shipiev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-22 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.13
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.13
55
+ description: Used for tracking and recording changes in model attributes
56
+ email:
57
+ - roman@shipiev.pro
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - acts_as_journalized.gemspec
68
+ - lib/acts_as_journalized.rb
69
+ - lib/acts_as_journalized/acts_as_journalized.rb
70
+ - lib/acts_as_journalized/callbacks.rb
71
+ - lib/acts_as_journalized/version.rb
72
+ homepage: https://github.com/rubynovich/acts_as_journalized
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Plug-in for Redmine
96
+ test_files: []
97
+ has_rdoc: