Permalink
Browse files

package as gem changing open file way

including this patch:
chebyte@86dee3c
f7163d7a42eeb2d
  • Loading branch information...
1 parent 41ebfbf commit 3f77a1ae34d7d40fa7f9bffc9b2e12e8c4d99f72 @zheileman committed Nov 24, 2011
Showing with 134 additions and 24 deletions.
  1. +20 −0 LICENSE
  2. +32 −22 README.rdoc
  3. +25 −0 Rakefile
  4. +1 −0 VERSION
  5. +1 −2 lib/sunspot/rich_document.rb
  6. +55 −0 sunspot_cell.gemspec
View
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Zheileman
+
+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:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+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.
View
@@ -1,12 +1,21 @@
= Sunspot Cell
-This plugin adds Cell support (for indexing rich documents) to Sunspot (developed against Sunspot 1.2.1).
+== Note by Zheileman
+
+* This gem exists because the only gem I could find for the original project (https://github.com/springbok/sunspot_cell) was the one packaged by Kevin Motschiedler (https://github.com/motske/sunspot_cell) and it lacks the support to deal with S3 included in this other fork: https://github.com/chebyte/sunspot_cell
+I've included other paths as well, and bugfixes I found useful from other forks.
+
+
+This gem adds Cell support (for indexing rich documents like pdf, docs, html, etc...) to Sunspot (developed against Sunspot 1.2.1).
+Support Paperclip and S3 Storage
The code is based on the patch included here:
http://outoftime.lighthouseapp.com/projects/20339/tickets/98-solr-cell
== Requirements
+* Sunspot gem installed
+
* Solr Cell libraries (+dist/apache-solr-cell-1.4.X.jar+ and +contrib/extraction/lib/*.jar+ from the standard Solr distribution) placed in the +/solr/lib+ directory as created by the Sunspot gem, in development environment. Your production setup might vary.
* Adjustments to the Solr +schema.xml+:
@@ -18,33 +27,34 @@ and
<dynamicField name="*_attachment" stored="true" type="text" multiValued="true" indexed="true"/>
<dynamicField name="ignored_*" type="ignored"/>
-== Note
+=== Install Plugin
-This version assumes the attachment attribute has method +.data+, that returns contents of the attachment.
+Add sunspot gem and sunspot_cell to Gemfile:
+
+ gem 'sunspot_rails', '~> 1.2.1'
+ gem 'sunspot_cell', :git => 'git://github.com/zheileman/sunspot_cell.git'
== Usage
-In your searchable block within your model add the document content attribute as an "attachment" type:
-
- searchable do
- attachment :document_attachment
- ...
+ class Doc
+ searchable do
+ text :title
+ attachment :file
+ end
end
-The plugin will expect a method to be defined that matches the name of the attachment attribute in our example it would be "document_attachment", e.g.
+== Paperclip & S3 Storage
- def document_attachment
- File.read(fname) # Reading contents from a file, you can also supply the contents direct from a DB field
- end
-
-== Todo
+ require 'open-uri'
-* Tests
+ class Doc
+ searchable do
+ text :title
+ attachment :attached_file
+ end
-== Note on Patches/Pull Requests
-
-* Fork the project.
-* Make your feature addition or bug fix.
-* Add tests for it. This is important so I don't break it in a future version unintentionally.
-* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-* Send me a pull request. Bonus points for topic branches.
+ private
+ def attached_file
+ URI.parse(remote_full_url)
+ end
+ end
View
@@ -0,0 +1,25 @@
+require 'rubygems'
+require 'rake'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+begin
+ require 'rspec'
+ require 'rspec/core/rake_task'
+ desc 'Run the unit tests'
+ RSpec::Core::RakeTask.new(:test)
+rescue LoadError
+ task :test do
+ STDERR.puts "You must have rspec 2.0 installed to run the tests"
+ end
+end
+
+desc 'Generate documentation.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.options << '--title' << 'Sunspot Cell support' << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
View
@@ -0,0 +1 @@
+0.1.1
@@ -23,8 +23,7 @@ def add(connection)
@fields.each do |f|
if f.name.to_s.include?("_attachment") and f.value.present?
- # It is assumed that f.value contains the document data NOT a link to a file
- data = f.value
+ data = open(f.value).read rescue ""
params['fmap.content'] = f.name
else
param_name = "literal.#{f.name.to_s}"
View
@@ -0,0 +1,55 @@
+Gem::Specification.new do |s|
+ s.name = %q{sunspot_cell}
+ s.version = "0.1.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Zheileman"]
+ s.date = %q{2011-24-11}
+ s.description = %q{This gem adds Cell support (for indexing rich documents) to Sunspot}
+ s.email = %q{zheileman@gmail.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION",
+ "init.rb",
+ "lib/sunspot/rich_document.rb",
+ "lib/sunspot_cell.rb",
+ "lib/sunspot_cell/attribute_field.rb",
+ "lib/sunspot_cell/composite_setup.rb",
+ "lib/sunspot_cell/dsl/fields.rb",
+ "lib/sunspot_cell/dsl/standard_query.rb",
+ "lib/sunspot_cell/field_factory.rb",
+ "lib/sunspot_cell/indexer.rb",
+ "lib/sunspot_cell/setup.rb",
+ "lib/sunspot_cell/type.rb"
+ ]
+ s.homepage = %q{https://github.com/zheileman/sunspot_cell}
+ s.rdoc_options = ["--charset=UTF-8", "--main", "README.rdoc", "LICENSE"]
+ s.licenses = ["MIT"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.7.2}
+ s.summary = %q{This gem adds Cell support (for indexing rich documents) to Sunspot}
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<sunspot>, [">= 1.2.1"])
+ s.add_development_dependency(%q<activerecord>, [">= 2.2"])
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
+ else
+ s.add_dependency(%q<sunspot>, [">= 1.2.1"])
+ s.add_dependency(%q<activerecord>, [">= 2.2"])
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
+ end
+ else
+ s.add_dependency(%q<sunspot>, [">= 1.2.1"])
+ s.add_dependency(%q<activerecord>, [">= 2.2"])
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
+ end
+end

0 comments on commit 3f77a1a

Please sign in to comment.