-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start testing! with some refactoring
- Loading branch information
Showing
8 changed files
with
92 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
guard :rspec, cmd: "bundle exec rspec" do | ||
require "guard/rspec/dsl" | ||
dsl = Guard::RSpec::Dsl.new(self) | ||
|
||
# RSpec files | ||
rspec = dsl.rspec | ||
watch(rspec.spec_helper) { rspec.spec_dir } | ||
watch(rspec.spec_support) { rspec.spec_dir } | ||
watch(rspec.spec_files) | ||
|
||
# Ruby files | ||
ruby = dsl.ruby | ||
dsl.watch_spec_files_for(ruby.lib_files) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,6 @@ | ||
require "searchyou/version" | ||
require "net/http" | ||
require "json" | ||
|
||
module Jekyll | ||
require "jekyll/plugin" | ||
require "jekyll/generator" | ||
|
||
class SearchyouIndexer < Jekyll::Generator | ||
safe true | ||
priority :lowest | ||
|
||
def generate(site) | ||
|
||
indexer = Searchyou::Indexer.new(site) | ||
indexer.run! | ||
|
||
site.posts.docs.each do |doc| | ||
indexer << doc.data.merge({ | ||
id: doc.basename_without_ext, | ||
content: doc.content | ||
}) | ||
end | ||
|
||
indexer.done! | ||
end | ||
end | ||
|
||
end | ||
require "searchyou/generator" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'searchyou/indexer' | ||
|
||
module Searchyou | ||
|
||
class Generator < Jekyll::Generator | ||
safe true | ||
priority :lowest | ||
|
||
def self.elasticsearch_url(site) | ||
ENV['ELASTICSEARCH_URL'] || | ||
ENV['BONSAI_URL'] || | ||
site.config['elasticsearch']['url'] | ||
end | ||
|
||
def generate(site) | ||
url = self.class.elasticsearch_url(site) | ||
indexer = Searchyou::Indexer.new(site) | ||
indexer.start | ||
|
||
site.posts.docs.each do |doc| | ||
indexer << doc.data.merge({ | ||
id: doc.basename_without_ext, | ||
content: doc.content | ||
}) | ||
end | ||
|
||
indexer.finish | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require File.expand_path('../spec_helper', File.dirname(__FILE__)) | ||
|
||
describe Searchyou::Generator do | ||
|
||
it 'is a Jekyll Generator' do | ||
expect(Searchyou::Generator.new).to be_a(Jekyll::Generator) | ||
end | ||
|
||
let(:jekyll_site) do | ||
double( | ||
'jekyll site', | ||
config: { 'elasticsearch' => { 'url' => 'http://localhost:9200' }} | ||
) | ||
end | ||
|
||
# TODO: integrated site generation | ||
it 'can generate an index' do | ||
g = Searchyou::Generator.new | ||
g.generate(jekyll_site) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require File.expand_path('../spec_helper', File.dirname(__FILE__)) | ||
|
||
describe Searchyou::Indexer do | ||
|
||
it 'is instantiated with an Elasticsearch URL' do | ||
expect { Searchyou::Indexer.new }.to raise_error(ArgumentError) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
require 'spec_helper' | ||
|
||
describe Searchyou do | ||
|
||
it 'has a version number' do | ||
expect(Searchyou::VERSION).not_to be nil | ||
end | ||
|
||
it 'does something useful' do | ||
expect(false).to eq(true) | ||
end | ||
end |