sinatra-hexacta 0.3.1 → 0.3.2

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: 185da18b74cc83d7a22b391e86d2620d1c71e70a0bea348f21959d4ca8168afd
4
- data.tar.gz: 738feb302f578a42855e8afa2af5bcb8c5b83c259c89c0d15b5c21c913317a55
3
+ metadata.gz: a6fb503a8966bb24d1526acd9e44a6b8f798967193f7b5c465c61b86c4eb4d76
4
+ data.tar.gz: 1896cd47708d90de659d4e7d5253d3588331fd2372234c7c1bc152783bbd75ff
5
5
  SHA512:
6
- metadata.gz: 9051be364b942161b6da74a1a60859c1f786c0dd1f8d3d99727d535e193acab914d655fc394c8b4a3b9a17b6fdc33a88316ea5182ce82bd04527e40631c0c27b
7
- data.tar.gz: 18f52572803ba6cc0e992f8ba1d1af5a6f1766588cf33f583d8fed896a0154190b2091a86f87f9f2195f300231a4882dd855a15eeb4c018afb0543ac94b45aad
6
+ metadata.gz: 2cbd2de133ebff3475d3d8f398d6588d264d6d310194b150e45a061a7d094f03dfe7288ef5b27bc1d9cecf663504fd793e0d0da9c9d47852ce327f04c5fc1e0b
7
+ data.tar.gz: ff26fc925028c9a03ca3af480c9292ed8a6ba6f463180d39625fb5a6ed896d13570f41e786a9d4038235ddfd950234e0e1ef402ee8be17085e8a8eb3670319c4
@@ -13,7 +13,7 @@ module Sinatra
13
13
  end
14
14
 
15
15
  def error_template(code)
16
- ErrorHandler.symlink("/lib/sinatra/views/errors/#{code}.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/errors/#{code}.slim")
16
+ ErrorHandler.copy_file("/lib/sinatra/views/errors/#{code}.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/errors/#{code}.slim")
17
17
  error code do
18
18
  if code == 500
19
19
  title = env['sinatra.error'].message.split(':')[0].gsub('#<','');
@@ -6,8 +6,8 @@ module Sinatra
6
6
  def enable_notifications
7
7
  p "Enabling notifications..."
8
8
  NotificationHandler.setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/notifications")
9
- NotificationHandler.symlink("/lib/sinatra/views/notifications.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications.slim")
10
- NotificationHandler.symlink_all("/lib/sinatra/views/notifications","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications")
9
+ NotificationHandler.copy_file("/lib/sinatra/views/notifications.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications.slim")
10
+ NotificationHandler.copy_all_files("/lib/sinatra/views/notifications","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications")
11
11
 
12
12
  post '/notification' do
13
13
  if params[:user_ids].blank?
@@ -20,7 +20,7 @@ module Sinatra
20
20
  end
21
21
 
22
22
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/alerts")
23
- symlink_all("/lib/sinatra/views/alerts","/app/views/#{Hexacta::GEM_FILE_DIR}/alerts")
23
+ copy_all_files("/lib/sinatra/views/alerts","/app/views/#{Hexacta::GEM_FILE_DIR}/alerts")
24
24
  end
25
25
 
26
26
  helpers AlertHelper
@@ -24,7 +24,7 @@ module Sinatra
24
24
  end
25
25
 
26
26
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/charts")
27
- symlink_all("/lib/sinatra/views/charts","/app/views/#{Hexacta::GEM_FILE_DIR}/charts")
27
+ copy_all_files("/lib/sinatra/views/charts","/app/views/#{Hexacta::GEM_FILE_DIR}/charts")
28
28
  end
29
29
 
30
30
  helpers ChartsHelper
@@ -40,7 +40,7 @@ module Sinatra
40
40
  end
41
41
 
42
42
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/inputs")
43
- symlink_all("/lib/sinatra/views/inputs","/app/views/#{Hexacta::GEM_FILE_DIR}/inputs")
43
+ copy_all_files("/lib/sinatra/views/inputs","/app/views/#{Hexacta::GEM_FILE_DIR}/inputs")
44
44
  end
45
45
 
46
46
  helpers InputHelper
@@ -18,7 +18,7 @@ module Sinatra
18
18
  p "Setting up libraries directory..."
