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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ebf6ec1a2970f27889a2247e0d322fdbe5d46fb
4
- data.tar.gz: 0bdda0bf265ab6728c59d3b7251a6a551bb19eb1
3
+ metadata.gz: 4cff94f537fb6f373b28d7e6ff01f448366c8524
4
+ data.tar.gz: 3299cc561b8af266b0c6c184700a57fba1813efa
5
5
  SHA512:
6
- metadata.gz: b1eb63c5dfe78a4beae56925b565813426fc2c1ff74ed63e1eecf83d4f25a615e31da646b977e2ddc184a46a1e630b525c3517c41f8e5f67087d7c1b035f1a6e
7
- data.tar.gz: 3b1fd3c7f160642adfbda70aab1fed792e229ec607aaa9892901aaf6ac9088852cbde2401e1756224e0bd76ab27cea265f9e90bc38e30ef62ccc299d27d6db14
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
- definition(pgfile).available_extensions.each do |dep|
12
- say_status('exists', dep.name)
13
- end
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
- installed = definition(pgfile).install
19
+ installed = definition(pgfile).install
20
+ end
16
21
 
17
22
  installed.each do |d|
18
23
  say_status('install', d.name, :yellow)
@@ -4,6 +4,7 @@ module PgBundle
4
4
  # it defines how to get the code and run make install on a given host (e.g. database server)
5
5
  class BaseSource
6
6
  attr_accessor :path
7
+
7
8
  def initialize(path)
8
9
  @path = path
9
10
  end
@@ -89,7 +89,12 @@ module PgBundle
89
89
  end
90
90
 
91
91
  def make_install_cmd(name)
92
- "cd #{load_destination(name)} && #{sudo} make clean && make install"
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)
@@ -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|
@@ -263,7 +263,7 @@ module PgBundle
263
263
  if opts[:path]
264
264
  @source = PathSource.new(opts[:path])
265
265
  elsif opts[:github]
266
- @source = GithubSource.new(opts[:github])
266
+ @source = GithubSource.new(opts[:github], opts[:branch].to_s)
267
267
  end
268
268
  end
269
269
  end
@@ -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
- # git clone user@git-server:project_name.git -b branch_name /some/folder
22
- cmd = "git clone git@github.com:#{path}.git -b #{branch_name} --quiet --depth=1 #{clone_dir}"
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, cmd
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
@@ -1,3 +1,3 @@
1
1
  module Pgbundle
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
data/spec/Pgfile CHANGED
@@ -4,3 +4,4 @@ pgx 'hstore'
4
4
  pgx 'bar', path: './spec/sample_extensions/bar', requires: 'ltree'
5
5
  pgx 'baz', '0.0.2', path: './spec/sample_extensions/baz', requires: 'foo'
6
6
  pgx 'foo', '0.0.1', path: './spec/sample_extensions/foo'
7
+ pgx 'myext', github: 'adjust/numhstore', branch: 'topic'
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
- subject { PgBundle::GithubSource.new('foo/bar') }
9
- its(:path) { should eq 'foo/bar' }
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
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-06-17 00:00:00.000000000 Z
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.1
188
+ rubygems_version: 2.2.2
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: bundling postgres extension