synaptic 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +0 -0
- data/README +0 -0
- data/lib/active_record/extensions.rb +28 -0
- data/lib/synaptic.rb +2 -0
- data/lib/synaptic/neuron.rb +19 -0
- data/lib/version.rb +7 -0
- data/synaptic.gemspec +30 -0
- metadata +76 -0
data/LICENSE
ADDED
File without changes
|
data/README
ADDED
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Synaptic
|
2
|
+
module ActiveRecord
|
3
|
+
module Extensions
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.extend( ClassMethods )
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def neuron options={}
|
12
|
+
neurons[self.model_name] = Synaptic::Neuron.new( self, options )
|
13
|
+
end
|
14
|
+
|
15
|
+
def neurons
|
16
|
+
@@neurons ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def synapsed?
|
20
|
+
!!neurons[self.model_name]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ActiveRecord::Base.send(:include, Synaptic::ActiveRecord::Extensions)
|
data/lib/synaptic.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Synaptic
|
2
|
+
class Neuron
|
3
|
+
def initialize model, options
|
4
|
+
@model = model
|
5
|
+
|
6
|
+
@white_list = options[:only] || []
|
7
|
+
@black_list = options[:except] || []
|
8
|
+
end
|
9
|
+
|
10
|
+
def synapses
|
11
|
+
@synapses ||= begin
|
12
|
+
synapses = @model.reflect_on_all_associations
|
13
|
+
synapses.select!{ |x| @white_list.include?( x.name ) } unless @white_list.empty?
|
14
|
+
synapses.reject!{ |x| @black_list.include?( x.name ) } unless @black_list.empty?
|
15
|
+
synapses
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/version.rb
ADDED
data/synaptic.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require './lib/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "synaptic"
|
9
|
+
s.version = Synaptic::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ["Christian Blais", "Thierry Joyal"]
|
12
|
+
s.email = ["christ.blais@gmail.com", "thierry.joyal@gmail.com"]
|
13
|
+
s.homepage = "http://github.com/christianblais/synaptic"
|
14
|
+
s.summary = "Synaptic reporting tool for ActiveRecord"
|
15
|
+
s.description = "Synaptic reporting tool for ActiveRecord"
|
16
|
+
|
17
|
+
s.add_dependency 'activerecord', '>=3.0.0'
|
18
|
+
|
19
|
+
s.files = [
|
20
|
+
'LICENSE',
|
21
|
+
'README',
|
22
|
+
'synaptic.gemspec',
|
23
|
+
'lib/synaptic.rb',
|
24
|
+
'lib/version.rb',
|
25
|
+
'lib/active_record/extensions.rb',
|
26
|
+
'lib/synaptic/neuron.rb'
|
27
|
+
]
|
28
|
+
|
29
|
+
s.require_paths = ['lib', 'test']
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: synaptic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christian Blais
|
9
|
+
- Thierry Joyal
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-06-10 00:00:00 -04:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: activerecord
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 3.0.0
|
26
|
+
type: :runtime
|
27
|
+
version_requirements: *id001
|
28
|
+
description: Synaptic reporting tool for ActiveRecord
|
29
|
+
email:
|
30
|
+
- christ.blais@gmail.com
|
31
|
+
- thierry.joyal@gmail.com
|
32
|
+
executables: []
|
33
|
+
|
34
|
+
extensions: []
|
35
|
+
|
36
|
+
extra_rdoc_files: []
|
37
|
+
|
38
|
+
files:
|
39
|
+
- LICENSE
|
40
|
+
- README
|
41
|
+
- synaptic.gemspec
|
42
|
+
- lib/synaptic.rb
|
43
|
+
- lib/version.rb
|
44
|
+
- lib/active_record/extensions.rb
|
45
|
+
- lib/synaptic/neuron.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://github.com/christianblais/synaptic
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
- test
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.6.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Synaptic reporting tool for ActiveRecord
|
75
|
+
test_files: []
|
76
|
+
|