huqua 2.0.0 → 3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57910c1454358b08fe5b90fe1b244b1ef9391048939a59bec9a14df43ba78ad6
4
- data.tar.gz: 5ae62872f43ddf4528eb8bbd7e507946d285c83964320428e0788d474da3aef9
3
+ metadata.gz: 48aaf5913bade6bdf3ac3e3b1d5fda74265372f243985b2d98a05a88e56fcfa6
4
+ data.tar.gz: b6f3a476a97ba259c5a431318ae1fc8b664b1c721d6caa894caef0e235375202
5
5
  SHA512:
6
- metadata.gz: ca9852ae298f51870e81b05071786ba611e108a086e8e52690fd388d523b4e5d336cfcd24c6e778989833645a5089068589fb20712d0beff18bcdb1164f965a8
7
- data.tar.gz: 964efe30f07fcaa8b20bfd6e00321b568e8071aa1743598da2bdf414628c565c372975093b3f320b59af34392e5ad786ca0f8d714f90ce7d12b9a94c8b21bb72
6
+ metadata.gz: b07487efdc9321cdd7bee344b8a5cb5aecce25ddbe08959f4665e4d8845a6dec1a068e2b775a7e0485b57cf36e17ddfb7d0154b3652803871dfd7c2ccdc24e88
7
+ data.tar.gz: 6a31e640d5bebe05d26e11cf903c7d802992aeb9862f1a0b9d94be77ced9af488778a7a84bceed1398647631abaa0a848ebfa15f4cd96b680bc26793cea29b20
@@ -21,4 +21,4 @@ module DisplayDetail
21
21
  puts "The second params need a integer!".red
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -8,6 +8,9 @@ module DisplayOverview
8
8
  res = $conn.exec(term)
9
9
  rescue StandardError => e
10
10
  res = nil
11
+
12
+
13
+
11
14
  end
12
15
 
13
16
  result = res ? "~> #{tables[n]} (#{res[0]['count']})".yellow : "Can not find #{tables[n]} in database".red
data/lib/huqua.rb CHANGED
@@ -1,17 +1,17 @@
1
- require 'pg'
2
- require 'yaml'
3
- require_relative 'string'
4
- require_relative 'read_schema'
5
- require_relative 'display_overview'
6
- require_relative 'display_structure'
7
- require_relative 'display_detail'
1
+ require "pg"
2
+ require "yaml"
3
+ require_relative "string"
4
+ require_relative "read_schema"
5
+ require_relative "display_overview"
6
+ require_relative "display_structure"
7
+ require_relative "display_detail"
8
8
 
9
9
  # Read database.yml
10
10
  begin
11
- config_info = YAML.load_file('config/database.yml')
11
+ config_info = YAML.load_file("config/database.yml")
12
12
 
13
- $username = config_info["development"]["username"] || ENV["USER"]
14
- $password = config_info["development"]["password"] || ''
13
+ $username = config_info["development"]["username"]
14
+ $password = config_info["development"]["password"]
15
15
  $database = config_info["development"]["database"]
16
16
  rescue StandardError => e
17
17
  puts "Missing database.yml or config in this file is wrong".red
@@ -19,15 +19,12 @@ end
19
19
 
20
20
  # Connect to database
21
21
  begin
22
- $conn = PG::Connection.connect(
23
- :hostaddr => "127.0.0.1", :port=>5432,
24
- :dbname => $database,
25
- :user => $username,
26
- :password => $password
27
- )
22
+ configs = Rails.configuration.database_configuration[Rails.env].with_indifferent_access
23
+ $conn =
24
+ PG::Connection.connect(hostaddr: (configs[:port] || "127.0.0.1"), port: (configs[:port] || 5432), dbname: configs[:database], user: configs[:username], password: configs[:password] || "")
28
25
  puts "Congrats, you have good connection to database!\n".green
29
26
  rescue StandardError => e
30
- puts "Can not connect to database...\n".red
27
+ puts "Can not connect to database...: #{e.message}\n".red
31
28
  end
32
29
 
33
30
  # Main Class
@@ -42,12 +39,8 @@ class Huqua
42
39
  ARGV.size.times { |item| tmp_arg.push(ARGV[item]) }
43
40
 
44
41
  if ARGV.size <= 2
45
- if(ARGV.size == 1)
46
- DisplayStructure.show(tables, tmp_arg)
47
- end
48
- if(ARGV.size == 2)
49
- DisplayDetail.show(tables, tmp_arg)
50
- end
42
+ DisplayStructure.show(tables, tmp_arg) if (ARGV.size == 1)
43
+ DisplayDetail.show(tables, tmp_arg) if (ARGV.size == 2)
51
44
  else
52
45
  puts "The number of arguments went wrong".red
53
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huqua
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: '3.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duy Chinh
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-31 00:00:00.000000000 Z
11
+ date: 2022-08-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple tool for checking postgresql database in development without
14
14
  access to rails console
@@ -25,11 +25,11 @@ files:
25
25
  - lib/huqua.rb
26
26
  - lib/read_schema.rb
27
27
  - lib/string.rb
28
- homepage: https://rubygems.org/gems/huqua
28
+ homepage: https://github.com/hdchinh/huqua
29
29
  licenses:
30
30
  - MIT
31
31
  metadata: {}
32
- post_install_message:
32
+ post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
@@ -44,9 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubyforge_project:
48
- rubygems_version: 2.7.6
49
- signing_key:
47
+ rubygems_version: 3.2.33
48
+ signing_key:
50
49
  specification_version: 4
51
50
  summary: A simple tool for checking postgresql database in development without access
52
51
  to rails console