pgbundle 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pgbundle +9 -4
- data/lib/pgbundle/base_source.rb +1 -0
- data/lib/pgbundle/database.rb +6 -1
- data/lib/pgbundle/definition.rb +10 -0
- data/lib/pgbundle/extension.rb +1 -1
- data/lib/pgbundle/github_source.rb +15 -8
- data/lib/pgbundle/version.rb +1 -1
- data/spec/Pgfile +1 -0
- data/spec/dsl_spec.rb +7 -1
- data/spec/source_spec.rb +18 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cff94f537fb6f373b28d7e6ff01f448366c8524
|
4
|
+
data.tar.gz: 3299cc561b8af266b0c6c184700a57fba1813efa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fdb90bb57db89073e3da35f8058cb26d58989612b43224d580dedebb735bf12c18e7252153789f294204503cb9edd61a1b0dca35672796fb8017917d926d532
|
7
|
+
data.tar.gz: 719f623d6982d7d7e10d14b74bc292b6f09b80fcc1b30a0fe7d70b1026a19275499303a8550573cc154bec0fa1a7880eabbe1137d7d5ff9c87eef428e80cd6d9
|
data/bin/pgbundle
CHANGED
@@ -7,12 +7,17 @@ require 'pry'
|
|
7
7
|
module PgBundle
|
8
8
|
class Cli < Thor
|
9
9
|
desc 'install', 'installs extensions'
|
10
|
+
method_options %w( force -f ) => :boolean
|
10
11
|
def install(pgfile = 'Pgfile')
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
if options.force?
|
13
|
+
installed = definition(pgfile).install!
|
14
|
+
else
|
15
|
+
definition(pgfile).available_extensions.each do |dep|
|
16
|
+
say_status('exists', dep.name)
|
17
|
+
end
|
14
18
|
|
15
|
-
|
19
|
+
installed = definition(pgfile).install
|
20
|
+
end
|
16
21
|
|
17
22
|
installed.each do |d|
|
18
23
|
say_status('install', d.name, :yellow)
|
data/lib/pgbundle/base_source.rb
CHANGED
data/lib/pgbundle/database.rb
CHANGED
@@ -89,7 +89,12 @@ module PgBundle
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def make_install_cmd(name)
|
92
|
-
|
92
|
+
<<-CMD.gsub(/\s+/, ' ').strip
|
93
|
+
cd #{load_destination(name)} &&
|
94
|
+
#{sudo} make clean &&
|
95
|
+
#{sudo} make &&
|
96
|
+
#{sudo} make install
|
97
|
+
CMD
|
93
98
|
end
|
94
99
|
|
95
100
|
def make_uninstall_cmd(name)
|
data/lib/pgbundle/definition.rb
CHANGED
@@ -30,6 +30,16 @@ module PgBundle
|
|
30
30
|
installed.select { |dep| dep.available?(database) }
|
31
31
|
end
|
32
32
|
|
33
|
+
# installs all required extensions
|
34
|
+
def install!
|
35
|
+
installed = extensions.map do |_, dep|
|
36
|
+
dep.install(database)
|
37
|
+
dep
|
38
|
+
end
|
39
|
+
|
40
|
+
installed.select { |dep| dep.available?(database) }
|
41
|
+
end
|
42
|
+
|
33
43
|
def init
|
34
44
|
["database '#{database.name}', host: '#{database.host}', user: #{database.user}, system_user: #{database.system_user}, use_sudo: #{database.use_sudo}"] +
|
35
45
|
database.current_definition.map do |r|
|
data/lib/pgbundle/extension.rb
CHANGED
@@ -2,6 +2,13 @@ require 'tmpdir'
|
|
2
2
|
module PgBundle
|
3
3
|
# The GithubSource class defines a Github Source
|
4
4
|
class GithubSource < BaseSource
|
5
|
+
attr_reader :branch
|
6
|
+
|
7
|
+
def initialize(path, branch = 'master')
|
8
|
+
@branch = branch
|
9
|
+
super(path)
|
10
|
+
end
|
11
|
+
|
5
12
|
def load(host, user, dest)
|
6
13
|
clone(dest)
|
7
14
|
if host == 'localhost'
|
@@ -11,21 +18,21 @@ module PgBundle
|
|
11
18
|
end
|
12
19
|
end
|
13
20
|
|
14
|
-
def branch_name
|
15
|
-
@branch || 'master'
|
16
|
-
end
|
17
|
-
|
18
21
|
private
|
19
22
|
|
20
23
|
def clone(dest)
|
21
|
-
#
|
22
|
-
|
23
|
-
%x((#{cmd} && rm -rf #{clone_dir}/.git}) 2>&1)
|
24
|
+
%x((#{git_command} && rm -rf #{clone_dir}/.git}) 2>&1)
|
25
|
+
|
24
26
|
unless $?.success?
|
25
|
-
fail GitCommandError,
|
27
|
+
fail GitCommandError, git_command
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
31
|
+
# git clone user@git-server:project_name.git -b branch_name /some/folder
|
32
|
+
def git_command
|
33
|
+
"git clone git@github.com:#{path}.git -b #{branch} --quiet --depth=1 #{clone_dir}"
|
34
|
+
end
|
35
|
+
|
29
36
|
def clone_dir
|
30
37
|
@clone_dir ||= Dir.mktmpdir
|
31
38
|
end
|
data/lib/pgbundle/version.rb
CHANGED
data/spec/Pgfile
CHANGED
data/spec/dsl_spec.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe PgBundle::Dsl do
|
4
|
-
|
5
4
|
subject { PgBundle::Dsl.new.eval_pgfile(File.expand_path('../Pgfile', __FILE__)) }
|
5
|
+
|
6
6
|
its(:database) { should be_a PgBundle::Database }
|
7
7
|
its('database.port') { should be 54321 }
|
8
8
|
its(:extensions) { should be_a Hash }
|
9
|
+
|
10
|
+
context 'parsing options' do
|
11
|
+
let(:opts) { { :github => 'adjust/numhstore', :branch => 'topic' } }
|
12
|
+
|
13
|
+
specify { subject.extensions['myext'].source.branch.should eq 'topic' }
|
14
|
+
end
|
9
15
|
end
|
data/spec/source_spec.rb
CHANGED
@@ -1,10 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
describe PgBundle::PathSource do
|
3
4
|
subject { PgBundle::PathSource.new('./foo/bar') }
|
4
5
|
its(:path) { should eq './foo/bar' }
|
5
6
|
end
|
6
7
|
|
7
8
|
describe PgBundle::GithubSource do
|
8
|
-
|
9
|
-
|
9
|
+
let(:git) { "git clone git@github.com:foo/bar.git -b #{branch} --quiet --depth=1" }
|
10
|
+
|
11
|
+
context 'default options' do
|
12
|
+
let(:branch) { 'master' }
|
13
|
+
|
14
|
+
subject { PgBundle::GithubSource.new('foo/bar') }
|
15
|
+
|
16
|
+
its(:git_command) { should match git }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'custom options' do
|
20
|
+
let(:branch) { 'topic' }
|
21
|
+
|
22
|
+
subject { PgBundle::GithubSource.new('foo/bar', 'topic') }
|
23
|
+
|
24
|
+
its(:git_command) { should match git }
|
25
|
+
end
|
10
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgbundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Kniep
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.2.
|
188
|
+
rubygems_version: 2.2.2
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: bundling postgres extension
|