8000 Metagem for the Postgres implementation · aaronjensen/eventide-postgres@0eb6d5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0eb6d5c

Browse files
committed
Metagem for the Postgres implementation
0 parents  commit 0eb6d5c

12 files changed

+254
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_store
2+
.bundle/
3+
.ruby-version
4+
.ruby-gemset
5+
.rvmrc
6+
Gemfile.lock
7+
*.log
8+
*.gem
9+
gems
10+
gems_backup
11+
*scratch*
12+
*notes*
13+
loader.rb

MIT-License.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2016 Scott Bellware
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# eventide-postgres
2+
3+
Event-Oriented Autonomous Services Toolkit
4+
5+
## License
6+
7+
The `eventide-postgres` library is released under the [MIT License](https://github.com/eventide-project/eventide-postgres/blob/master/MIT-License.txt).

eventide-postgres.gemspec

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- encoding: utf-8 -*-
2+
Gem::Specification.new do |s|
3+
s.name = 'eventide-postgres'
4+
s.version = '0.1.0.0'
5+
s.summary = 'Event-Oriented Autonomous Services Toolkit'
6+
s.description = ' '
7+
8+
s.authors = ['The Eventide Project']
9+
s.email = 'opensource@eventide-project.org'
10+
s.homepage = 'https://github.com/eventide-project/eventide-postgres'
11+
s.licenses = ['MIT']
12+
13+
s.require_paths = ['lib']
14+
s.files = Dir.glob('{lib}/**/*')
15+
s.platform = Gem::Platform::RUBY
16+
s.required_ruby_version = '>= 2.2.3'
17+
18+
s.add_runtime_dependency 'entity_store'
19+
s.add_runtime_dependency 'messaging-postgres'
20+
end

init.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
lib_dir = File.expand_path('../lib', __FILE__)
2+
$LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
3+
4+
libraries_dir = ENV['LIBRARIES_HOME']
5+
unless libraries_dir.nil?
6+
libraries_dir = File.expand_path(libraries_dir)
7+
$LOAD_PATH.unshift libraries_dir unless $LOAD_PATH.include?(libraries_dir)
8+
end
9+
10+
require 'eventide/postgres'

install-gems.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ -z ${GEM_AUTHORITY_PATH+x} ]; then
6+
echo "GEM_AUTHORITY_PATH is not set"
7+
exit
8+
fi
9+
10+
echo
11+
echo 'Installing local gems'
12+
echo '= = ='
13+
14+
source ./set-local-gem-path.sh
15+
16+
echo
17+
echo 'Removing gem files'
18+
echo '- - -'
19+
if test -n "$(find . -maxdepth 1 -name '*.gem' -print -quit)"; then
20+
for gem in *.gem; do
21+
echo "- $gem"
22+
rm $gem
23+
done
24+
else
25+
echo "(No gem files found)"
26+
fi
27+
28+
echo
29+
echo 'Building gems'
30+
echo '- - -'
31+
for gemspec in *.gemspec; do
32+
echo "- $gemspec"
33+
gem build $gemspec
34+
done
35+
36+
if [ -z ${POSTURE+x} ]; then
37+
echo "(POSTURE is not set. Using \"operational\" by default.)"
38+
posture="operational"
39+
else
40+
posture=$POSTURE
41+
fi
42+
43+
scheme="https:"
44+
gem_repo_authority_path=$GEM_AUTHORITY_PATH
45+
public_gem_repo_uri="$scheme//$gem_repo_authority_path"
46+
47+
gemfury_token=""
48+
if [ ! -z ${GEMFURY_TOKEN+x} ]; then
49+
gemfury_token=$GEMFURY_TOKEN
50+
fi
51+
52+
private_source=""
53+
if [ ! $gemfury_token = "" ]; then
54+
private_gem_repo_uri="$scheme//$gemfury_token@$gem_repo_authority_path"
55+
private_source="--source $private_gem_repo_uri"
56+
fi
57+
58+
public_source="--source $public_gem_repo_uri"
59+
60+
ruby_gems_source="--source https://rubygems.org"
61+
62+
echo
63+
echo "Installing gems locally (posture: $posture)"
64+
echo '- - -'
65+
for gem in *.gem; do
66+
echo "($gem)"
67+
cmd="gem install $gem --clear-sources $private_source $public_source $ruby_gems_source --install-dir ./gems"
68+
69+
if [ operational != "$posture" ]; then
70+
cmd="$cmd --development"
71+
fi
72+
73+
echo $cmd
74+
($cmd) || exit 1
75+
done
76+
77+
echo '= = ='
78+
echo '(done)'
79+
echo

