safai 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/safai/fires.rb +27 -29
  2. data/lib/safai.rb +11 -11
  3. data/safai.gemspec +5 -7
  4. metadata +4 -4
data/lib/safai/fires.rb CHANGED
@@ -1,39 +1,37 @@
1
+ module Fires
2
+ def self.included(klass)
3
+ klass.send(:extend, ClassMethods)
4
+ end
1
5
 
2
- module Fires
3
- def self.included(klass)
4
- klass.send(:extend, ClassMethods)
5
- end
6
-
7
- module ClassMethods
8
- def fires(event_type, opts)
9
- raise ArgumentError, "Argument :on is mandatory" unless opts.has_key?(:on)
6
+ module ClassMethods
7
+ def fires(event_type, opts)
8
+ raise ArgumentError, "Argument :on is mandatory" unless opts.has_key?(:on)
10
9
 
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
10
+ # Array provided, set multiple callbacks
11
+ if opts[:on].kind_of?(Array)
12
+ opts[:on].each { |on| fires(event_type, opts.merge({:on => on})) }
13
+ return
14
+ end
16
15
 
17
- opts[:subject] = :self unless opts.has_key?(:subject)
16
+ opts[:subject] = :self unless opts.has_key?(:subject)
18
17
 
19
- send(:"after_#{opts[:on]}", :if => opts[:if]) do
20
- create_options = [:actor, :subject, :secondary_subject, :link, :message].inject({}) do |memo, sym|
21
- if opts[sym]
22
- if opts[sym].respond_to?(:call)
23
- memo[sym] = opts[sym].call(self)
24
- elsif opts[sym] == :self
25
- memo[sym] = self
26
- else
27
- memo[sym] = send(opts[sym])
28
- end
18
+ send(:"after_#{opts[:on]}", :if => opts[:if]) do
19
+ create_options = [:actor, :subject, :secondary_subject, :link, :message].inject({}) do |memo, sym|
20
+ if opts[sym]
21
+ if opts[sym].respond_to?(:call)
22
+ memo[sym] = opts[sym].call(self)
23
+ elsif opts[sym] == :self
24
+ memo[sym] = self
25
+ else
26
+ memo[sym] = send(opts[sym])
29
27
  end
30
- memo
31
28
  end
32
- create_options[:event_type] = event_type.to_s
33
-
34
- TimelineEvent.create!(create_options)
29
+ memo
35
30
  end
31
+ create_options[:event_type] = event_type.to_s
32
+
33
+ TimelineEvent.create!(create_options)
36
34
  end
37
35
  end
38
36
  end
39
-
37
+ end
data/lib/safai.rb CHANGED
@@ -1,13 +1,3 @@
1
- class Safai
2
-
3
- module Fires
4
- end
5
-
6
- module Helpers
7
- end
8
-
9
- end
10
-
11
1
  require 'money'
12
2
  require 'roo'
13
3
  require 'safai/spreadsheet'
@@ -20,4 +10,14 @@ require 'safai/date'
20
10
  require 'safai/fires'
21
11
  require 'safai/helpers'
22
12
  ActiveRecord::Base.send :include, Safai::Fires
23
- ActionView::Base.send :include, Safai::Helpers
13
+ ActionView::Base.send :include, Safai::Helpers
14
+
15
+ class Safai
16
+
17
+ module Fires
18
+ end
19
+
20
+ module Helpers
21
+ end
22
+
23
+ end
data/safai.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'safai'
3
- s.version = '0.0.22'
3
+ s.version = '0.0.23'
4
4
  s.date = '2010-04-28'
5
- s.summary = "Address logic gem"
6
- s.description = "A simple hello world gem"
5
+ s.summary = "Commonly used functions"
6
+ s.description = "Clean up (Safai) of code"
7
7
  s.authors = ["Ritvvij Parrikh"]
8
8
  s.email = 'ritvij.j@gmail.com'
9
9
  s.files = ["lib/safai.rb",
@@ -19,11 +19,9 @@ Gem::Specification.new do |s|
19
19
  "generators/safai/templates/model.rb",
20
20
  "generators/safai/safai_generator.rb",
21
21
  "lib/safai/fires.rb",
22
- #"lib/safai/macros.rb",
23
- "safai.gemspec"#,
24
- #"lib/safai/matchers.rb"
22
+ "safai.gemspec"
25
23
  ]
26
- s.homepage = 'http://rubygems.org/gems/safai'
24
+ s.homepage = 'http://github.com/ritvvijparrikh/safai'
27
25
  s.required_rubygems_version = '>= 1.3.6'
28
26
  s.add_development_dependency("carmen", '0.2.13')
29
27
  s.add_development_dependency("htmldiff", '0.0.1')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -91,7 +91,7 @@ dependencies:
91
91
  - - '='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 4.2.9
94
- description: A simple hello world gem
94
+ description: Clean up (Safai) of code
95
95
  email: ritvij.j@gmail.com
96
96
  executables: []
97
97
  extensions: []
@@ -111,7 +111,7 @@ files:
111
111
  - generators/safai/safai_generator.rb
112
112
  - lib/safai/fires.rb
113
113
  - safai.gemspec
114
- homepage: http://rubygems.org/gems/safai
114
+ homepage: http://github.com/ritvvijparrikh/safai
115
115
  licenses: []
116
116
  post_install_message:
117
117
  rdoc_options: []
@@ -134,5 +134,5 @@ rubyforge_project:
134
134
  rubygems_version: 1.8.24
135
135
  signing_key:
136
136
  specification_version: 3
137
- summary: Address logic gem
137
+ summary: Commonly used functions
138
138
  test_files: []