-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
139 additions
and
43 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 |
---|---|---|
@@ -1 +1,14 @@ | ||
*.secret | ||
|
||
/.bundle/ | ||
/.yardoc | ||
/Gemfile.lock | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
|
||
# rspec failure tracking | ||
.rspec_status |
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,2 @@ | ||
--format documentation | ||
--color |
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,5 @@ | ||
sudo: false | ||
language: ruby | ||
rvm: | ||
- 2.3.3 | ||
before_install: gem install bundler -v 1.14.3 |
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,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in sierra-postgres-utilities.gemspec | ||
gemspec |
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ __NOTE: Some sites may have iii setups that store different data in different pl | |
### Interact with bib (and other) records | ||
|
||
```ruby | ||
require_relative 'lib/sierra_postgres_utilities.rb' | ||
require 'sierra_postgres_utilities' | ||
|
||
bnum = 'b9256886a' | ||
bib = SierraBib.new(bnum) | ||
|
@@ -105,17 +105,15 @@ return any of ```bib```'s entries in those two views. | |
|
||
## SETUP | ||
|
||
* Clone or download a copy. | ||
* ```gem install mail``` | ||
* ```gem install pg``` | ||
* ```gem install marc``` | ||
* git clone https://github.com/UNC-Libraries/sierra-postgres-utilities | ||
* cd sierra-postgres-utilities | ||
* bundle install | ||
* bundle exec rake install | ||
* supply the Sierra postgres credentials per the below | ||
* optionally supply smtp server address | ||
|
||
### Credentials | ||
|
||
#### Stored in file | ||
|
||
Create a yaml file in the base directory like so: | ||
|
||
```yaml | ||
|
@@ -126,20 +124,33 @@ user: myusername | |
password: mypassword | ||
``` | ||
If you name the file ```sierra_prod.secret``` it will be the default connection. | ||
Store the creds in a file ```sierra_prod.secret``` in the | ||
current working directory or the base directory of sierra_postgres_utilities. | ||
Creds from this file will be used as the default connection. | ||
|
||
Alternately, specify a credential file location as an environment variable, e.g.: | ||
|
||
Use some other file with ```SierraDB.connect_as(creds: filename)``` | ||
```bash | ||
SIERRA_INIT_CREDS=my/path/file.yaml irb | ||
``` | ||
|
||
Set a test server connection in a file named ```sierra_test.secret```. Use it with ```SierraDB.connect_as(creds: 'test')``` | ||
or set the file location in ruby: | ||
|
||
#### Passed as argument | ||
```ruby | ||
# File location | ||
ENV['SIERRA_INIT_CREDS'] = 'my/path/file.yaml' | ||
require 'sierra_postgres_utilities' | ||
``` | ||
|
||
Pass the connection info (host, port, dbname, user, password) in a hash: ```SierraDB.connect_as(creds: cred_hash)``` | ||
Once connected to the Sierra DB, you can close the connection and reconnect | ||
under alternate creds using: | ||
- ```SierraDB.connect_as(creds: filename)```, or | ||
- ```SierraDB.connect_as(creds: cred_hash)``` | ||
|
||
### SMTP connection / email address storage | ||
|
||
Define an smtp connection (that does not require authentication) if you'll use this to send emails. | ||
Create ```smtp.secret``` in the base directory: | ||
Create ```smtp.secret``` in the working directory: | ||
|
||
```yaml | ||
address: smtp.example.com | ||
|
@@ -160,16 +171,3 @@ c.yield_email # => [email protected] | |
c.yield_email(index: 'default_email') # => [email protected] | ||
c.yield_email(index: 'other_email') # => [email protected] | ||
``` | ||
|
||
## Loading into other scripts | ||
|
||
This isn't a gem. It isn't getting installed and can have varying paths, so we've been keeping the sierra-postgres-utilities folder and the folders for scripts dependent on sierra-postgres-utilities in the same directory, so: | ||
|
||
* .../code/sierra-postgres-utilities/.git | ||
* .../code/dependent_repo/dependent_thing.rb | ||
|
||
and then in dependent_thing.rb doing: | ||
|
||
```ruby | ||
require_relative '../sierra-postgres-utilities/lib/sierra_postgres_utilities.rb' | ||
``` |
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,6 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec |
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,14 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "bundler/setup" | ||
require "sierra_postgres_utilities" | ||
|
||
# You can add fixtures and/or initialization code here to make experimenting | ||
# with your gem easier. You can also use a different console, if you like. | ||
|
||
# (If you use this, don't forget to add pry to your Gemfile!) | ||
# require "pry" | ||
# Pry.start | ||
|
||
require "irb" | ||
IRB.start(__FILE__) |
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,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install | ||
|
||
# Do any other automated setup that you need to do here |
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,39 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'sierra_postgres_utilities/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = 'sierra_postgres_utilities' | ||
spec.version = SierraPostgresUtilities::VERSION | ||
spec.authors = ['ldss-jm', 'Kristina Spurgin'] | ||
spec.email = ['[email protected]'] | ||
|
||
spec.summary = 'Connects to iii Sierra postgres DB and provides ' \ | ||
'logic/utilities to interact with Sierra records in ruby.' | ||
spec.homepage = "https://github.com/UNC-Libraries/sierra-postgres-utilities" | ||
|
||
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' | ||
# to allow pushing to a single host or delete this section to allow pushing to any host. | ||
if spec.respond_to?(:metadata) | ||
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" | ||
else | ||
raise 'RubyGems 2.0 or newer is required to protect against ' \ | ||
'public gem pushes.' | ||
end | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject do |f| | ||
f.match(%r{^(test|spec|features)/}) | ||
end | ||
spec.bindir = "exe" | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_development_dependency 'bundler', '~> 1.14' | ||
spec.add_development_dependency 'rake', '~> 10.0' | ||
spec.add_development_dependency 'rspec', '~> 3.0' | ||
|
||
spec.add_runtime_dependency 'mail', '~> 2.6' | ||
spec.add_runtime_dependency 'marc', '~> 1.0' | ||
spec.add_runtime_dependency 'pg', '~> 1.1' | ||
end |