focus_common 0.0.2 → 0.0.4

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
- SHA1:
3
- metadata.gz: 515e0d24e0dbb77aeb8e11135e9b1a241c8eb57c
4
- data.tar.gz: 402482fa00cf2edc78e23146d4a287b4060195e3
2
+ SHA256:
3
+ metadata.gz: c31f69a408d2cfb5939ffe8d2ca9ee7056f37e0ae3f4931af246450191cf036d
4
+ data.tar.gz: b63ebb1cac3cd016f896547348e9be1a6716b2141000862f16cb3c52a940f63f
5
5
  SHA512:
6
- metadata.gz: cd8d8d042421fa286fc97beffee421d43d830985963ff8ff8d83d69374cf6222d6e88d96561bf789b7b36078e564a82ebcf4348d4687ce9922968af76ae29fc7
7
- data.tar.gz: 660545e1ba7657395faf069ff9277641d08760e31ef677252a9f128edcb102cac91d84ac4eab78ccc5bec0e5709edf2f58adcc4811bf5f41103d6ded3cdbae4e
6
+ metadata.gz: 48e79968501e3702b51aa71111995c02665524b327277ec971e9e9332d881d0d86191d0352a03610ee850a146464a0534378d30d82814cce2525254f18a74c11
7
+ data.tar.gz: e0a2d41166292f43e377de8dbb2233fe4f704861c1286496e62674a59a7eead8bc29876ab6d6cb1081a5b8c4d5744b982625208dce0fa9470a296fc9755c19aa
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/focus_common.gemspec CHANGED
File without changes
@@ -0,0 +1,92 @@
1
+ class FocusCommon::AppInfo
2
+
3
+ def get_database_time_info
4
+ conn = ActiveRecord::Base.connection
5
+ if conn.class.name.demodulize == 'Mysql2Adapter'
6
+ {zone: conn.execute("SELECT @@global.time_zone, @@session.time_zone;").to_a.flatten,
7
+ time: conn.execute("select concat(now(), '');").to_a.flatten.first,
8
+ }
9
+ else
10
+ {}
11
+ end
12
+ end
13
+
14
+ def get_database_info
15
+ conn = ActiveRecord::Base.connection
16
+ if conn.class.name.demodulize == 'Mysql2Adapter'
17
+ {version: conn.select_value("SELECT @@version"),
18
+ }
19
+ else
20
+ {}
21
+ end
22
+ end
23
+
24
+ def git_version
25
+ if Rails.env.development?
26
+ `git rev-parse HEAD`
27
+ else
28
+ filename = File.join(Rails.root, 'REVISION')
29
+ if File.exists?(filename)
30
+ File.read(filename).strip
31
+ else
32
+ nil
33
+ end
34
+ end
35
+ end
36
+
37
+ def get_info
38
+ db_time_info = self.get_database_time_info
39
+ info = \
40
+ {
41
+ environment: {
42
+ rails: Rails.env,
43
+ stage: ENV['STAGE'],
44
+ },
45
+ version: {
46
+ ruby: RUBY_VERSION,
47
+ rails: Rails::VERSION::STRING,
48
+ git: git_version,
49
+ database: self.get_database_info[:version],
50
+ },
51
+ time: {
52
+ system: {
53
+ time: Time.now.to_s,
54
+ zone: Time.now.zone,
55
+ },
56
+ rails: {
57
+ time: Time.zone.now,
58
+ zone: Time.zone.to_s,
59
+ },
60
+ database: {
61
+ time: db_time_info[:time],
62
+ global_zone: db_time_info[:zone].try(:first),
63
+ session_zone: db_time_info[:zone].try(:second),
64
+ },
65
+ },
66
+ important_gems: get_gems.map{|g| [g.name, g.version]}.to_h.slice(*self.important_gems),
67
+ }
68
+
69
+ if defined?(CbaDb)
70
+ info[:cba_site] = \
71
+ CbaDb.enabled_sites.map do |site|
72
+ namespace = CbaDb.sites_info.fetch(site, {})[:db_name]
73
+ [site, namespace]
74
+ end.to_h
75
+ end
76
+
77
+ info
78
+ end
79
+
80
+ def important_gems
81
+ ['sidekiq',
82
+ 'grape',
83
+ 'elasticsearch',
84
+ 'twitter-bootstrap-rails',
85
+ ]
86
+ end
87
+
88
+ def get_gems
89
+ Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }
90
+ end
91
+
92
+ end
@@ -1,18 +1,20 @@
1
1
  namespace :systemd do
2
2
 
3
3
  [:start, :stop, :restart].each do |cmd|
4
- task "app_#{cmd}" do
4
+ task "rails_#{cmd}", :app do |t, args|
5
5
  on roles(:app), in: :sequence, wait: 5 do
6
6
  within release_path do
7
- execute "sudo systemctl #{cmd} rails_#{fetch(:application)}"
7
+ app_name = args[:app] || fetch(:application)
8
+ execute "sudo systemctl #{cmd} rails_#{app_name}"
8
9
  end
9
10
  end
10
11
  end
11
12
 
12
- task "sidekiq_#{cmd}" do
13
- on roles(:app), in: :sequence, wait: 5 do
13
+ task "sidekiq_#{cmd}", [:app] do
14
+ on roles(:app), in: :sequence, wait: 5 do |t, args|
14
15
  within release_path do
15
- execute "sudo systemctl #{cmd} sidekiq_#{fetch(:application)}"
16
+ app_name = args[:app] || fetch(:application)
17
+ execute "sudo systemctl #{cmd} sidekiq_#{app_name}"
16
18
  end
17
19
  end
18
20
  end
@@ -1,4 +1,3 @@
1
1
  module FocusCommon
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.4'
3
3
  end
4
-
data/lib/focus_common.rb CHANGED
File without changes
data/makefile CHANGED
@@ -1,7 +1,7 @@
1
1
  build:
2
2
  gem build focus_common.gemspec
3
3
 
4
- upload:
4
+ upload: clear build
5
5
  gem push *.gem
6
6
 
7
7
  clear:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: focus_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - linjunhalida
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-29 00:00:00.000000000 Z
11
+ date: 2025-01-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Common library for Focus Solution Inc Rails projects
14
14
  email:
@@ -24,6 +24,7 @@ files:
24
24
  - Rakefile
25
25
  - focus_common.gemspec
26
26
  - lib/focus_common.rb
27
+ - lib/focus_common/app_info.rb
27
28
  - lib/focus_common/capistrano.rb
28
29
  - lib/focus_common/version.rb
29
30
  - makefile
@@ -31,7 +32,7 @@ homepage: https://github.com/halida/focus_common
31
32
  licenses:
32
33
  - LGPL-3.0
33
34
  metadata: {}
34
- post_install_message:
35
+ post_install_message:
35
36
  rdoc_options: []
36
37
  require_paths:
37
38
  - lib
@@ -46,9 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
47
  - !ruby/object:Gem::Version
47
48
  version: '0'
48
49
  requirements: []
49
- rubyforge_project:
50
- rubygems_version: 2.5.2
51
- signing_key:
50
+ rubygems_version: 3.5.23
51
+ signing_key:
52
52
  specification_version: 4
53
53
  summary: Common library for Focus Solution Inc Rails projects
54
54
  test_files: []