giraffesoft-timeline_fu 0.2.0 → 0.3.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.
- data/.gitignore +1 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +1 -1
- data/Rakefile +36 -0
- data/VERSION.yml +2 -2
- data/init.rb +1 -0
- data/lib/timeline_fu/fires.rb +7 -0
- data/shoulda_macros/timeline_fu_shoulda.rb +11 -0
- data/test/fires_test.rb +5 -2
- data/test/test_helper.rb +2 -2
- data/timeline_fu.gemspec +55 -0
- metadata +13 -10
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 James Golick
|
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
CHANGED
@@ -37,7 +37,7 @@ You can supply a few parameters to fires, two of them are mandatory.
|
|
37
37
|
The rest all fit neatly in an options hash.
|
38
38
|
|
39
39
|
- :on => [ActiveRecord event]
|
40
|
-
- mandatory. You use it to specify whether you want the event created after a create, update or destroy.
|
40
|
+
- mandatory. You use it to specify whether you want the event created after a create, update or destroy. You can also supply an array of events, e.g. [:create, :update].
|
41
41
|
- :actor is your way of specifying who took this action.
|
42
42
|
- In the example, post.author is going to be this person.
|
43
43
|
- :subject is automatically set to self, which is good most of the time. You can however override it if you need to, using :subject.
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the timeline_fu plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |s|
|
18
|
+
s.name = "timeline_fu"
|
19
|
+
s.summary = %Q{Easily build timelines, much like GitHub's news feed}
|
20
|
+
s.email = "james@giraffesoft.ca"
|
21
|
+
s.homepage = "http://github.com/giraffesoft/timeline_fu"
|
22
|
+
s.description = "Easily build timelines, much like GitHub's news feed"
|
23
|
+
s.authors = ["James Golick", "Mathieu Martin", "Francois Beausoleil"]
|
24
|
+
end
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Generate documentation for the timeline_fu plugin.'
|
30
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
31
|
+
rdoc.rdoc_dir = 'rdoc'
|
32
|
+
rdoc.title = 'TimelineFu'
|
33
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
34
|
+
rdoc.rdoc_files.include('README*')
|
35
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
36
|
+
end
|
data/VERSION.yml
CHANGED
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'timeline_fu'
|
data/lib/timeline_fu/fires.rb
CHANGED
@@ -7,6 +7,13 @@ module TimelineFu
|
|
7
7
|
module ClassMethods
|
8
8
|
def fires(event_type, opts)
|
9
9
|
raise ArgumentError, "Argument :on is mandatory" unless opts.has_key?(:on)
|
10
|
+
|
11
|
+
# Array provided, set multiple callbacks
|
12
|
+
if opts[:on].kind_of?(Array)
|
13
|
+
opts[:on].each { |on| fires(event_type, opts.merge({:on => on})) }
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
10
17
|
opts[:subject] = :self unless opts.has_key?(:subject)
|
11
18
|
|
12
19
|
method_name = :"fire_#{event_type}_after_#{opts[:on]}"
|
data/test/fires_test.rb
CHANGED
@@ -8,7 +8,10 @@ class FiresTest < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
def test_should_fire_the_appropriate_callback
|
10
10
|
@list = List.new(hash_for_list(:author => @james));
|
11
|
-
TimelineEvent.expects(:create!).with(:actor => @james, :subject => @list, :event_type => '
|
11
|
+
TimelineEvent.expects(:create!).with(:actor => @james, :subject => @list, :event_type => 'list_created_or_updated')
|
12
|
+
@list.save
|
13
|
+
TimelineEvent.expects(:create!).with(:actor => @mat, :subject => @list, :event_type => 'list_created_or_updated')
|
14
|
+
@list.author = @mat
|
12
15
|
@list.save
|
13
16
|
end
|
14
17
|
|
@@ -61,7 +64,7 @@ class FiresTest < Test::Unit::TestCase
|
|
61
64
|
|
62
65
|
def test_should_set_secondary_subject_to_self_when_requested
|
63
66
|
@list = List.new(hash_for_list(:author => @james));
|
64
|
-
TimelineEvent.stubs(:create!).with(has_entry(:event_type, "
|
67
|
+
TimelineEvent.stubs(:create!).with(has_entry(:event_type, "list_created_or_updated"))
|
65
68
|
@list.save
|
66
69
|
@comment = Comment.new(:body => 'cool list!', :author => @mat, :list => @list)
|
67
70
|
TimelineEvent.stubs(:create!).with(has_entry(:event_type, "comment_created"))
|
data/test/test_helper.rb
CHANGED
@@ -47,8 +47,8 @@ class List < ActiveRecord::Base
|
|
47
47
|
belongs_to :author, :class_name => "Person"
|
48
48
|
has_many :comments
|
49
49
|
|
50
|
-
fires :
|
51
|
-
|
50
|
+
fires :list_created_or_updated, :actor => :author,
|
51
|
+
:on => [:create, :update]
|
52
52
|
end
|
53
53
|
|
54
54
|
class Comment < ActiveRecord::Base
|
data/timeline_fu.gemspec
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{timeline_fu}
|
5
|
+
s.version = "0.3.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["James Golick", "Mathieu Martin", "Francois Beausoleil"]
|
9
|
+
s.date = %q{2009-06-26}
|
10
|
+
s.description = %q{Easily build timelines, much like GitHub's news feed}
|
11
|
+
s.email = %q{james@giraffesoft.ca}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"MIT-LICENSE",
|
18
|
+
"README.rdoc",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION.yml",
|
21
|
+
"generators/timeline_fu/USAGE",
|
22
|
+
"generators/timeline_fu/templates/migration.rb",
|
23
|
+
"generators/timeline_fu/templates/model.rb",
|
24
|
+
"generators/timeline_fu/timeline_fu_generator.rb",
|
25
|
+
"init.rb",
|
26
|
+
"lib/timeline_fu.rb",
|
27
|
+
"lib/timeline_fu/fires.rb",
|
28
|
+
"lib/timeline_fu/macros.rb",
|
29
|
+
"lib/timeline_fu/matchers.rb",
|
30
|
+
"shoulda_macros/timeline_fu_shoulda.rb",
|
31
|
+
"test/fires_test.rb",
|
32
|
+
"test/test_helper.rb",
|
33
|
+
"timeline_fu.gemspec"
|
34
|
+
]
|
35
|
+
s.has_rdoc = true
|
36
|
+
s.homepage = %q{http://github.com/giraffesoft/timeline_fu}
|
37
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.3.1}
|
40
|
+
s.summary = %q{Easily build timelines, much like GitHub's news feed}
|
41
|
+
s.test_files = [
|
42
|
+
"test/fires_test.rb",
|
43
|
+
"test/test_helper.rb"
|
44
|
+
]
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
48
|
+
s.specification_version = 2
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
51
|
+
else
|
52
|
+
end
|
53
|
+
else
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giraffesoft-timeline_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Golick
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-
|
14
|
+
date: 2009-06-26 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -24,26 +24,28 @@ extensions: []
|
|
24
24
|
extra_rdoc_files:
|
25
25
|
- README.rdoc
|
26
26
|
files:
|
27
|
+
- .gitignore
|
28
|
+
- MIT-LICENSE
|
27
29
|
- README.rdoc
|
30
|
+
- Rakefile
|
28
31
|
- VERSION.yml
|
29
|
-
- generators/timeline_fu
|
30
|
-
- generators/timeline_fu/templates
|
32
|
+
- generators/timeline_fu/USAGE
|
31
33
|
- generators/timeline_fu/templates/migration.rb
|
32
34
|
- generators/timeline_fu/templates/model.rb
|
33
35
|
- generators/timeline_fu/timeline_fu_generator.rb
|
34
|
-
-
|
35
|
-
- lib/timeline_fu
|
36
|
+
- init.rb
|
37
|
+
- lib/timeline_fu.rb
|
36
38
|
- lib/timeline_fu/fires.rb
|
37
39
|
- lib/timeline_fu/macros.rb
|
38
40
|
- lib/timeline_fu/matchers.rb
|
39
|
-
-
|
41
|
+
- shoulda_macros/timeline_fu_shoulda.rb
|
40
42
|
- test/fires_test.rb
|
41
43
|
- test/test_helper.rb
|
44
|
+
- timeline_fu.gemspec
|
42
45
|
has_rdoc: true
|
43
46
|
homepage: http://github.com/giraffesoft/timeline_fu
|
44
47
|
post_install_message:
|
45
48
|
rdoc_options:
|
46
|
-
- --inline-source
|
47
49
|
- --charset=UTF-8
|
48
50
|
require_paths:
|
49
51
|
- lib
|
@@ -66,5 +68,6 @@ rubygems_version: 1.2.0
|
|
66
68
|
signing_key:
|
67
69
|
specification_version: 2
|
68
70
|
summary: Easily build timelines, much like GitHub's news feed
|
69
|
-
test_files:
|
70
|
-
|
71
|
+
test_files:
|
72
|
+
- test/fires_test.rb
|
73
|
+
- test/test_helper.rb
|