honesty 0.0.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +65 -0
- data/init.rb +1 -0
- data/install.rb +2 -0
- data/lib/fact.rb +7 -0
- data/lib/generators/honesty/USAGE +6 -0
- data/lib/generators/honesty/honesty_generator.rb +18 -0
- data/lib/generators/honesty/templates/create_facts.rb +18 -0
- data/lib/generators/honesty/templates/fact.rb +10 -0
- data/lib/honesty.rb +15 -38
- data/lib/version.rb +3 -0
- metadata +31 -24
- data/.gitignore +0 -4
- data/Gemfile +0 -4
- data/Rakefile +0 -1
- data/honesty.gemspec +0 -25
- data/lib/honesty/version.rb +0 -3
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Tim Boisvert
|
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.rdoc
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
Honesty
|
2
|
+
=================
|
3
|
+
|
4
|
+
Honesty allows developers to store and track user activities and system events in
|
5
|
+
a human-readable, easily-searchable format.
|
6
|
+
|
7
|
+
== Resources
|
8
|
+
|
9
|
+
Install
|
10
|
+
|
11
|
+
* gem install honesty
|
12
|
+
* If using bundler:
|
13
|
+
** Add "gem 'honesty'" to your Gemfile
|
14
|
+
** "bundle install"
|
15
|
+
|
16
|
+
|
17
|
+
Generate the model:
|
18
|
+
|
19
|
+
** Rails 3: rails g honesty
|
20
|
+
** Rails 2: script/generate honesty
|
21
|
+
|
22
|
+
Migrate:
|
23
|
+
** rake db:migrate
|
24
|
+
|
25
|
+
== Usage
|
26
|
+
|
27
|
+
* use Honesty in your ActiveRecord model.
|
28
|
+
|
29
|
+
class Shoe < ActiveRecord::Base
|
30
|
+
honesty
|
31
|
+
end
|
32
|
+
|
33
|
+
* Add a fact to a model instance
|
34
|
+
|
35
|
+
Parameters:
|
36
|
+
* Context - the object being acted on or the entity being tracked.
|
37
|
+
* Agent - the actor, so to speak.
|
38
|
+
* Action - the action taking place.
|
39
|
+
|
40
|
+
shoe = Shoe.create
|
41
|
+
shoe.fact("Shoe", "Tim Boisvert", "Created Adidas Superstar II")
|
42
|
+
|
43
|
+
* If you want to short-cut the fact and use the object's class name as the context:
|
44
|
+
|
45
|
+
shoe = Shoe.create
|
46
|
+
shoe.fact("Tim Boisvert", "Created Adidas Superstar II")
|
47
|
+
|
48
|
+
In this case the context would've been set to the class name of the object calling it -- in this case, Shoe
|
49
|
+
|
50
|
+
* Get facts:
|
51
|
+
|
52
|
+
shoe = Shoe.find(1)
|
53
|
+
facts = shoe.facts.all
|
54
|
+
|
55
|
+
== Credits
|
56
|
+
|
57
|
+
This plugin is heavily influenced by Acts As Taggable. Thanks to Jack Dempsey et al.
|
58
|
+
|
59
|
+
== Contributors
|
60
|
+
|
61
|
+
Tim Boisvert
|
62
|
+
|
63
|
+
== More
|
64
|
+
|
65
|
+
http://github.com/timboisvert/honesty
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'rails', 'init')
|
data/install.rb
ADDED
data/lib/fact.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
class HonestyGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@source_root ||= File.expand_path("../templates", __FILE__)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.next_migration_number(path)
|
11
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_model_file
|
15
|
+
template "fact.rb", "app/models/fact.rb"
|
16
|
+
migration_template "create_facts.rb", "db/migrate/create_facts.rb"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateFacts < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :facts do |t|
|
4
|
+
t.string :context, :limit => 40
|
5
|
+
t.string :agent
|
6
|
+
t.string :action
|
7
|
+
t.references :honest, :polymorphic => true
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :facts, :honest_type
|
12
|
+
add_index :facts, :honest_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :facts
|
17
|
+
end
|
18
|
+
end
|
data/lib/honesty.rb
CHANGED
@@ -1,51 +1,28 @@
|
|
1
|
-
require "honesty/version"
|
2
1
|
require 'active_record'
|
3
2
|
|
4
|
-
#
|
5
|
-
module
|
6
|
-
module ActiveRecord::Acts::Honesty
|
3
|
+
# Honesty
|
4
|
+
module Honesty
|
7
5
|
|
8
6
|
def self.included(base)
|
9
|
-
base.extend ClassMethods
|
7
|
+
base.extend ClassMethods
|
10
8
|
end
|
11
|
-
|
9
|
+
|
12
10
|
module ClassMethods
|
13
11
|
def honesty
|
14
|
-
has_many :
|
15
|
-
include
|
12
|
+
has_many :facts, {:as => :honest, :dependent => :destroy}
|
13
|
+
include Honesty::InstanceMethods
|
16
14
|
end
|
17
15
|
end
|
18
|
-
|
16
|
+
|
19
17
|
module InstanceMethods
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# Helper methods
|
29
|
-
def truths_by_context
|
30
|
-
Truth.find(:all,
|
31
|
-
:conditions => ["context = ?", self.class.context],
|
32
|
-
:order => "created_at DESC"
|
33
|
-
)
|
34
|
-
end
|
35
|
-
def truths_by_agent
|
36
|
-
Truth.find(:all,
|
37
|
-
:conditions => ["agent = ?", self.class.agent],
|
38
|
-
:order => "created_at DESC"
|
39
|
-
)
|
40
|
-
end
|
41
|
-
def truths_by_action
|
42
|
-
Truth.find(:all,
|
43
|
-
:conditions => ["action = ?", self.class.action],
|
44
|
-
:order => "created_at DESC"
|
45
|
-
)
|
46
|
-
end
|
18
|
+
def fact(*params)
|
19
|
+
if params.length == 3
|
20
|
+
self.facts.create(:context => params[0], :agent => params[1], :action => params[2])
|
21
|
+
elsif params.length == 2
|
22
|
+
self.facts.create(:context => self.class.name, :agent => params[0], :action => params[1])
|
23
|
+
end
|
24
|
+
end
|
47
25
|
end
|
48
|
-
|
49
26
|
end
|
50
27
|
|
51
|
-
ActiveRecord::Base.send(:include,
|
28
|
+
ActiveRecord::Base.send(:include, Honesty)
|
data/lib/version.rb
ADDED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honesty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tim Boisvert
|
9
|
-
autorequire:
|
9
|
+
autorequire: honesty
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-24 00:00:00.
|
12
|
+
date: 2012-01-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &14777840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14777840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sqlite3
|
27
|
-
requirement: &
|
27
|
+
requirement: &14777140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,33 +32,39 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *14777140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &14776420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *14776420
|
47
47
|
description: Store and track user activities and system events in a human-readable,
|
48
|
-
easily-searchable format
|
49
|
-
email:
|
50
|
-
- boisvert@gmail.com
|
48
|
+
easily-searchable format
|
49
|
+
email: boisvert@gmail.com
|
51
50
|
executables: []
|
52
51
|
extensions: []
|
53
|
-
extra_rdoc_files:
|
52
|
+
extra_rdoc_files:
|
53
|
+
- README.rdoc
|
54
|
+
- MIT-LICENSE
|
54
55
|
files:
|
55
|
-
-
|
56
|
-
-
|
57
|
-
- Rakefile
|
58
|
-
- honesty.gemspec
|
56
|
+
- MIT-LICENSE
|
57
|
+
- README.rdoc
|
59
58
|
- lib/honesty.rb
|
60
|
-
- lib/
|
61
|
-
|
59
|
+
- lib/fact.rb
|
60
|
+
- lib/version.rb
|
61
|
+
- lib/generators/honesty/honesty_generator.rb
|
62
|
+
- lib/generators/honesty/templates/fact.rb
|
63
|
+
- lib/generators/honesty/templates/create_facts.rb
|
64
|
+
- lib/generators/honesty/USAGE
|
65
|
+
- init.rb
|
66
|
+
- install.rb
|
67
|
+
homepage: http://github.com/timboisvert/honesty
|
62
68
|
licenses: []
|
63
69
|
post_install_message:
|
64
70
|
rdoc_options: []
|
@@ -77,9 +83,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
83
|
- !ruby/object:Gem::Version
|
78
84
|
version: '0'
|
79
85
|
requirements: []
|
80
|
-
rubyforge_project:
|
81
|
-
rubygems_version: 1.8.
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.10
|
82
88
|
signing_key:
|
83
89
|
specification_version: 3
|
84
|
-
summary: Store and track
|
90
|
+
summary: Store and track user activities and system events in a human-readable, easily-searchable
|
91
|
+
format
|
85
92
|
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/honesty.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "honesty/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "honesty"
|
7
|
-
s.version = Honesty::VERSION
|
8
|
-
s.authors = ["Tim Boisvert"]
|
9
|
-
s.email = ["boisvert@gmail.com"]
|
10
|
-
s.homepage = ""
|
11
|
-
s.summary = %q{Store and track human-readable user activities and system events}
|
12
|
-
s.description = %q{Store and track user activities and system events in a human-readable, easily-searchable format.}
|
13
|
-
|
14
|
-
s.rubyforge_project = "honesty"
|
15
|
-
|
16
|
-
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = ["lib"]
|
20
|
-
|
21
|
-
# specify any dependencies here; for example:
|
22
|
-
s.add_development_dependency 'rspec'
|
23
|
-
s.add_development_dependency 'sqlite3'
|
24
|
-
s.add_dependency 'rails', '~> 3.0'
|
25
|
-
end
|
data/lib/honesty/version.rb
DELETED