lib/eventide/postgres.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'messaging/postgres'
2+
require 'entity_store'

library-symlinks.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
set -e
2+
3+
if [ -z ${LIBRARIES_HOME+x} ]; then
4+
echo "LIBRARIES_HOME must be set to the libraries directory path... exiting"
5+
exit 1
6+
fi
7+
8+
if [ ! -d "$LIBRARIES_HOME" ]; then
9+
echo "$LIBRARIES_HOME does not exist... exiting"
10+
exit 1
11+
fi
12+
13+
function make_directory {
14+
directory=$1
15+
16+
lib_directory="$LIBRARIES_HOME/$directory"
17+
18+
if [ ! -d "$lib_directory" ]; then
19+
echo "- making directory $lib_directory"
20+
mkdir -p "$lib_directory"
21+
fi
22+
}
23+
24+
function remove_lib_symlinks {
25+
name=$1
26+
directory=$2
27+
28+
dest="$LIBRARIES_HOME"
29+
if [ ! -z "$directory" ]; then
30+
dest="$dest/$directory"
31+
fi
32+
dest="$dest/$name"
33+
34+
for entry in $dest*; do
35+
if [ -h "$entry" ]; then
36+
echo "- removing symlink: $entry"
37+
rm $entry
38+
fi
39+
done
40+
}
41+
42+
function symlink_lib {
43+
name=$1
44+
directory=$2
45+
46+
echo
47+
echo "Symlinking $name"
48+
echo "- - -"
49+
50+
remove_lib_symlinks $name $directory
51+
52+
src="$(pwd)/lib"
53+
dest="$LIBRARIES_HOME"
54+
if [ ! -z "$directory" ]; then
55+
src="$src/$directory"
56+
dest="$dest/$directory"
57+
58+
make_directory $directory
59+
fi
60+
src="$src/$name"
61+
62+
echo "- destination is $dest"
63+
64+
full_name=$directory/$name
65+
66+
for entry in $src*; do
67+
entry_basename=$(basename $entry)
68+
dest_item="$dest/$entry_basename"
69+
70+
echo "- symlinking $entry_basename to $dest_item"
71+
72+
cmd="ln -s $entry $dest_item"
73+
echo $cmd
74+
($cmd)
75+
done
76+
77+
echo "- - -"
78+
echo "($name done)"
79+
echo
80+
}

remove-lib-symlinks.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source ./library-symlinks.sh
2+
3+
remove_lib_symlinks 'eventide' 'postgres'

set-local-gem-path.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
unchanged_gem_path=$GEM_PATH
4+
5+
if [[ ! $GEM_PATH == *"./gems"* ]]; then
6+
export GEM_PATH=./gems:$GEM_PATH
7+
8+
echo "Gem path was changed"
9+
echo " from: $unchanged_gem_path"
10+
echo " to: $GEM_PATH"
11+
else
12+
echo "Gem path was unchanged"
13+
echo " from: $unchanged_gem_path"
14+
fi
15+
16+
echo

symlink-lib.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source ./library-symlinks.sh
2+
3+
symlink_lib 'eventide' 'postgres'

test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
load './init.rb'

0 commit comments

Comments
 (0)
0