Skip to content

Commit

Permalink
initial gem structure
Browse files Browse the repository at this point in the history
  • Loading branch information
marianposaceanu committed Jul 8, 2013
0 parents commit bd8dc72
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.gem
*.swp
*.lock
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
11 changes: 11 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source 'https://rubygems.org'

gemspec

gem 'murmurhash3'

group :test do
gem 'factory_girl'
gem 'rspec'
gem 'guard-rspec'
end
11 changes: 11 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
end

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Search redux

A simpler wrapper around [murmurhash3](https://github.com/funny-falcon/murmurhash3-ruby) gem with a nicer API.

## Requirements

Murmur redux requires at least Ruby >= 1.9.2

## Installation

Include the gem in your Gemfile:

```ruby
gem 'murmur_redux'
```

## Quick start

By default it uses MurmurHash3_x86_128 which is a nice combination of low latency and with good collision resistence.

```ruby
class MyClass
hex_string = MurmurRedux::Hash.digest('test')
end
```

## License (MIT)

Copyright (c) 2013 Marian Posaceanu

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.

27 changes: 27 additions & 0 deletions lib/murmur_redux.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'search_redux/version'
require 'search_redux/errors'
require 'search_redux/helpers'
require 'search_redux/glue'
require 'search_redux/searchable'
require 'search_redux/rdbms/mysql'
require 'search_redux/rdbms/postgres'

require 'search_redux/railtie'

module SearchRedux
extend Helpers

module ClassMethods
def act_as_searchable(options = {})
attr_accessor :searchable

@searchable = SearchRedux::Searchable.new options
end

def text_search(query)
raise(Errors::ActAsSearchableUnintialized, 'Use act_as_searchable') unless @searchable

@searchable.full_text_search(query, self)
end
end
end
7 changes: 7 additions & 0 deletions lib/murmur_redux/errors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module MurmurRedux
class Error < StandardError; end

module Errors
class NotFound < MurmurRedux::Error; end
end
end
Empty file added lib/murmur_redux/hash.rb
Empty file.
3 changes: 3 additions & 0 deletions lib/murmur_redux/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module MurmurRedux
VERSION = '0.0.1' unless defined? MurmurRedux::VERSION
end
19 changes: 19 additions & 0 deletions murmur_redux.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
require 'murmur_redux/version'

Gem::Specification.new do |s|
s.name = 'murmur_redux'
s.version = MurmurRedux::VERSION
s.platform = Gem::Platform::RUBY
s.summary = 'A simpler wrapper around murmurhash3 gem with a nicer API.'
s.author = 'Marian Posaceanu'
s.email = '[email protected]'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ['lib']
s.homepage = 'https://github.com/dakull/murmur_redux'

s.required_ruby_version = '>= 1.9.2'

s.add_dependency('murmurhash3', '~> 0.1.3')
end
17 changes: 17 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
end

0 comments on commit bd8dc72

Please sign in to comment.