19
19
  copy_dir_structure("/lib/sinatra/public","/app/public/#{Hexacta::GEM_FILE_DIR}")
20
20
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/libraries")
21
- symlink_all("/lib/sinatra/views/libraries","/app/views/#{Hexacta::GEM_FILE_DIR}/libraries")
21
+ copy_all_files("/lib/sinatra/views/libraries","/app/views/#{Hexacta::GEM_FILE_DIR}/libraries")
22
22
  end
23
23
 
24
24
  helpers LibrariesHelper
@@ -20,7 +20,7 @@ module Sinatra
20
20
  end
21
21
 
22
22
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/reports")
23
- symlink_all("/lib/sinatra/views/reports","/app/views/#{Hexacta::GEM_FILE_DIR}/reports")
23
+ copy_all_files("/lib/sinatra/views/reports","/app/views/#{Hexacta::GEM_FILE_DIR}/reports")
24
24
  end
25
25
 
26
26
  helpers ReportHelper
@@ -9,43 +9,30 @@ module Sinatra
9
9
  module Hexacta
10
10
  GEM_FILE_DIR = "sinatra-hexacta"
11
11
 
12
- def symlink(original_path, link_path)
13
- File.symlink "#{Gem.loaded_specs["sinatra-hexacta"].gem_dir}#{original_path}", "#{link_path}" unless Gem.loaded_specs["sinatra-hexacta"].nil? || File.exist?("#{link_path}")
12
+ def gem_path
13
+ File.expand_path("../..",__dir__)
14
14
  end
15
15
 
16
- def symlink_all(original_path, link_path)
17
- Dir.foreach("#{Gem.loaded_specs["sinatra-hexacta"].gem_dir}#{original_path}") do |child|
18
- symlink("#{original_path}/#{child}","#{link_path}/#{child}") unless child == '.' || child == '..'
19
- end unless Gem.loaded_specs["sinatra-hexacta"].nil?
16
+ def copy_file(original_path, link_path)
17
+ IO.copy_stream("#{gem_path}#{original_path}",link_path) unless File.exist?(link_path) && FileUtils.compare_file("#{gem_path}#{original_path}",link_path)
20
18
  end
21
19
 
22
- def setup_dir(path)
23
- unless Gem.loaded_specs["sinatra-hexacta"].nil?
24
- FileUtils.remove_dir path if Dir.exist? path
25
- FileUtils.mkdir_p path
20
+ def copy_all_files(original_path, link_path)
21
+ Dir.foreach("#{gem_path}#{original_path}") do |child|
22
+ copy_file("#{original_path}/#{child}","#{link_path}/#{child}") unless child == '.' || child == '..'
26
23
  end
27
24
  end
28
25
 
26
+ def setup_dir(path)
27
+ FileUtils.mkdir_p path
28
+ end
29
+
29
30
  def copy_dir_structure(original_path, destination_path)
30
- unless Gem.loaded_specs["sinatra-hexacta"].nil?
31
- FileUtils.remove_dir destination_path if Dir.exist? destination_path
32
- FileUtils.copy_entry("#{Gem.loaded_specs["sinatra-hexacta"].gem_dir}#{original_path}", destination_path)
33
- end
31
+ FileUtils.copy_entry("#{gem_path}#{original_path}", destination_path)
34
32
  end
35
33
  end
36
34
  end
37
35
 
38
- if Gem.loaded_specs["sinatra-hexacta"].nil?
39
- p "ERROR: Sinatra hexacta gem was not found"
40
- else
41
- p "Sinatr hexacta gem was found in #{Gem.loaded_specs["sinatra-hexacta"].gem_dir}"
42
- end
43
-
44
- unless Gem.loaded_specs["sinatra-hexacta"].nil?
45
- FileUtils.remove_dir "/app/views/sinatra-hexacta" if Dir.exist? "/app/views/sinatra-hexacta"
46
- FileUtils.remove_dir "/app/public/sinatra-hexacta" if Dir.exist? "/app/public/sinatra-hexacta"
47
- end
48
-
49
36
  require_relative 'helpers/init'
50
37
  require_relative 'handlers/init'
51
38
  require_relative 'extensions/init'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-hexacta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Zanger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-03 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A gem to support general functionality accross all apps
14
14
  email: mzanger@hexacta.com