fontana_client_support 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/.gitmodules +3 -0
- data/Rakefile +3 -0
- data/fontana_client_support.gemspec +3 -0
- data/lib/fontana_client_support/config_server.rb +59 -0
- data/lib/fontana_client_support/tasks/config_server.rake +20 -0
- data/lib/fontana_client_support/version.rb +1 -1
- data/lib/fontana_client_support.rb +2 -0
- data/spec/fontana_client_support/config_server_spec.rb +28 -0
- data/spec/spec_helper.rb +3 -0
- metadata +56 -7
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzUxMzFkYjQxNDU0NmRiYWU5ODBhZGMzZmZmMDgxYjIwMDIzOGJlMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzQ1NGMwNjIyMjk5ZTBjZDMwYjdhMzYwYjlkMDgwNmZhNmY3NWY3NA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjQ4Zjk5NmE5YjgzOGNmOWRjZDJjYzFjY2MzMGVmOWM4ZGE2MDhiYTI5MWJl
|
10
|
+
Y2Y0NmZlMDUxOTNiOTI4OGRiYzVlYTAxMDIyYTM5OWQ0MDEyNGVjOWNmMTUw
|
11
|
+
NmU4OWY2ZjRmY2I1NTYxZDcyNDY0ODQ2MzVhNzcwM2E4YjY4YjM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZWFhMDc2ZmM2ZmU4ZWY4NGY3Y2VkOTdiNDIzNzdmYWQ2OTVlNmViMGFlYmM5
|
14
|
+
NjFlNjFmMjMyMzdhZTdkMzBhY2RlMDE5OTM2NmI2MTE0ZTRlNWMzM2ZiM2I0
|
15
|
+
M2Q1NDFjYjIyMzU2OTE5OTVmMDFlYTA3NmMyNjk1ZmUyYzFjYTQ=
|
data/.gitmodules
ADDED
data/Rakefile
CHANGED
@@ -20,4 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "httpclient"
|
25
|
+
spec.add_development_dependency "json"
|
23
26
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'fontana_client_support'
|
2
|
+
|
3
|
+
module FontanaClientSupport
|
4
|
+
class ConfigServer
|
5
|
+
|
6
|
+
# see http://doc.ruby-lang.org/ja/1.9.3/class/WEBrick=3a=3aHTTPServer.html
|
7
|
+
def initialize(config = {})
|
8
|
+
@config = {
|
9
|
+
:DocumentRoot => File.join(FontanaClientSupport.root_dir, "config_server"),
|
10
|
+
:BindAddress => '127.0.0.1',
|
11
|
+
:Port => 80
|
12
|
+
}
|
13
|
+
@config.update(config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def launch
|
17
|
+
require 'webrick'
|
18
|
+
server = WEBrick::HTTPServer.new(@config)
|
19
|
+
puts "config_server options: #{@config.inspect}"
|
20
|
+
Signal.trap(:INT){ server.shutdown }
|
21
|
+
server.start
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
|
26
|
+
def start_daemon(options = {})
|
27
|
+
pid_dir = File.join(FontanaClientSupport.root_dir, "tmp/pids")
|
28
|
+
pid_file = File.join(pid_dir, "config_server.pid")
|
29
|
+
if File.exist?(pid_file)
|
30
|
+
raise "Can't start config server daemon because #{pid_file} already exists."
|
31
|
+
end
|
32
|
+
FileUtils.mkdir_p(pid_dir)
|
33
|
+
pid = fork do
|
34
|
+
$PROGRAM_NAME = __FILE__
|
35
|
+
open(pid_file, "w") do |f|
|
36
|
+
f.write(Process.pid)
|
37
|
+
end
|
38
|
+
begin
|
39
|
+
self.new(options).launch
|
40
|
+
ensure
|
41
|
+
File.delete(pid_file)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
pid
|
45
|
+
end
|
46
|
+
|
47
|
+
def stop_daemon
|
48
|
+
pid_dir = File.join(FontanaClientSupport.root_dir, "tmp/pids")
|
49
|
+
Dir[File.join(pid_dir, "config_server.pid")].each do |filepath|
|
50
|
+
pid = File.read(filepath)
|
51
|
+
Process.kill("INT", pid.to_i)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
namespace :config_server do
|
4
|
+
|
5
|
+
desc "launch server process in foreground mode"
|
6
|
+
task :launch do
|
7
|
+
FontanaClientSupport::ConfigServer.new.launch
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "start server daemon"
|
11
|
+
task :start do
|
12
|
+
FontanaClientSupport::ConfigServer.start_daemon
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "stop server daemon"
|
16
|
+
task :stop do
|
17
|
+
FontanaClientSupport::ConfigServer.stop_daemon
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'httpclient'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
describe FontanaClientSupport::ConfigServer do
|
7
|
+
|
8
|
+
before do
|
9
|
+
path = File.expand_path("../config_server_sample1", __FILE__)
|
10
|
+
FontanaClientSupport.root_dir = path
|
11
|
+
# FontanaClientSupport::ConfigServer.start_daemon(:Port => 3002, :DocumentRoot => path)
|
12
|
+
FontanaClientSupport::ConfigServer.start_daemon(:Port => 3002)
|
13
|
+
sleep(3)
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
FontanaClientSupport::ConfigServer.stop_daemon
|
18
|
+
end
|
19
|
+
|
20
|
+
it "get develop.json" do
|
21
|
+
c = HTTPClient.new
|
22
|
+
JSON.parse(c.get_content("http://localhost:3002/api_server/1/develop.json")).should == {
|
23
|
+
"http_url_base" => "http://localhost:3000",
|
24
|
+
"https_url_base" => "https://localhost:3001",
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontana_client_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,14 +28,56 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httpclient
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
39
81
|
- !ruby/object:Gem::Version
|
40
82
|
version: '0'
|
41
83
|
description: gem to support development and testing with GSS/fontana
|
@@ -46,6 +88,7 @@ extensions: []
|
|
46
88
|
extra_rdoc_files: []
|
47
89
|
files:
|
48
90
|
- .gitignore
|
91
|
+
- .gitmodules
|
49
92
|
- Gemfile
|
50
93
|
- LICENSE.txt
|
51
94
|
- README.md
|
@@ -56,7 +99,9 @@ files:
|
|
56
99
|
- lib/fontana/rake_utils.rb
|
57
100
|
- lib/fontana/server_rake.rb
|
58
101
|
- lib/fontana_client_support.rb
|
102
|
+
- lib/fontana_client_support/config_server.rb
|
59
103
|
- lib/fontana_client_support/tasks.rb
|
104
|
+
- lib/fontana_client_support/tasks/config_server.rake
|
60
105
|
- lib/fontana_client_support/tasks/deploy/scm.rake
|
61
106
|
- lib/fontana_client_support/tasks/deploy/sync.rake
|
62
107
|
- lib/fontana_client_support/tasks/fixtures.rake
|
@@ -64,6 +109,8 @@ files:
|
|
64
109
|
- lib/fontana_client_support/tasks/spec.rake
|
65
110
|
- lib/fontana_client_support/tasks/vendor_fontana.rake
|
66
111
|
- lib/fontana_client_support/version.rb
|
112
|
+
- spec/fontana_client_support/config_server_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
67
114
|
homepage: ''
|
68
115
|
licenses:
|
69
116
|
- MIT
|
@@ -74,12 +121,12 @@ require_paths:
|
|
74
121
|
- lib
|
75
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
123
|
requirements:
|
77
|
-
- - '>='
|
124
|
+
- - ! '>='
|
78
125
|
- !ruby/object:Gem::Version
|
79
126
|
version: '0'
|
80
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
128
|
requirements:
|
82
|
-
- - '>='
|
129
|
+
- - ! '>='
|
83
130
|
- !ruby/object:Gem::Version
|
84
131
|
version: '0'
|
85
132
|
requirements: []
|
@@ -88,5 +135,7 @@ rubygems_version: 2.0.3
|
|
88
135
|
signing_key:
|
89
136
|
specification_version: 4
|
90
137
|
summary: gem to support development and testing with GSS/fontana
|
91
|
-
test_files:
|
138
|
+
test_files:
|
139
|
+
- spec/fontana_client_support/config_server_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
92
141
|
has_rdoc:
|