logga 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc185d64a918cac51a56b20765c205b38f54d785
4
+ data.tar.gz: 1949c2c9853bd5772a7e440ac9504e71247fbffc
5
+ SHA512:
6
+ metadata.gz: dfb8995b4d5c6e42d979944e9bdab276376b2b6b1e59cb3deb0fc07785512a1bc8de44d7513c99f9a294dba3e88403ea3a3cb6a51a9328b86b1986d14b1e1b5b
7
+ data.tar.gz: 2f9686849c6a73c2f32d01db7a4499e5d3c2c226e2aa798e029f3815fd3177d60a1dc973049f320fb98999ef7f4fe5349cf6b095fda297bc75ff27c27c4b70d5
data/.gitignore ADDED
@@ -0,0 +1,102 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Gems
11
+ /Gemfile.lock
12
+
13
+ # Ignore the default SQLite database.
14
+ /db/*.sqlite3
15
+ /db/*.sqlite3-journal
16
+
17
+ # Ignore gem building folder: pkg
18
+ pkg
19
+
20
+ # Ignore log and tmp files
21
+ log/*
22
+ *.log
23
+ tmp
24
+ tmp/**/*
25
+
26
+ # Documentation
27
+ /doc/
28
+ doc/api
29
+ doc/app
30
+ .yardoc
31
+ /_yardoc/
32
+ .yardopts
33
+
34
+ # Public Uploads
35
+ public/system/*
36
+ public/themes/*
37
+
38
+ # Public Cache
39
+ public/javascripts/cache
40
+ public/stylesheets/cache
41
+
42
+ # Vendor Cache
43
+ vendor/cache
44
+
45
+ # Acts as Indexed
46
+ index/**/*
47
+
48
+ # Refinery Specific
49
+ *.tmproj
50
+ *.autobackupbyrefinery.*
51
+ refinerycms-*.gem
52
+ .autotest
53
+
54
+ # Mac
55
+ .DS_Store
56
+
57
+ # Windows
58
+ Thumbs.db
59
+
60
+ # NetBeans
61
+ nbproject
62
+
63
+ # Eclipse
64
+ .project
65
+
66
+ # Redcar
67
+ .redcar
68
+
69
+ # Rubinius
70
+ *.rbc
71
+
72
+ # RVM / rbenv
73
+ .ruby-version
74
+ .ruby-gemset
75
+ .rvmrc
76
+
77
+ # Vim
78
+ *.swp
79
+ *.swo
80
+
81
+ # RubyMine
82
+ .idea
83
+
84
+ # E-texteditor
85
+ .eprj
86
+
87
+ # Backup
88
+ *~
89
+
90
+ # Capybara Bug
91
+ capybara-*html
92
+
93
+ # sass
94
+ .sass-cache
95
+ .sass-cache/*
96
+
97
+ # SimpleCov (tests code converage)
98
+ /coverage
99
+
100
+ # RSpec
101
+ /spec/reports/
102
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --require byebug
3
+ --require spec_helper
4
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.4
5
+ before_install: gem install bundler -v 1.15.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in logga.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Lorenzo Tello
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Logga
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/logga`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'logga'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install logga
22
+
23
+ ## Usage
24
+
25
+ Add this to your model:
26
+
27
+ ```ruby
28
+ class Order < ApplicationRecord
29
+ add_log_entries_for :create, :update
30
+ end
31
+
32
+ ```
33
+
34
+ so that new LogEntry records attached to a given Order instance will be created whenever a new one is created or
35
+ modified.
36
+
37
+ ## Development
38
+
39
+ 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.
40
+
41
+ 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).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ltello/logga.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "logga"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ module Logga
2
+ module ActiveRecord
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ def add_log_entries_for_updates!
7
+ around_update :log_model_changes
8
+ end
9
+ end
10
+
11
+ def log_model_changes
12
+ field_changes = changes
13
+ log_field_changes(field_changes) if yield
14
+ end
15
+
16
+ def log_field_changes(changes)
17
+ changes.each { |field, values| log_field_change(field, *values) }
18
+ end
19
+
20
+ def log_field_change(field, old_value, new_value)
21
+ author_data = Hash(try(:author))
22
+ self.log_entries.create(
23
+ body: "changed #{field} from #{old_value} to #{new_value}",
24
+ author_id: author_data[:id],
25
+ author_tupe: author_data[:type],
26
+ author_name: author_data[:name]
27
+ )
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module Logga
2
+ VERSION = "0.1.0"
3
+ end
data/lib/logga.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext'
3
+ require 'active_support/concern'
4
+ require_relative "logga/version"
5
+
6
+
7
+ module Logga
8
+
9
+ ActiveSupport.on_load(:active_record) do
10
+ include Logga::ActiveRecord
11
+ end
12
+
13
+ end
data/logga.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "logga/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "logga"
8
+ spec.version = Logga::VERSION
9
+ spec.authors = ["Stuart Chinery, Rob Hesketh, Lorenzo Tello"]
10
+ spec.email = ["stuart.chinery@gmail.com, contact@robhesketh.com, ltello8a@gmail.com"]
11
+
12
+ spec.summary = "Extensions to ActiveRecord to log entries on model changes"
13
+ spec.description = "Extensions to ActiveRecord to log entries on model changes"
14
+ spec.homepage = "https://github.com/ltello/logga"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.15"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.6"
27
+ spec.add_development_dependency "factory_girl", "~> 4.8"
28
+ spec.add_development_dependency "byebug", "~> 5.0"
29
+ spec.add_development_dependency "simplecov"
30
+
31
+ spec.add_runtime_dependency "activerecord", "~> 5.0"
32
+ spec.add_runtime_dependency "activesupport", "~> 5.0"
33
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logga
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stuart Chinery, Rob Hesketh, Lorenzo Tello
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-13 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: factory_girl
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activerecord
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '5.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '5.0'
125
+ description: Extensions to ActiveRecord to log entries on model changes
126
+ email:
127
+ - stuart.chinery@gmail.com, contact@robhesketh.com, ltello8a@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - bin/console
140
+ - bin/setup
141
+ - lib/logga.rb
142
+ - lib/logga/active_record.rb
143
+ - lib/logga/version.rb
144
+ - logga.gemspec
145
+ homepage: https://github.com/ltello/logga
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.6.12
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: Extensions to ActiveRecord to log entries on model changes
169
+ test_files: []