pgai 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 0b90d7c59fd71a8be56fa44aa2cb5f0852ffd32727d32122623374f55351e91d
4
- data.tar.gz: aceb7f2333e5335779f5de61c78a13522e8b3181561f42f72d4f7feb5430ee6c
3
+ metadata.gz: 123bfba393d6bed50c493b3acd2d934b497c506a09c5680293bc2d68eb942394
4
+ data.tar.gz: cc04c9ab11322ba25526b3fef520c72c172e9672d52e04aded6b23e37a28490b
5
5
  SHA512:
6
- metadata.gz: cdd32ea51e752bc2430206445dfdd63f99d3102213a5412083750b6b1ec522681fb3ecf4d49e4328a7d84efff543cd7405ebe6b39a7613270d268fbd38f7672b
7
- data.tar.gz: f9efad629d63f4094e75d8c79c1a2af85eb7947864437828c42417948b28606a47a5bd09f3545377e72f1e5e9894ee2c06b3f5a3a43529b135a883cc733b1056
6
+ metadata.gz: d746ae9b949706ad27f5aeb8089ff928475188a2e43ab996b8ece041feae63b740d70a3ed165f0af3f022309066cec0bcb6200fca8b1c7c1da4a1e7dec7932e1
7
+ data.tar.gz: 43b5d7e409bca1d28cb75c6fff9a3259c34348bc7365035134acff02639e5e8a7753401f83ef3d3dcbbab2fa6089060e91bf4bfb1406dd27b19e102d63b23a9f
@@ -6,6 +6,7 @@ module Pgai
6
6
  class CreateCloneService
7
7
  HOSTNAME = "127.0.0.1"
8
8
  CLONE_REFRESH_INTERVAL = 0.2
9
+ PROGRESS_BAR_WIDTH = 80
9
10
 
10
11
  attr_reader :id, :env, :logger
11
12
 
@@ -16,11 +17,15 @@ module Pgai
16
17
  end
17
18
 
18
19
  def execute
20
+ logger.info("Preparing clone ...")
21
+ logger.debug { "Expected cloning time: #{env.expected_cloning_time}" }
22
+ progress_bar.start
23
+
19
24
  create_clone_resource
20
- logger.debug(clone_resource.status_message)
21
- progress_bar.advance
25
+
26
+ logger.debug { clone_resource.status_message }
22
27
  wait_for_clone_to_be_ready
23
- logger.debug(clone_resource.status_message)
28
+ logger.debug { clone_resource.status_message }
24
29
 
25
30
  Resources::Local::Clone.new(cached_clone_attributes).tap(&:save)
26
31
  end
@@ -53,8 +58,8 @@ module Pgai
53
58
 
54
59
  def wait_for_clone_to_be_ready
55
60
  loop do
61
+ progress_bar.advance(steps)
56
62
  clone_resource.refresh
57
- progress_bar.advance
58
63
  break if clone_resource.ready?
59
64
  sleep(CLONE_REFRESH_INTERVAL)
60
65
  end
@@ -62,14 +67,11 @@ module Pgai
62
67
  end
63
68
 
64
69
  def progress_bar
65
- @progress_bar ||= TTY::ProgressBar.new(
66
- "Preparing clone ... [:bar]",
67
- total: progress_bar_steps
68
- )
70
+ @progress_bar ||= TTY::ProgressBar.new("[:bar]", total: PROGRESS_BAR_WIDTH)
69
71
  end
70
72
 
71
- def progress_bar_steps
72
- (env.expected_cloning_time / CLONE_REFRESH_INTERVAL).ceil + 1
73
+ def steps
74
+ @steps ||= (PROGRESS_BAR_WIDTH / env.expected_cloning_time).ceil
73
75
  end
74
76
  end
75
77
  end
@@ -95,7 +95,6 @@ module Pgai
95
95
  def assign_attributes(user_attributes)
96
96
  user_attributes.each do |key, value|
97
97
  attribute = self.class.attributes.find { |attr| attr.name == key }
98
- raise "shit" unless attribute
99
98
 
100
99
  assign_attribute(attribute, value)
101
100
  end
data/lib/pgai/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pgai
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marius Bobin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-18 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  - !ruby/object:Gem::Version
285
285
  version: '0'
286
286
  requirements: []
287
- rubygems_version: 3.4.10
287
+ rubygems_version: 3.4.19
288
288
  signing_key:
289
289
  specification_version: 4
290
290
  summary: CLI wrapper for postgres.ai thin clones