soulheart 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +55 -18
- data/lib/soulheart/config.rb +6 -1
- data/lib/soulheart/loader.rb +3 -3
- data/lib/soulheart/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7614d5a25688e37c96f1934f0e431048603771d
|
4
|
+
data.tar.gz: 7bede6c0cd14ddb287636f8194d641eb1842625c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6380d4fa61e9101397e254afc09b4fe8b765f396728f2b68ad358224bf6ac09f36dad401c0079cf0dc7b28bccd22b4ab0a1c2fa9bc0e7f7868aa47a7d16714eb
|
7
|
+
data.tar.gz: 5c1700b08f56ef30e12fdef6520f1d5b89641b2e6480a2489edb75ba67b8b6e786b15f9ff20f2a63dccca12766db6981253ecc15ba0854fed6f7ea5e5cb13da9
|
data/README.md
CHANGED
@@ -1,34 +1,71 @@
|
|
1
1
|
# <img src="https://raw.githubusercontent.com/sethherr/soulheart/master/logo.png" alt="Soulheart" width="200"> Soulheart [](https://travis-ci.org/sethherr/soulheart) [](https://codeclimate.com/github/sethherr/soulheart) [](https://codeclimate.com/github/sethherr/soulheart/coverage)
|
2
2
|
|
3
|
-
|
3
|
+
Soulheart is a ready-to-use remote data source for autocomplete. The goal is to provide a solid, flexible tool that's downright simple to set up.
|
4
4
|
|
5
|
-
|
5
|
+
- [Demos](https://sethherr.github.io/soulheart/)
|
6
|
+
- [Usage documentation](https://sethherr.github.io/soulheart/commands/)
|
7
|
+
- [Example data sources](https://github.com/sethherr/soulheart/tree/master/example_data_sources)
|
8
|
+
- [Getting started](#getting-started)
|
9
|
+
- [Deployment](#deployment)
|
10
|
+
- [Testing](#testing)
|
6
11
|
|
7
|
-
- pagination
|
8
|
-
- categories
|
9
|
-
- sorting by priority (not just alphabetically)
|
10
|
-
- arbitrary return values/objects
|
11
|
-
- loading data via gists (or any url)
|
12
|
-
- mounting standalone or inside of a rails app
|
13
12
|
|
14
|
-
|
13
|
+
## Features
|
15
14
|
|
15
|
+
- **Pagination**
|
16
|
+
<br>For infinite scrolling of results - wow!
|
17
|
+
- **Categories**
|
18
|
+
<br>Match results for specified categories, or not - your choice.
|
19
|
+
- **Prioritization**
|
20
|
+
<br>Return results sorted by priority (not just alphabetically).
|
21
|
+
- **Arbitrary return objects**
|
22
|
+
<br>Get whatever you want back. IDs, URLs, image links, even pre-formatted HTML :boom:
|
23
|
+
- **Load remote data**
|
24
|
+
<br>Makes loading data via gists (or any url) possible.
|
25
|
+
- **Runs Standalone or inside a rails app**
|
16
26
|
|
17
|
-
|
27
|
+
## Getting started
|
18
28
|
|
19
|
-
|
29
|
+
See the [Soulheart demos page](https://sethherr.github.io/soulheart/) for a step-by-step explanation of creating an instance and setting up a select box that uses it as a remote data source.
|
20
30
|
|
21
|
-
I'm testing with: `ruby 2.1` and `redis 3.0`.
|
22
31
|
|
23
|
-
|
32
|
+
## Deployment
|
24
33
|
|
25
|
-
|
34
|
+
#### With Heroku [](https://heroku.com/deploy)
|
26
35
|
|
27
|
-
|
36
|
+
You can instantly deploy Soulheart to Heroku for free - just click the button - which deploys this repository using `rackup` to start the server. Because of this, there's a `config.ru` and a `Gemfile.lock`—to make it (and any forks) runnable on Heroku. These files aren't in the Gem.
|
28
37
|
|
29
|
-
|
38
|
+
To update your Heroku deploy of Soulheart, use the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-command) and redeploy the app:
|
39
|
+
|
40
|
+
heroku deploy -a NAME_OF_YOUR_APP_ON_HEROKU
|
41
|
+
|
30
42
|
|
31
|
-
|
43
|
+
#### In a Rails app
|
32
44
|
|
45
|
+
Soulheart is also a gem. Add it to your gemfile:
|
33
46
|
|
34
|
-
|
47
|
+
gem 'soulheart'
|
48
|
+
|
49
|
+
And then put this in your routes.rb -
|
50
|
+
|
51
|
+
require 'sidekiq/web'
|
52
|
+
mount Soulheart::Server => "/soulhearts"
|
53
|
+
|
54
|
+
You can then access the server when your rails app is running. You can run the [Soulheart commands](https://sethherr.github.io/soulheart/commands/) from that directory.
|
55
|
+
|
56
|
+
## Testing
|
57
|
+
|
58
|
+
Tested with rspec, check out test information at [Code Climate](https://codeclimate.com/github/sethherr/soulheart).
|
59
|
+
|
60
|
+
Run `bundle exec guard` to watch for changes and rerun the tests when files are saved.
|
61
|
+
|
62
|
+
|
63
|
+
## Requirements
|
64
|
+
|
65
|
+
Soulheart is a Redis backed Sinatra server. I test with the latest MRI (2.2, 2.1, 2.0) and JRuby versions (1.7). Other versions/VMs are untested but might work fine.
|
66
|
+
|
67
|
+
It requires Redis 3.0
|
68
|
+
|
69
|
+
## Additional info
|
70
|
+
|
71
|
+
This started as a fork of [Soulmate](https://github.com/seatgeek/soulmate). It's MIT licensed.
|
data/lib/soulheart/config.rb
CHANGED
@@ -19,12 +19,17 @@ module Soulheart
|
|
19
19
|
redis
|
20
20
|
end
|
21
21
|
|
22
|
+
def jruby?
|
23
|
+
RUBY_ENGINE == 'jruby'
|
24
|
+
end
|
25
|
+
|
22
26
|
# Returns the current Redis connection. If none has been created, will
|
23
27
|
# create a new one.
|
24
28
|
def redis
|
25
29
|
@redis ||= (
|
26
30
|
url = URI(@redis_url || ENV['REDIS_URL'] || 'redis://127.0.0.1:6379/0')
|
27
|
-
::Redis.new( #
|
31
|
+
::Redis.new( #
|
32
|
+
driver: (jruby? ? :ruby : :hiredis),
|
28
33
|
host: url.host,
|
29
34
|
port: url.port,
|
30
35
|
db: url.path[1..-1],
|
data/lib/soulheart/loader.rb
CHANGED
@@ -49,7 +49,7 @@ module Soulheart
|
|
49
49
|
redis.del(results_hashes_id)
|
50
50
|
end
|
51
51
|
|
52
|
-
def clear(remove_results
|
52
|
+
def clear(remove_results=false)
|
53
53
|
category_combos.each {|cat| delete_data(category_id(cat)) }
|
54
54
|
delete_categories
|
55
55
|
delete_data
|
@@ -62,7 +62,7 @@ module Soulheart
|
|
62
62
|
set_category_combos_array.each do |category_combo|
|
63
63
|
items.each do |item|
|
64
64
|
next unless category_combo.match(item['category']) || category_combo == 'all'
|
65
|
-
add_item(item, category_id(category_combo),
|
65
|
+
add_item(item, category_id(category_combo), true) # send it base
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -75,7 +75,7 @@ module Soulheart
|
|
75
75
|
.merge item
|
76
76
|
end
|
77
77
|
|
78
|
-
def add_item(item, category_base_id
|
78
|
+
def add_item(item, category_base_id=nil, cleaned=false)
|
79
79
|
unless cleaned
|
80
80
|
item = clean(item)
|
81
81
|
category_base_id ||= category_id(item['category'])
|
data/lib/soulheart/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soulheart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Herr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hiredis
|