Rfizzy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "redis"
5
+ # Add dependencies to develop your gem here.
6
+ # Include everything needed to run rake, tests, features, etc.
7
+ group :development do
8
+ gem "rspec", "~> 2.6.0"
9
+ gem "yard", "~> 0.6.0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ gem "autotest"
14
+ gem "syntax"
15
+ gem "reek", "~> 1.2.8"
16
+ end
@@ -0,0 +1,49 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ZenTest (4.5.0)
5
+ autotest (4.4.6)
6
+ ZenTest (>= 4.4.1)
7
+ diff-lcs (1.1.2)
8
+ git (1.2.5)
9
+ jeweler (1.6.4)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ rake (0.9.2)
14
+ rcov (0.9.9)
15
+ redis (2.2.1)
16
+ reek (1.2.8)
17
+ ruby2ruby (~> 1.2)
18
+ ruby_parser (~> 2.0)
19
+ sexp_processor (~> 3.0)
20
+ rspec (2.6.0)
21
+ rspec-core (~> 2.6.0)
22
+ rspec-expectations (~> 2.6.0)
23
+ rspec-mocks (~> 2.6.0)
24
+ rspec-core (2.6.4)
25
+ rspec-expectations (2.6.0)
26
+ diff-lcs (~> 1.1.2)
27
+ rspec-mocks (2.6.0)
28
+ ruby2ruby (1.2.5)
29
+ ruby_parser (~> 2.0)
30
+ sexp_processor (~> 3.0)
31
+ ruby_parser (2.0.6)
32
+ sexp_processor (~> 3.0)
33
+ sexp_processor (3.0.5)
34
+ syntax (1.0.0)
35
+ yard (0.6.8)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ autotest
42
+ bundler (~> 1.0.0)
43
+ jeweler (~> 1.6.4)
44
+ rcov
45
+ redis
46
+ reek (~> 1.2.8)
47
+ rspec (~> 2.6.0)
48
+ syntax
49
+ yard (~> 0.6.0)
@@ -0,0 +1,7 @@
1
+ Copyright © 2011 Seifvan Heifdari af Awesomeness Von Cheeseburger
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. By reading this fine print your soul is now the exclusive property of Seivan Heidari Productions and its Subsidiaries. Unauthorized use of seivan gems, images, materials, souls, odors and oxygen is strongly discouraged. We know where you sleep. Also, your mum & bring back prop8
@@ -0,0 +1,75 @@
1
+ = Rfizzy http://travis-ci.org/seivan/Rfizzy.png
2
+
3
+ A ruby library utilizing Redis for;
4
+ * Full text search engine with Redis.
5
+ * Taggingging library
6
+ * Social Graph with friends, followers, followees and etc. (not in 0.1.0, gotta pick your battles )
7
+
8
+ ### Key Features
9
+ # * Very unobtrusiv
10
+ # * Very easy to add to a project
11
+ # * Very easy to remove from a project
12
+ # * Small memory foot print,
13
+ # * very tiny code base compared to other libraries and in contrast to what it adds to a project
14
+ # * Fast
15
+ # * No learning curve
16
+ # * Works with any ORMs out of the box...
17
+ # * ... Since it's not attached to any of ORMs
18
+ # ***
19
+
20
+
21
+
22
+ Works in all Ruby projects, regardless of ORM as long as an attribute has a way to identify it (e.g ID column).
23
+ Very simple built, source code is < 100 loc and has full test coverage.
24
+ Easy to tap into any project without high learning curve or code breakage. Easy to remove as well.
25
+ VERY unobtrusive.
26
+
27
+ == Introduction
28
+ class Tweet < ActiveRecord::Base
29
+ after_create :create_search_index
30
+ before_destroy :destroy_search_index
31
+
32
+ private
33
+ def create_search_index
34
+ FullTextSearch.create_index :attribute_namespace => :tweet_text_content,
35
+ :document_id => id,
36
+ :words => text_content
37
+
38
+ end
39
+
40
+ def destroy_search_index
41
+ FullTextSearch.destroy_index :attribute_namespace => :tweet_text_content,
42
+ :document_id => id,
43
+ :words => text_content
44
+
45
+ end
46
+ end
47
+
48
+
49
+ set_of_ids = FullTextSearch.search_index :attribute_namespace => :article_text,
50
+ :search => text_content
51
+
52
+ Article.where(:id => set_of_ids)
53
+
54
+ == Contributing to Rfizzy
55
+
56
+ * Make sure you got Redis running locally on standard port
57
+ * Make sure you can have up to 10 databases with redis, since the test suite uses db 10
58
+ * Check out the latest develop to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
59
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
60
+ * Fork the project
61
+ * Start a feature/my_feature or hotfix/ branch
62
+ * Commit and push until you are happy with your contribution
63
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
64
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
65
+
66
+ == Copyright
67
+
68
+ Copyright © 2011 Seifvan Heifdari af Awesomeness Von Cheeseburger
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. By not reading this fine print your soul is now the exclusive property of Seivan Heidari Productions and its Subsidiaries. Unauthorized use of Seivans code, images, materials, souls, odors and oxygen is strongly discouraged. We know where you sleep. Also, I might have banged your mums pool boy. Sorry about that.
75
+
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "Rfizzy"
18
+ gem.homepage = "http://github.com/seivan/Rfizzy"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Full text search engine with Redis. Works in all Ruby projects}
21
+ gem.description = %Q{Full text search engine with Redis. Works in all Ruby projects. Very simple built, source code is < 300loc including tests. Was built because it's cheaper to go with the 20mb Redis solution with redis than using PostgreSQL's full text search. Also I needed background jobs and might as well use Resque for that.}
22
+ gem.email = "seivan@kth.se"
23
+ gem.authors = ["Seivan Heidari"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'reek/rake/task'
29
+ Reek::Rake::Task.new do |t|
30
+ t.fail_on_error = true
31
+ t.verbose = false
32
+ t.source_files = 'lib/**/*.rb'
33
+ end
34
+
35
+ require 'rspec/core'
36
+ require 'rspec/core/rake_task'
37
+ RSpec::Core::RakeTask.new(:spec) do |spec|
38
+ spec.pattern = FileList['spec/**/*_spec.rb']
39
+ end
40
+
41
+
42
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
43
+ spec.pattern = 'spec/**/*_spec.rb'
44
+ spec.rcov = true
45
+ spec.rspec_opts = ["--color", "--format", "documentation", "--tag"]
46
+ end
47
+
48
+ task :default => :spec
49
+
50
+ require 'yard'
51
+ YARD::Rake::YardocTask.new
@@ -0,0 +1,92 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{Rfizzy}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Seivan Heidari"]
12
+ s.date = %q{2011-07-18}
13
+ s.description = %q{Full text search engine with Redis. Works in all Ruby projects. Very simple built, source code is < 300loc including tests. Was built because it's cheaper to go with the 20mb Redis solution with redis than using PostgreSQL's full text search. Also I needed background jobs and might as well use Resque for that.}
14
+ s.email = %q{seivan@kth.se}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "Rfizzy.gemspec",
28
+ "VERSION",
29
+ "docs/FullTextSearch.html",
30
+ "docs/Tagging.html",
31
+ "docs/docco.css",
32
+ "docs/installation_and_setup.html",
33
+ "example_usage/FullTextSearch.rb",
34
+ "example_usage/Tagging.rb",
35
+ "example_usage/installation_and_setup.rb",
36
+ "lib/Rfizzy.rb",
37
+ "spec/.DS_Store",
38
+ "spec/initialization/rfizzy_searching_initialize_spec.rb",
39
+ "spec/searching/.DS_Store",
40
+ "spec/searching/rfizzy_searching_create_spec.rb",
41
+ "spec/searching/rfizzy_searching_destroy_spec.rb",
42
+ "spec/searching/rfizzy_searching_search_spec.rb",
43
+ "spec/spec_helper.rb",
44
+ "spec/support/.DS_Store",
45
+ "spec/support/Factories/search_factories.rb",
46
+ "spec/support/Factories/tagging_factories.rb",
47
+ "spec/tagging/rfizzy_tagging_create_spec.rb",
48
+ "spec/tagging/rfizzy_tagging_search_spec.rb"
49
+ ]
50
+ s.homepage = %q{http://github.com/seivan/Rfizzy}
51
+ s.licenses = ["MIT"]
52
+ s.require_paths = ["lib"]
53
+ s.rubygems_version = %q{1.6.2}
54
+ s.summary = %q{Full text search engine with Redis. Works in all Ruby projects}
55
+
56
+ if s.respond_to? :specification_version then
57
+ s.specification_version = 3
58
+
59
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
+ s.add_runtime_dependency(%q<redis>, [">= 0"])
61
+ s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
62
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
63
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
65
+ s.add_development_dependency(%q<rcov>, [">= 0"])
66
+ s.add_development_dependency(%q<autotest>, [">= 0"])
67
+ s.add_development_dependency(%q<syntax>, [">= 0"])
68
+ s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
69
+ else
70
+ s.add_dependency(%q<redis>, [">= 0"])
71
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
72
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
73
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
74
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
75
+ s.add_dependency(%q<rcov>, [">= 0"])
76
+ s.add_dependency(%q<autotest>, [">= 0"])
77
+ s.add_dependency(%q<syntax>, [">= 0"])
78
+ s.add_dependency(%q<reek>, ["~> 1.2.8"])
79
+ end
80
+ else
81
+ s.add_dependency(%q<redis>, [">= 0"])
82
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
83
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
84
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
85
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
86
+ s.add_dependency(%q<rcov>, [">= 0"])
87
+ s.add_dependency(%q<autotest>, [">= 0"])
88
+ s.add_dependency(%q<syntax>, [">= 0"])
89
+ s.add_dependency(%q<reek>, ["~> 1.2.8"])
90
+ end
91
+ end
92
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html> <html> <head> <title>FullTextSearch.rb</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="FullTextSearch.html"> FullTextSearch.rb </a> <a class="source" href="Tagging.html"> Tagging.rb </a> <a class="source" href="installation_and_setup.html"> installation_and_setup.rb </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> FullTextSearch.rb </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <h2>Full Text Searching</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>We are using an ActiveRecord model here.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nc">Tweet</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
2
+ </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>With it's complimentary callbacks</p> </td> <td class="code"> <div class="highlight"><pre> <span class="n">after_create</span> <span class="ss">:create_search_index</span>
3
+ <span class="n">before_destroy</span> <span class="ss">:destroy_search_index</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>But you can just as well use any other orm that gives it's documents/tables unique identifiers (id's)</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kp">private</span>
4
+ <span class="k">def</span> <span class="nf">create_search_index</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>So we set the namespace we want the searching to be on by setting it's name :tweet<em>text</em>content
5
+ We pass the tweets id to it so we can find it
6
+ And we pass the tweets text_content, so we can match our search</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">FullTextSearch</span><span class="o">.</span><span class="n">create_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:tweet_text_content</span><span class="p">,</span>
7
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span>
8
+
9
+ <span class="k">end</span>
10
+
11
+ <span class="k">def</span> <span class="nf">destroy_search_index</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Same applies here to as to create, except we are removing the records indices
12
+ No need to pass the words here, just what records index to remove</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">FullTextSearch</span><span class="o">.</span><span class="n">destroy_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:tweet_text_content</span><span class="p">,</span>
13
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span>
14
+
15
+ <span class="k">end</span>
16
+ <span class="k">end</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Now you can search through your indices easily
17
+ By passing what namespace you want to search on with the words you are searching with</p> </td> <td class="code"> <div class="highlight"><pre><span class="n">set_of_ids</span> <span class="o">=</span> <span class="no">FullTextSearch</span><span class="o">.</span><span class="n">search_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:tweet_text_content</span><span class="p">,</span>
18
+ <span class="ss">:search</span> <span class="o">=&gt;</span> <span class="s2">&quot;jquery mobile&quot;</span>
19
+ </pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>And no matter if you're using Mongoid, ActiveRecord or DataMapper, you can now query the ID's.</p> </td> <td class="code"> <div class="highlight"><pre><span class="no">Article</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="ss">:id</span> <span class="o">=&gt;</span> <span class="n">set_of_ids</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h2>Association</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Now lets assume we want to limit to who can search what by setting an association</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">def</span> <span class="nf">create_search_index</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>Notice the assoction on the tweets user.id</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">FullTextSearch</span><span class="o">.</span><span class="n">create_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:tweet_text_content</span><span class="p">,</span>
20
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span><span class="p">,</span>
21
+ <span class="ss">:words</span> <span class="o">=&gt;</span> <span class="n">text_content</span><span class="p">,</span>
22
+ <span class="ss">:association</span> <span class="o">=&gt;</span> <span class="n">user</span><span class="o">.</span><span class="n">id</span>
23
+
24
+ <span class="k">end</span>
25
+
26
+ <span class="k">def</span> <span class="nf">destroy_search_index</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Same concept applies here as well</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">FullTextSearch</span><span class="o">.</span><span class="n">destroy_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:tweet_text_content</span><span class="p">,</span>
27
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span><span class="p">,</span>
28
+ <span class="ss">:association</span> <span class="o">=&gt;</span> <span class="n">user</span><span class="o">.</span><span class="n">id</span><span class="p">,</span>
29
+
30
+ <span class="k">end</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>And when the current_user searches he will only find on his own associated tweets</p> </td> <td class="code"> <div class="highlight"><pre><span class="n">set_of_ids</span> <span class="o">=</span> <span class="no">FullTextSearch</span><span class="o">.</span><span class="n">search_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:tweet_text_content</span><span class="p">,</span>
31
+ <span class="ss">:search</span> <span class="o">=&gt;</span> <span class="s2">&quot;jQuery map&quot;</span><span class="p">,</span>
32
+ <span class="ss">:association</span> <span class="o">=&gt;</span> <span class="n">current_user</span><span class="o">.</span><span class="n">id</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <h2>But wait! ... there's more</h2>
33
+
34
+ <h3>What can I do with this?</h3>
35
+
36
+ <ul>
37
+ <li><p><a href="https://github.com/fabrik42/acts_as_api/wiki/">Tagging - find posts through tagging, find tags through posts</a></p></li>
38
+ <li><p><a href="https://github.com/fabrik42/acts_as_api/wiki/Calling-a-method-of-the-model">Full text search -through association or attributes</a></p></li>
39
+ <li><p>Social Graph, friends, followers, followees</p></li>
40
+ </ul>
41
+
42
+ <p>You can find more advanced examples by using the "Jumper" placed at the upper right corner</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <h2>Links</h2>
43
+
44
+ <ul>
45
+ <li><a href="https://github.com/seivan/Rfizzy">Check out the source code on Github</a></li>
46
+ <li><a href="https://github.com/seivan/Rfizzy/issues">Found a bug or do you have a feature request?</a></li>
47
+ <li><a href="http://travis-ci.org/seivan/Rfizzy">Continues build and testing status</a></li>
48
+ </ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
@@ -0,0 +1,49 @@
1
+ <!DOCTYPE html> <html> <head> <title>Tagging.rb</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="FullTextSearch.html"> FullTextSearch.rb </a> <a class="source" href="Tagging.html"> Tagging.rb </a> <a class="source" href="installation_and_setup.html"> installation_and_setup.rb </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> Tagging.rb </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <h2>Tagging</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>We are using an ActiveRecord model here.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nc">Article</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
2
+ </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>With it's complimentary callbacks</p> </td> <td class="code"> <div class="highlight"><pre> <span class="n">after_create</span> <span class="ss">:create_search_index</span>
3
+ <span class="n">before_destroy</span> <span class="ss">:destroy_search_index</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>But you can just as well use any other orm that gives it's documents/tables unique identifiers (id's)</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kp">private</span>
4
+ <span class="k">def</span> <span class="nf">create_search_index</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>So we set the namespace we want the searching to be on by setting it's name :article_tags
5
+ We pass the article's id to it so we can find it
6
+ And we pass the articles tags as an array
7
+ Naturally the tags can just be a virtual attribute as an array of tags when posting the article</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">TaggyMcFaggy</span><span class="o">.</span><span class="n">create_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:article_tags</span><span class="p">,</span>
8
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span><span class="p">,</span>
9
+ <span class="ss">:words</span> <span class="o">=&gt;</span> <span class="n">tags</span>
10
+
11
+ <span class="k">end</span>
12
+
13
+ <span class="k">def</span> <span class="nf">destroy_search_index</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Same concept applies here, except we don't care about the tags themselves.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">TaggyMcFaggy</span><span class="o">.</span><span class="n">destroy_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:article_text</span><span class="p">,</span>
14
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span>
15
+
16
+ <span class="k">end</span>
17
+ <span class="k">end</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Pass in an array of tags, or a single tag as a text</p> </td> <td class="code"> <div class="highlight"><pre><span class="n">set_of_ids</span> <span class="o">=</span> <span class="no">TaggyMcFaggy</span><span class="o">.</span><span class="n">search_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:article_text</span><span class="p">,</span>
18
+ <span class="ss">:search</span> <span class="o">=&gt;</span> <span class="s2">&quot;food&quot;</span>
19
+ </pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>And no matter if you're using Mongoid, ActiveRecord or DataMapper, you can now query the ID's.</p> </td> <td class="code"> <div class="highlight"><pre><span class="no">Article</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="ss">:id</span> <span class="o">=&gt;</span> <span class="n">set_of_ids</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Now lets assume we want to limit to who can search what by setting an association</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">def</span> <span class="nf">create_search_index</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>Notice the assoction on article.user.id</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">TaggyMcFaggy</span><span class="o">.</span><span class="n">create_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:article_text</span><span class="p">,</span>
20
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span><span class="p">,</span>
21
+ <span class="ss">:words</span> <span class="o">=&gt;</span> <span class="n">text_content</span><span class="p">,</span>
22
+ <span class="ss">:association</span> <span class="o">=&gt;</span> <span class="n">user</span><span class="o">.</span><span class="n">id</span>
23
+
24
+ <span class="k">end</span>
25
+
26
+ <span class="k">def</span> <span class="nf">destroy_search_index</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Same concept applies here, except we really do not care about the tags when deleting</p> </td> <td class="code"> <div class="highlight"><pre> <span class="no">TaggyMcFaggy</span><span class="o">.</span><span class="n">destroy_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:article_text</span><span class="p">,</span>
27
+ <span class="ss">:document_id</span> <span class="o">=&gt;</span> <span class="nb">id</span><span class="p">,</span>
28
+ <span class="ss">:association</span> <span class="o">=&gt;</span> <span class="n">user</span><span class="o">.</span><span class="n">id</span><span class="p">,</span>
29
+
30
+ <span class="k">end</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>And when the current_user searches he will only find on his own associated tweets</p> </td> <td class="code"> <div class="highlight"><pre><span class="n">set_of_ids</span> <span class="o">=</span> <span class="no">TaggyMcFaggy</span><span class="o">.</span><span class="n">search_index</span> <span class="ss">:attribute_namespace</span> <span class="o">=&gt;</span> <span class="ss">:article_text</span><span class="p">,</span>
31
+ <span class="ss">:association</span> <span class="o">=&gt;</span> <span class="n">current_user</span><span class="o">.</span><span class="n">id</span><span class="p">,</span>
32
+ <span class="ss">:search</span> <span class="o">=&gt;</span> <span class="o">[</span><span class="s2">&quot;Food&quot;</span><span class="p">,</span> <span class="s2">&quot;gaming&quot;</span><span class="p">,</span> <span class="s2">&quot;Balls&quot;</span><span class="o">]</span>
33
+ </pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <h2>But wait! ... there's more</h2>
34
+
35
+ <h3>What can I do with this?</h3>
36
+
37
+ <ul>
38
+ <li><p><a href="https://github.com/fabrik42/acts_as_api/wiki/">Tagging - find posts through tagging, find tags through posts</a></p></li>
39
+ <li><p><a href="https://github.com/fabrik42/acts_as_api/wiki/Calling-a-method-of-the-model">Full text search -through association or attributes</a></p></li>
40
+ <li><p>Social Graph, friends, followers, followees</p></li>
41
+ </ul>
42
+
43
+ <p>You can find more advanced examples by using the "Jumper" placed at the upper right corner</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <h2>Links</h2>
44
+
45
+ <ul>
46
+ <li><a href="https://github.com/seivan/Rfizzy">Check out the source code on Github</a></li>
47
+ <li><a href="https://github.com/seivan/Rfizzy/issues">Found a bug or do you have a feature request?</a></li>
48
+ <li><a href="http://travis-ci.org/seivan/Rfizzy">Continues build and testing status</a></li>
49
+ </ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
@@ -0,0 +1,186 @@
1
+ /*--------------------- Layout and Typography ----------------------------*/
2
+ body {
3
+ font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
4
+ font-size: 15px;
5
+ line-height: 22px;
6
+ color: #252519;
7
+ margin: 0; padding: 0;
8
+ }
9
+ a {
10
+ color: #261a3b;
11
+ }
12
+ a:visited {
13
+ color: #261a3b;
14
+ }
15
+ p {
16
+ margin: 0 0 15px 0;
17
+ }
18
+ h1, h2, h3, h4, h5, h6 {
19
+ margin: 0px 0 15px 0;
20
+ }
21
+ h1 {
22
+ margin-top: 40px;
23
+ }
24
+ #container {
25
+ position: relative;
26
+ }
27
+ #background {
28
+ position: fixed;
29
+ top: 0; left: 525px; right: 0; bottom: 0;
30
+ background: #f5f5ff;
31
+ border-left: 1px solid #e5e5ee;
32
+ z-index: -1;
33
+ }
34
+ #jump_to, #jump_page {
35
+ background: white;
36
+ -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
37
+ -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
38
+ font: 10px Arial;
39
+ text-transform: uppercase;
40
+ cursor: pointer;
41
+ text-align: right;
42
+ }
43
+ #jump_to, #jump_wrapper {
44
+ position: fixed;
45
+ right: 0; top: 0;
46
+ padding: 5px 10px;
47
+ }
48
+ #jump_wrapper {
49
+ padding: 0;
50
+ display: none;
51
+ }
52
+ #jump_to:hover #jump_wrapper {
53
+ display: block;
54
+ }
55
+ #jump_page {
56
+ padding: 5px 0 3px;
57
+ margin: 0 0 25px 25px;
58
+ }
59
+ #jump_page .source {
60
+ display: block;
61
+ padding: 5px 10px;
62
+ text-decoration: none;
63
+ border-top: 1px solid #eee;
64
+ }
65
+ #jump_page .source:hover {
66
+ background: #f5f5ff;
67
+ }
68
+ #jump_page .source:first-child {
69
+ }
70
+ table td {
71
+ border: 0;
72
+ outline: 0;
73
+ }
74
+ td.docs, th.docs {
75
+ max-width: 450px;
76
+ min-width: 450px;
77
+ min-height: 5px;
78
+ padding: 10px 25px 1px 50px;
79
+ overflow-x: hidden;
80
+ vertical-align: top;
81
+ text-align: left;
82
+ }
83
+ .docs pre {
84
+ margin: 15px 0 15px;
85
+ padding-left: 15px;
86
+ }
87
+ .docs p tt, .docs p code {
88
+ background: #f8f8ff;
89
+ border: 1px solid #dedede;
90
+ font-size: 12px;
91
+ padding: 0 0.2em;
92
+ }
93
+ .pilwrap {
94
+ position: relative;
95
+ }
96
+ .pilcrow {
97
+ font: 12px Arial;
98
+ text-decoration: none;
99
+ color: #454545;
100
+ position: absolute;
101
+ top: 3px; left: -20px;
102
+ padding: 1px 2px;
103
+ opacity: 0;
104
+ -webkit-transition: opacity 0.2s linear;
105
+ }
106
+ td.docs:hover .pilcrow {
107
+ opacity: 1;
108
+ }
109
+ td.code, th.code {
110
+ padding: 14px 15px 16px 25px;
111
+ width: 100%;
112
+ vertical-align: top;
113
+ background: #f5f5ff;
114
+ border-left: 1px solid #e5e5ee;
115
+ }
116
+ pre, tt, code {
117
+ font-size: 12px; line-height: 18px;
118
+ font-family: Monaco, Consolas, "Lucida Console", monospace;
119
+ margin: 0; padding: 0;
120
+ }
121
+
122
+
123
+ /*---------------------- Syntax Highlighting -----------------------------*/
124
+ td.linenos { background-color: #f0f0f0; padding-right: 10px; }
125
+ span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
126
+ body .hll { background-color: #ffffcc }
127
+ body .c { color: #408080; font-style: italic } /* Comment */
128
+ body .err { border: 1px solid #FF0000 } /* Error */
129
+ body .k { color: #954121 } /* Keyword */
130
+ body .o { color: #666666 } /* Operator */
131
+ body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
132
+ body .cp { color: #BC7A00 } /* Comment.Preproc */
133
+ body .c1 { color: #408080; font-style: italic } /* Comment.Single */
134
+ body .cs { color: #408080; font-style: italic } /* Comment.Special */
135
+ body .gd { color: #A00000 } /* Generic.Deleted */
136
+ body .ge { font-style: italic } /* Generic.Emph */
137
+ body .gr { color: #FF0000 } /* Generic.Error */
138
+ body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
139
+ body .gi { color: #00A000 } /* Generic.Inserted */
140
+ body .go { color: #808080 } /* Generic.Output */
141
+ body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
142
+ body .gs { font-weight: bold } /* Generic.Strong */
143
+ body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
144
+ body .gt { color: #0040D0 } /* Generic.Traceback */
145
+ body .kc { color: #954121 } /* Keyword.Constant */
146
+ body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
147
+ body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
148
+ body .kp { color: #954121 } /* Keyword.Pseudo */
149
+ body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
150
+ body .kt { color: #B00040 } /* Keyword.Type */
151
+ body .m { color: #666666 } /* Literal.Number */
152
+ body .s { color: #219161 } /* Literal.String */
153
+ body .na { color: #7D9029 } /* Name.Attribute */
154
+ body .nb { color: #954121 } /* Name.Builtin */
155
+ body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
156
+ body .no { color: #880000 } /* Name.Constant */
157
+ body .nd { color: #AA22FF } /* Name.Decorator */
158
+ body .ni { color: #999999; font-weight: bold } /* Name.Entity */
159
+ body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
160
+ body .nf { color: #0000FF } /* Name.Function */
161
+ body .nl { color: #A0A000 } /* Name.Label */
162
+ body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
163
+ body .nt { color: #954121; font-weight: bold } /* Name.Tag */
164
+ body .nv { color: #19469D } /* Name.Variable */
165
+ body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
166
+ body .w { color: #bbbbbb } /* Text.Whitespace */
167
+ body .mf { color: #666666 } /* Literal.Number.Float */
168
+ body .mh { color: #666666 } /* Literal.Number.Hex */
169
+ body .mi { color: #666666 } /* Literal.Number.Integer */
170
+ body .mo { color: #666666 } /* Literal.Number.Oct */
171
+ body .sb { color: #219161 } /* Literal.String.Backtick */
172
+ body .sc { color: #219161 } /* Literal.String.Char */
173
+ body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
174
+ body .s2 { color: #219161 } /* Literal.String.Double */
175
+ body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
176
+ body .sh { color: #219161 } /* Literal.String.Heredoc */
177
+ body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
178
+ body .sx { color: #954121 } /* Literal.String.Other */
179
+ body .sr { color: #BB6688 } /* Literal.String.Regex */
180
+ body .s1 { color: #219161 } /* Literal.String.Single */
181
+ body .ss { color: #19469D } /* Literal.String.Symbol */
182
+ body .bp { color: #954121 } /* Name.Builtin.Pseudo */
183
+ body .vc { color: #19469D } /* Name.Variable.Class */
184
+ body .vg { color: #19469D } /* Name.Variable.Global */
185
+ body .vi { color: #19469D } /* Name.Variable.Instance */
186
+ body .il { color: #666666 } /* Literal.Number.Integer.Long */