change_log 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.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in change_log.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "change_log/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "change_log"
7
+ s.version = ChangeLog::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Peter Zhang"]
10
+ s.email = ["peterz@ncs.co.nz"]
11
+ s.homepage = "http://www.ncs.co.nz"
12
+ s.summary = %q{Change log gem record every changes for the model}
13
+ s.description = %q{A gem to keep all maintenance logs}
14
+
15
+ s.add_development_dependency "rspec"
16
+ s.rubyforge_project = "change_log"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ end
@@ -0,0 +1,3 @@
1
+ module ChangeLog
2
+ VERSION = "0.0.1"
3
+ end
data/lib/change_log.rb ADDED
@@ -0,0 +1,45 @@
1
+ require 'singleton'
2
+ require 'yaml'
3
+ require 'change_log/config'
4
+ require 'change_log/controller'
5
+ require 'change_log/has_change_log'
6
+ require 'change_log/maintenance'
7
+
8
+ # ChangeLog's module methods can be called in both models and controllers.
9
+ module ChangeLog
10
+
11
+ # Switches ChangeLog on or off.
12
+ def self.enabled=(value)
13
+ ChangeLog.config.enabled = value
14
+ end
15
+
16
+ # Returns `true` if ChangeLog is on, `false` otherwise.
17
+ # ChangeLog is enabled by default.
18
+ def self.enabled?
19
+ !!ChangeLog.config.enabled
20
+ end
21
+
22
+ # Returns who is reponsible for any changes that occur.
23
+ def self.whodidit
24
+ change_log_store[:whodidit]
25
+ end
26
+
27
+ # Sets who is responsible for any changes that occur.
28
+ # In a controller it automatically get the value from `current_user` action.
29
+ def self.whodidit=(value)
30
+ change_log_store[:whodidit] = value
31
+ end
32
+
33
+
34
+ private
35
+ # Thread-safe hash to hold ChangeLog's data.
36
+ def self.change_log_store
37
+ Thread.current[:change_log] ||= {}
38
+ end
39
+
40
+ # Returns ChangeLog's configuration object.
41
+ def self.config
42
+ @@config ||= ChangeLog::Config.instance
43
+ end
44
+
45
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: change_log
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Peter Zhang
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-18 00:00:00 +13:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: A gem to keep all maintenance logs
36
+ email:
37
+ - peterz@ncs.co.nz
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - Rakefile
48
+ - change_log.gemspec
49
+ - lib/change_log.rb
50
+ - lib/change_log/version.rb
51
+ has_rdoc: true
52
+ homepage: http://www.ncs.co.nz
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project: change_log
81
+ rubygems_version: 1.3.7
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Change log gem record every changes for the model
85
+ test_files: []
86
+