penumbra 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b43f7c5f99dad02ff0fef204f56a4693e36b9be3
4
+ data.tar.gz: 09f2bcf947ec8087251efcad6424016568df3688
5
+ SHA512:
6
+ metadata.gz: df1c3026c73e5016329c2d74875e2b5c218deb6cdd807c60ba69f8a233b1927dd981f5193483254ea985ed0c8cc4828cada22c76a9b30b812c739797c2c0393d
7
+ data.tar.gz: 6902d341911b48fe815ede04fb8d80cd548ee3f8504e95095172d0cde3a32f63792e7d32fbbc1401d83466e2a8df888e214e2d656031fc40ca35ce00a51b1324
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ *.swp
10
+ *~
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ penumbra
@@ -0,0 +1 @@
1
+ 2.2.2
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in penumbra.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Dennis Walters
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Penumbra
2
+
3
+ Just a shadow of sunspot/solr/whathave you. Creates JSON-stored Indexes,
4
+ possibly collected into Catalogs. Really, it's just a bunch of hashes.
5
+ Hashes all the way down! Hashes, I say!
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'penumbra'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install penumbra
22
+
23
+ ## Usage
24
+
25
+
26
+ ## Development
27
+
28
+ ## Contributing
29
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "penumbra"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ require 'penumbra/version'
2
+ require 'penumbra/catalog'
3
+ require 'penumbra/index'
4
+
5
+ module Penumbra
6
+ def self.catalog(path)
7
+ Catalog.new(path)
8
+ end
9
+
10
+ def self.index(path)
11
+ Index.new(path)
12
+ end
13
+ end
@@ -0,0 +1,69 @@
1
+ require 'penumbra/index'
2
+
3
+ module Penumbra
4
+ class Catalog
5
+ attr_reader :path
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ end
10
+
11
+ def [](index_name)
12
+ index_for(index_name)
13
+ end
14
+
15
+ def indexes
16
+ @indexes ||= {}
17
+ end
18
+
19
+ def index_for(index_name)
20
+ index_name = index_name.to_s
21
+ indexes[index_name] ||= Index.new(File.join(path, index_name))
22
+ end
23
+
24
+ def put(index_name, key, value)
25
+ index_for(index_name).put(key, value)
26
+ end
27
+
28
+ def get(index_name, key)
29
+ index_for(index_name).get(key)
30
+ end
31
+
32
+ def keys_for(index_name)
33
+ index_for(index_name).keys
34
+ end
35
+
36
+ def values_for(index_name)
37
+ index_for(index_name).values
38
+ end
39
+
40
+ def open
41
+ create_path
42
+ @opened = true
43
+ end
44
+
45
+ def close
46
+ raise NotOpenError unless open?
47
+ indexes.values.map(&:close)
48
+ end
49
+
50
+ def destroy
51
+ remove_path
52
+ end
53
+
54
+ private
55
+ def create_path
56
+ FileUtils.mkdir_p(path)
57
+ end
58
+
59
+ def open?
60
+ @opened
61
+ end
62
+
63
+ def remove_path
64
+ FileUtils.rm_rf(path)
65
+ end
66
+
67
+ class NotOpenError < StandardError ; end
68
+ end
69
+ end
@@ -0,0 +1,38 @@
1
+ require 'oj'
2
+
3
+ module Penumbra
4
+ class Index
5
+ attr_reader :path
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ db
10
+ end
11
+
12
+ def keys
13
+ db.keys.sort
14
+ end
15
+
16
+ def values
17
+ db.values
18
+ end
19
+
20
+ def get(key)
21
+ db[key]
22
+ end
23
+
24
+ def put(key, value)
25
+ db[key] = value
26
+ end
27
+
28
+ def db
29
+ @db ||= File.exist?(path) ? Oj.load(File.read(path)) : {}
30
+ end
31
+
32
+ def close
33
+ file = File.open(path, 'w')
34
+ file.write(Oj.dump(db))
35
+ file.close
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Penumbra
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'penumbra/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "penumbra"
8
+ spec.version = Penumbra::VERSION
9
+ spec.authors = ["Dennis Walters"]
10
+ spec.email = ["dwalters@engineyard.com"]
11
+
12
+ spec.summary = %q{Naive caching/indexing, a shadow of solr}
13
+ spec.homepage = "https://github.com/ess/penumbra"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|tmp)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.2"
24
+ spec.add_development_dependency "simplecov", "~> 0.10"
25
+ spec.add_runtime_dependency "oj", "~> 2.12"
26
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: penumbra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dennis Walters
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: oj
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.12'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.12'
83
+ description:
84
+ email:
85
+ - dwalters@engineyard.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".ruby-gemset"
93
+ - ".ruby-version"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/penumbra.rb
102
+ - lib/penumbra/catalog.rb
103
+ - lib/penumbra/index.rb
104
+ - lib/penumbra/version.rb
105
+ - penumbra.gemspec
106
+ homepage: https://github.com/ess/penumbra
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.7
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Naive caching/indexing, a shadow of solr
130
+ test_files: []