fontana_client_support 0.7.2 → 0.8.0
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 +4 -4
- data/.gitignore +1 -0
- data/lib/fontana.rb +18 -6
- data/lib/fontana_client_support.rb +1 -12
- data/lib/fontana_client_support/config_server.rb +4 -1
- data/lib/fontana_client_support/tasks/delayed_job.rake +57 -0
- data/lib/fontana_client_support/tasks/factory_girl.rake +18 -0
- data/lib/fontana_client_support/tasks/vendor_fontana.rake +5 -8
- data/lib/fontana_client_support/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbb4703a07cc90d6464574b2496b1d190d57ab2f
|
4
|
+
data.tar.gz: 81c6792dd383c7b0f4ab7b0676b435ae40a9909c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 640166a805a597dc89d3a10d06a41e13ddc526fde925dd778e9959ccb28f7107623f0c52007e7e12edcef9d2e8c577aab30313c593741e831f4a5ff2e299213a
|
7
|
+
data.tar.gz: 0ce01a1e42df1ea0a74e0cb2f9f7a47b20404ba0cae8c969e4316c3d00b03a0c5a7cd4221c82121747ca24604cd24f4af192859c734bcd1c7bc4bd00f077632d
|
data/.gitignore
CHANGED
data/lib/fontana.rb
CHANGED
@@ -13,7 +13,6 @@ module Fontana
|
|
13
13
|
attr_accessor :gemfile
|
14
14
|
|
15
15
|
attr_accessor :repo_url
|
16
|
-
attr_accessor :branch
|
17
16
|
|
18
17
|
def home
|
19
18
|
@home ||= ENV['FONTANA_HOME'] || (Dir.exist?(FontanaClientSupport.vendor_fontana) or Fontana.repo_url) ? FontanaClientSupport.vendor_fontana : nil
|
@@ -32,23 +31,36 @@ module Fontana
|
|
32
31
|
# これは fontanaの Fontana.app_mode と同じ動きをすることが期待されています。
|
33
32
|
# https://github.com/tengine/fontana/blob/master/config/application.rb#L47
|
34
33
|
def app_mode
|
35
|
-
(ENV["FONTANA_APP_MODE"] || "
|
34
|
+
(ENV["FONTANA_APP_MODE"] || "test").to_sym # production development test
|
36
35
|
end
|
37
36
|
|
38
37
|
def app_mode=(value)
|
39
38
|
ENV["FONTANA_APP_MODE"] = value
|
40
39
|
end
|
41
40
|
|
41
|
+
def branch
|
42
|
+
unless @branch
|
43
|
+
@branch = ENV['FONTANA_BRANCH' ]
|
44
|
+
load_fontana_version_file unless @branch
|
45
|
+
end
|
46
|
+
@branch
|
47
|
+
end
|
48
|
+
|
42
49
|
def version
|
43
50
|
unless @version
|
44
51
|
@version = ENV['FONTANA_VERSION' ]
|
45
|
-
unless @version
|
46
|
-
path = File.expand_path("FONTANA_VERSION", FontanaClientSupport.root_dir)
|
47
|
-
@version = File.read(path).strip if File.readable?(path)
|
48
|
-
end
|
52
|
+
load_fontana_version_file unless @version
|
49
53
|
end
|
50
54
|
@version
|
51
55
|
end
|
52
56
|
|
57
|
+
def load_fontana_version_file
|
58
|
+
path = File.expand_path("FONTANA_VERSION", FontanaClientSupport.root_dir)
|
59
|
+
line = File.read(path).strip
|
60
|
+
@version, @branch = line.split(/\@/, 2).map{|s| s.empty? ? nil : s }
|
61
|
+
@branch ||= "master"
|
62
|
+
end
|
63
|
+
private :load_fontana_version_file
|
64
|
+
|
53
65
|
end
|
54
66
|
end
|
@@ -16,17 +16,7 @@ module FontanaClientSupport
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def current_branch_name
|
19
|
-
|
20
|
-
@current_branch_name = `git status`.scan(/On branch\s*(.+)\s*$/).flatten.first
|
21
|
-
unless @current_branch_name
|
22
|
-
work = `git log --decorate -1`.scan(/^commit\s[0-9a-f]+\s\((.+)\)/).
|
23
|
-
flatten.first.split(/,/).map(&:strip).reject{|s| s =~ /HEAD\Z/}
|
24
|
-
r = work.select{|s| s =~ /origin\//}.first
|
25
|
-
r ||= work.first
|
26
|
-
@current_branch_name = r.sub(/\Aorigin\//, '')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
@current_branch_name
|
19
|
+
@current_branch_name ||= `git symbolic-ref --short HEAD`.strip
|
30
20
|
rescue => e
|
31
21
|
puts "[#{e.class}] #{e.message}"
|
32
22
|
puts "Dir.pwd: #{Dir.pwd}"
|
@@ -62,5 +52,4 @@ end
|
|
62
52
|
require 'fontana'
|
63
53
|
|
64
54
|
Fontana.repo_url = ENV['FONTANA_REPO_URL']
|
65
|
-
Fontana.branch = ENV['FONTANA_BRANCH' ] || 'master'
|
66
55
|
Fontana.gemfile = ENV['FONTANA_GEMFILE' ] || "Gemfile-LibgssTest"
|
@@ -11,9 +11,10 @@ module FontanaClientSupport
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def launch
|
14
|
+
$stdout.puts "pwd : #{Dir.pwd.inspect}"
|
14
15
|
require 'webrick'
|
15
16
|
root_dir = FontanaClientSupport.root_dir
|
16
|
-
document_root_source = @config[:document_root] || root_dir ? File.join(root_dir, "config_server") : "."
|
17
|
+
document_root_source = @config[:document_root] || (root_dir ? File.join(root_dir, "config_server") : ".")
|
17
18
|
$stdout.puts "config_server options: #{@config.inspect}"
|
18
19
|
$stdout.puts("root_dir : #{root_dir.inspect}")
|
19
20
|
$stdout.puts("document_root_source : #{document_root_source.inspect}")
|
@@ -91,6 +92,8 @@ module FontanaClientSupport
|
|
91
92
|
end
|
92
93
|
$stdout.reopen("/dev/null")
|
93
94
|
$stderr.reopen("/dev/null")
|
95
|
+
# $stdout.reopen("stdout.log")
|
96
|
+
# $stderr.reopen("stderr.log")
|
94
97
|
begin
|
95
98
|
self.new(options).launch
|
96
99
|
ensure
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'fontana_client_support'
|
3
|
+
|
4
|
+
include Fontana::CommandUtils
|
5
|
+
extend Fontana::RakeUtils
|
6
|
+
|
7
|
+
def build_env_str(env)
|
8
|
+
env.each_with_object([]){|(k,v), d|
|
9
|
+
d << "#{k.to_s}=#{v.to_s}"
|
10
|
+
}.join(" ")
|
11
|
+
end
|
12
|
+
|
13
|
+
[:development, :test].each do |app_mode|
|
14
|
+
namespace app_mode do
|
15
|
+
namespace :delayed_job do
|
16
|
+
|
17
|
+
cmd_env = {FONTANA_APP_MODE: app_mode, BUNDLE_GEMFILE: "Gemfile-LibgssTest" }
|
18
|
+
cmd_env_str = build_env_str(cmd_env)
|
19
|
+
|
20
|
+
commands = {
|
21
|
+
start: "start an instance of the application",
|
22
|
+
stop: "stop all instances of the application",
|
23
|
+
restart: "stop all instances and restart them afterwards",
|
24
|
+
reload: "send a SIGHUP to all instances of the application",
|
25
|
+
run: "start the application and stay on top",
|
26
|
+
zap: "set the application to a stopped state",
|
27
|
+
status: "show status (PID) of application instances",
|
28
|
+
}
|
29
|
+
|
30
|
+
cmd_base = cmd_env_str + " bundle exec script/delayed_job "
|
31
|
+
|
32
|
+
commands.each do |cmd, description|
|
33
|
+
|
34
|
+
desc "@#{app_mode} #{description}"
|
35
|
+
task cmd do
|
36
|
+
s = "#{cmd_base} #{cmd}"
|
37
|
+
options_str = ENV['OPTIONS']
|
38
|
+
unless options_str.nil? || options_str.empty?
|
39
|
+
s << " " << options_str
|
40
|
+
end
|
41
|
+
app_options_str = ENV['APP_OPTIONS']
|
42
|
+
unless app_options_str.nil? || app_options_str.empty?
|
43
|
+
s << " -- " << app_options_str
|
44
|
+
end
|
45
|
+
system_at_vendor_fontana!(s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "show help"
|
50
|
+
task :help do
|
51
|
+
# script/delayed_job --help が exitstatus が 0 でないので明示的に無視します
|
52
|
+
system_at_vendor_fontana!("#{cmd_base} script/delayed_job --help; echo ''")
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'fontana_client_support'
|
2
|
+
include Fontana::ServerRake
|
3
|
+
|
4
|
+
namespace_with_fontana :factory_girl, :"app_seed:generate" do
|
5
|
+
|
6
|
+
# desc "generate spec/support/models files"
|
7
|
+
fontana_task :spec_support_models, env: {
|
8
|
+
"SPEC_SUPPORT_MODELS_DIR" => File.expand_path("spec/support/models", FontanaClientSupport.root_dir)
|
9
|
+
}
|
10
|
+
|
11
|
+
# desc "generate spec/factories files"
|
12
|
+
fontana_task :spec_factories, env: {
|
13
|
+
"SPEC_FACTORIES_DIR" => File.expand_path("spec/factories", FontanaClientSupport.root_dir)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "generate spec/support/models files and spec/factories files"
|
18
|
+
task :factory_girl => [:"factory_girl:spec_support_models", :"factory_girl:spec_factories"]
|
@@ -14,19 +14,16 @@ namespace :vendor do
|
|
14
14
|
d = FontanaClientSupport.vendor_fontana
|
15
15
|
if Dir.exist?(d)
|
16
16
|
Dir.chdir(d) do
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
t.split(/\s*:\s*/, 2).last
|
21
|
-
else
|
22
|
-
nil
|
23
|
-
end
|
17
|
+
# http://qiita.com/sugyan/items/83e060e895fa8ef2038c
|
18
|
+
s = `git describe --tags`
|
19
|
+
s.scan(/\A(v\d+\.\d+\.\d+)/).flatten.first
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
28
24
|
def vendor_fontana_branch
|
29
|
-
|
25
|
+
# http://qiita.com/sugyan/items/83e060e895fa8ef2038c
|
26
|
+
`git symbolic-ref --short HEAD`.strip
|
30
27
|
end
|
31
28
|
|
32
29
|
def raise_if_fontana_branch_empty
|
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.8.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-09-
|
11
|
+
date: 2013-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,8 +110,10 @@ files:
|
|
110
110
|
- lib/fontana_client_support/tasks/app_seed.rake
|
111
111
|
- lib/fontana_client_support/tasks/config_server.rake
|
112
112
|
- lib/fontana_client_support/tasks/db.rake
|
113
|
+
- lib/fontana_client_support/tasks/delayed_job.rake
|
113
114
|
- lib/fontana_client_support/tasks/deploy/scm.rake
|
114
115
|
- lib/fontana_client_support/tasks/deploy/sync.rake
|
116
|
+
- lib/fontana_client_support/tasks/factory_girl.rake
|
115
117
|
- lib/fontana_client_support/tasks/fixtures.rake
|
116
118
|
- lib/fontana_client_support/tasks/init.rake
|
117
119
|
- lib/fontana_client_support/tasks/server.rake
|