fontana_client_support 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmYzNjM1NGZlYmU1ZDAzYzVhNGViNmYzYmQ5Mzg2ZjVhZjZjMDBiZg==
4
+ ZTZhZWVhYzllN2JjM2FlYjcxMGRiMTVhM2RiNzhlODZkZmI5MGM3ZQ==
5
5
  data.tar.gz: !binary |-
6
- OWM2ZDk0MDBlZTkzYWFiZGQ0MTFkZmMzMDRlYjdkYmYzNTk0ZWZjZA==
6
+ ZWRhNjY1MTkyZDM1YWI5MjE0Yjk0ZWMwNzQxZWRiYTBlZGM1ZjlmZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZDIyMDRmZTViMjlhOWE4ZWVjZDQ1ODdlMzY0Njk0NjE3OTVhYzU1YzgyNzFj
10
- YjMwNTQ4YmU3ODMwNDljYjA3MDVkMDViNTFmODVkMjM5ZmFhNDRhOGZhMjU0
11
- NGE0N2YwODMzNjIxZWJiMGI2YTEzNzRmN2U4MThmMWQ0ODlhMzM=
9
+ YTBjMGNhZGQ0N2IwZDdkM2M2ZWY1ZDg4M2U1MzE2MDM5MDdjNDhiMTQ0ZGU1
10
+ ZDA0ZjAyMDI4YTUzYWY2ZTI1NTgwN2JhNGFkN2Y2OGUxNWRlMDI0OTE2NGMy
11
+ Y2FhNmEyODI2ZDIxMjk4NzA4YWJhYzVjODM0OTg3YTkzZTE2M2E=
12
12
  data.tar.gz: !binary |-
13
- ZTY1MDE4ZWM0Y2E5MzAzYTk4MjAzNDU0Njk1Y2UyOTMwZDUwZDI4MGNiNWEz
14
- ZmQ3OTVlMmNkZmNjYzU2ODM0ZjkzZTc3MTcwMzI3MDczZWUxMWI0ZTBmZGU3
15
- YzhmNTAwMmNjODM5Zjk3ODRjNjI0NjdkYzQ3YjZmZjc5OTYwZGY=
13
+ NGFiZDE2MGE2ZGQwNTdmZTVlYmVkZjQxZmY3OTgyYTRiMTBjMjdkODc4ZWEy
14
+ Y2VlNjRiNDQ1OWM4MzUxODJhZjk5NjVjOWI2NDg3M2QzNjcyN2NhZDZmMDZl
15
+ ZmUxYTc3NWE3MGJiZDQ5OTgxODYyMGE1MjVmZTIyMjEwMDI3ZGE=
@@ -14,15 +14,21 @@ module FontanaClientSupport
14
14
  require 'webrick'
15
15
  root_dir = FontanaClientSupport.root_dir
16
16
  document_root_source = @config[:document_root] || root_dir ? File.join(root_dir, "config_server") : "."
17
+ $stdout.puts "config_server options: #{@config.inspect}"
18
+ $stdout.puts("root_dir : #{root_dir.inspect}")
19
+ $stdout.puts("document_root_source : #{document_root_source.inspect}")
17
20
  Dir.mktmpdir("fontana_config_server") do |dir|
18
21
  if @config[:document_root] or root_dir.nil?
19
22
  document_root = document_root_source
20
23
  else
21
- git_dir = File.join(dir, "workspace")
24
+ git_dir = File.join(dir, "workspace")
22
25
  document_root = File.join(dir, "document_root")
23
26
  FileUtils.cp_r(document_root_source, document_root)
24
27
  end
25
28
 
29
+ $stdout.puts("document_root : #{document_root.inspect}")
30
+ $stdout.puts("git_dir : #{git_dir.inspect}")
31
+
26
32
  server_config = {
27
33
  :DocumentRoot => document_root,
28
34
  :BindAddress => @config[:address] || ENV['GSS_CONFIG_SERVER_ADDRESS'],
@@ -31,19 +37,39 @@ module FontanaClientSupport
31
37
  server = WEBrick::HTTPServer.new(server_config)
32
38
  if FontanaClientSupport.root_dir
33
39
  server.mount_proc('/switch_config_server') do |req, res|
40
+ buf = []
34
41
  unless Dir.exist?(git_dir)
35
- FileUtils.cp_r(root_dir, git_dir)
42
+ if git_repo_url = @config[:git_repo_url] || ENV['GSS_CONFIG_SERVER_REPO_URL']
43
+ Dir.chdir(dir) do
44
+ cmd = "git clone #{git_repo_url} #{File.basename(git_dir)}"
45
+ if system(cmd)
46
+ buf << "SUCCESS: #{cmd}"
47
+ else
48
+ buf << "ERROR: #{cmd}"
49
+ end
50
+ end
51
+ else
52
+ FileUtils.cp_r(root_dir, git_dir)
53
+ buf << "SUCCESS: cp -r #{root_dir} #{git_dir}"
54
+ end
36
55
  end
37
56
  tag = req.path.sub(%r{\A/switch_config_server/}, '')
38
- Dir.chdir(git_dir) do
39
- system("git reset --hard #{tag}")
40
- FileUtils.rm_rf(document_root)
41
- FileUtils.cp_r(File.join(git_dir, "config_server"), document_root)
57
+ if tag.nil? || tag.empty?
58
+ bug << "no tag or SHA1 given"
59
+ else
60
+ Dir.chdir(git_dir) do
61
+ if system("git reset --hard #{tag}")
62
+ FileUtils.rm_rf(document_root)
63
+ FileUtils.cp_r(File.join(git_dir, "config_server"), document_root)
64
+ buf << "SUCCESS"
65
+ else
66
+ buf << "ERROR if you use in submodule, set $GSS_CONFIG_SERVER_REPO_URL.\nlike this:\n$ rake config_server:launch GSS_CONFIG_SERVER_PORT=3002 GSS_CONFIG_SERVER_REPO_URL=git@github.com:groovenauts/fontana_sample.git"
67
+ end
68
+ end
42
69
  end
43
- res.body = Dir["#{document_root}/**/*"].to_a.join("\n ")
70
+ res.body = (buf + ["", "files: "] + Dir["#{document_root}/**/*"].to_a).join("\n ")
44
71
  end
45
72
  end
46
- puts "config_server options: #{@config.inspect}"
47
73
  Signal.trap(:INT){ server.shutdown }
48
74
  server.start
49
75
  end
@@ -1,3 +1,3 @@
1
1
  module FontanaClientSupport
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontana_client_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - akima