gordon 0.0.21 → 0.1.0

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
  SHA1:
3
- metadata.gz: 92355b0ef213be4b1cf55eceeea64e67c32e13f3
4
- data.tar.gz: 8f4257916fc921dd70dc09168684965551d7d923
3
+ metadata.gz: 2302a6d87784b1ca55883765df7fb291a46d89cf
4
+ data.tar.gz: a61805f3bccaa4cf6a57b9059bb8bd8965cea903
5
5
  SHA512:
6
- metadata.gz: 97f28ad1766b41487f41716a0347e78b029046151c926f6324b3aa8e4350b3d63319e1a5d313e38c4a8c4d2c24f3c535bfb89f1d4cbb7899e73022e7724cbd6a
7
- data.tar.gz: 6d384435ab5c0e29b19ccd19d956e0d89163e3ca3dbc76c78bdbd8c1f05410c959c27a9e07f60b8e7bfdde62124b8601ec7d64369871f3c74c6564d84c7ffb87
6
+ metadata.gz: 9468e34edace9a9e4f78150b782c7c724209a952c947b74c194affafd74bb5ce9e7157aeac7674f217f935880882d23fdba08f74df19800fcdff782b26e1b12c
7
+ data.tar.gz: a9ebb25612ba992deda25d8d8f2915e95a98b262f487f337e48d0cc6c8dfc6d52a7149ba5a07daa0e890ae5dc256268291fe90c1e30efaf438c521e3d6eaef27
data/README.md CHANGED
@@ -26,13 +26,14 @@ Per example: create a user that will run app with credentials, whose $HOME is th
26
26
 
27
27
  * Web Servers: Tomcat or Jetty;
28
28
 
29
- * Init scripts: Systemd (all generated by Foreman soon);
29
+ * Init scripts: Systemd;
30
30
 
31
31
  * Apps supported:
32
32
 
33
33
  * Ruby Web (resides based on Http Server of choice)
34
34
  * Ruby Standalone (resides on /opt/*app_name*)
35
35
  * Java Web (resides based on Web Server of choice)
36
+ * Java Standalone (resides on /opt/*app_name*)
36
37
 
37
38
  ## Installation
38
39
 
@@ -50,6 +51,51 @@ Or install it yourself as:
50
51
 
51
52
  ## Usage
52
53
 
54
+ Gordon have two ways to package applications. You can create a yaml file called `gordon.yml` on root of your app. Here an example:
55
+
56
+ ```
57
+ recipes:
58
+ # web app
59
+ - app_name: web-app
60
+ app_description: web-app
61
+ app_homepage: https://github.com/web/app
62
+ app_type: web
63
+ app_source: web-app/
64
+ app_source_excludes:
65
+ - log
66
+ - tmp
67
+
68
+ runtime_name: ruby
69
+ runtime_version: 2.2.2
70
+ http_server_type: nginx
71
+ init_type: systemd
72
+
73
+ package_type: rpm
74
+ output_dir: pkg
75
+
76
+ # standalone app
77
+ - app_name: standalone-app
78
+ app_description: standalone-app
79
+ app_homepage: https://github.com/standalone/app
80
+ app_type: standalone
81
+ app_source: standalone-app/
82
+ app_source_excludes:
83
+ - classes
84
+
85
+ runtime_name: oracle-jre
86
+ runtime_version: 1.8.0_45
87
+
88
+ package_type: rpm
89
+ output_dir: pkg
90
+
91
+ ```
92
+
93
+ For more details about all parameters available, please run `gordon --help` for more details.
94
+
95
+ Another way is using CLI directly. Below some examples how to use it.
96
+
97
+ ### Usage: Packing a Ruby Web Application
98
+
53
99
  First, you need to vendorize all gems in deployment mode:
54
100
 
55
101
  $ ruby -S bundle package --all
@@ -60,8 +106,8 @@ Here a simple example to build a Ruby Web App that runs Nginx and uses Systemd a
60
106
 
61
107
  $ ruby -S gordon \
62
108
  --app-type web \
63
- --app-name my-app \
64
- --app-description "my app" \
109
+ --app-name my-ruby-app \
110
+ --app-description "my ruby app" \
65
111
  --app-homepage https://github.com/myuser/my-app \
66
112
  --app-version 1.0.0 \
67
113
  --app-source . \
@@ -80,20 +126,46 @@ It will generate a RPM package in pkg/ with the following structure:
80
126
 
81
127
  Due for conventions, remember:
82
128
 
83
- * /usr/share/nginx/html is $HOME of user *app-name*
129
+ * /usr/share/nginx/html is $HOME of user *app-name*;
84
130
  * Systemd will run app using user *app-name.target*
85
131
 
86
132
  Sounds good?
87
133
 
88
- ## And for Java Web applications?
134
+ ### Usage: Java Web Application
89
135
 
90
136
  First, generate war files. After, do the following steps:
91
137
 
92
- * Set `--app-source` with the path of war file;
93
- * Set `--runtime-name` to java-oracle (only for CentOS platform at this time) or java-openjdk;
94
- * Set `--runtime-version` (1.7.0_60, 1.8.0_31; Gordon checks and inject correct version into package metadata).
95
- * Set `--web-server-type` to `tomcat` or `jetty`;
96
- * You can avoid `--init-type` because war files are handled by application server of choice (Tomcat or Jetty).
138
+ $ ruby -S gordon \
139
+ --app-type web \
140
+ --app-name my-java-app \
141
+ --app-description "my java app" \
142
+ --app-homepage https://github.com/myuser/my-app \
143
+ --app-version 1.0.0 \
144
+ --app-source path/of/application.war \
145
+ --runtime-name oracle-jdk \
146
+ --runtime-version 1.8.0_45 \
147
+ --http-server-type apache \
148
+ --web-server-type tomcat \
149
+ --package-type rpm \
150
+ --output pkg
151
+
152
+ You must avoid `--init-type` because war files are handled by application server of choice (Tomcat or Jetty).
153
+
154
+ ## Usage: Java Standalone Application
155
+
156
+ Generate jar files before and after pass some parameters:
157
+
158
+ $ ruby -S gordon \
159
+ --app-type web \
160
+ --app-name my-java-standalone-app \
161
+ --app-description "my java standalone app" \
162
+ --app-homepage https://github.com/myuser/my-app \
163
+ --app-version 1.0.0 \
164
+ --app-source path/of/application.jar \
165
+ --runtime-name oracle-jdk \
166
+ --runtime-version 1.8.0_45 \
167
+ --package-type rpm \
168
+ --output pkg
97
169
 
98
170
  ## Why you not use Omnibus or Heroku buildpacks?
99
171
 
@@ -113,9 +185,10 @@ Because I like Gordon Ramsay.
113
185
 
114
186
  ## TODO
115
187
 
116
- * Add Oracle JRE support for Debian (oracle-jre-installer?)
117
- * Validate inputs
118
188
  * Debian check (gem heavly developed under CentOS environment)
189
+ * Export init files to other formats supported by foreman;
190
+ * Add Oracle JRE / JDK support for Debian (maybe oracle-jre-installer?)
191
+ * Validate inputs
119
192
 
120
193
  ## Contributing
121
194
 
data/gordon.gemspec CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "rake"
22
22
  spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "byebug"
24
+ spec.add_development_dependency "simplecov"
23
25
 
24
26
  spec.add_dependency "fpm-cookery"
25
27
  spec.add_dependency "foreman"
@@ -5,7 +5,7 @@ module Gordon
5
5
  namespace = "Application::Types"
6
6
 
7
7
  runtime_name = options.runtime_name
8
- runtime_name = :java if runtime_name =~ /java/
8
+ runtime_name = :java if runtime_name =~ /j(dk|re)/
9
9
  application_type = "#{runtime_name}_#{options.app_type}_app"
10
10
 
11
11
  ::Gordon::Factory.create_instance(namespace, application_type)
@@ -0,0 +1,43 @@
1
+ path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib'))
2
+ $LOAD_PATH.unshift path
3
+
4
+ require 'gordon'
5
+
6
+ $env_vars = Gordon::EnvVars.load
7
+
8
+ class JavaStandaloneApp < FPM::Cookery::Recipe
9
+ extend Gordon::Cookery::DependencyResolver
10
+
11
+ include Gordon::Cookery::Common,
12
+ Gordon::Cookery::Init,
13
+ Gordon::Cookery::Log,
14
+ Gordon::Cookery::ApplicationUser,
15
+ Gordon::Cookery::Standalone,
16
+ Gordon::Cookery::Java::Common
17
+
18
+ name $env_vars.app_name
19
+ description $env_vars.app_description
20
+ version $env_vars.app_version
21
+ homepage $env_vars.app_homepage
22
+
23
+ source $env_vars.app_source, with: :local_path
24
+
25
+ depends *resolve_dependencies($env_vars, platform)
26
+
27
+ fpm_attributes["#{FPM::Cookery::Facts.target}_user".to_sym] = $env_vars.app_name
28
+ fpm_attributes["#{FPM::Cookery::Facts.target}_group".to_sym] = $env_vars.app_name
29
+
30
+ def build
31
+ home_path = get_skeleton_path_from_type($env_vars, :misc)
32
+
33
+ create_user_and_group($env_vars, home_path)
34
+ setup_user_permissions($env_vars, home_path)
35
+ end
36
+
37
+ def install
38
+ create_log_folder($env_vars)
39
+
40
+ install_standalone_files($env_vars, JAVA_BLACKLIST_FILES)
41
+ end
42
+ end
43
+
data/lib/gordon/cli.rb CHANGED
@@ -10,8 +10,8 @@ module Gordon
10
10
  parser = create_option_parser(options)
11
11
  parser.parse!
12
12
 
13
- recipe = Recipe.new(options)
14
- cooker = Cooker.new(recipe)
13
+ recipes = Cookbook.exists? ? Cookbook.read_and_merge_with(options) : [ Recipe.new(options) ]
14
+ cooker = Cooker.new(recipes)
15
15
  cooker.cook
16
16
  end
17
17
 
@@ -39,6 +39,10 @@ module Gordon
39
39
  options.app_source = app_source
40
40
  end
41
41
 
42
+ opts.on('-E', '--app-source-excludes APP_SOURCE_EXCLUDES', 'Application Source Excludes List') do |app_source_excludes|
43
+ options.app_source_excludes = app_source_excludes
44
+ end
45
+
42
46
  opts.on('-T', '--app-type APP_TYPE', 'Application Type') do |app_type|
43
47
  options.app_type = app_type
44
48
  end
@@ -0,0 +1,29 @@
1
+ require 'yaml'
2
+ require 'erb'
3
+
4
+ module Gordon
5
+ class Cookbook
6
+ def self.exists?
7
+ File.exists?(self.get_path)
8
+ end
9
+
10
+ def self.read_and_merge_with(main_options)
11
+ path = self.get_path
12
+ body = File.read(path)
13
+ yaml = ERB.new(body)
14
+ data = YAML.load(yaml.result)
15
+
16
+ data['recipes'].map do |recipe|
17
+ option = Options.from(main_options, recipe)
18
+ Recipe.new(option)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def self.get_path
25
+ File.join(Dir.pwd, 'gordon.yml')
26
+ end
27
+ end
28
+ end
29
+
data/lib/gordon/cooker.rb CHANGED
@@ -2,39 +2,42 @@ require 'fileutils'
2
2
 
3
3
  module Gordon
4
4
  class Cooker
5
- attr_reader :recipe, :options
5
+ attr_reader :recipes
6
6
 
7
7
  FPM_COOKERY_COMMAND = 'fpm-cook'
8
8
  FPM_COOKERY_WORKING_DIR = '/tmp/gordon'
9
9
 
10
- def initialize(recipe)
11
- @recipe = recipe
12
- @options = recipe.options
10
+ def initialize(recipes)
11
+ @recipes = recipes
13
12
  end
14
13
 
15
14
  def cook
16
- clean
17
- package
15
+ recipes.each do |recipe|
16
+ options = recipe.options
17
+
18
+ clean(options)
19
+ package(recipe, options)
20
+ end
18
21
  end
19
22
 
20
23
  private
21
24
 
22
- def clean
25
+ def clean(options)
23
26
  # fpm-cook clean command only cleans tmp-build and tmp-dest folders
24
27
  # and don't include cache dir :(
25
- FileUtils.rm_rf(get_working_path)
28
+ FileUtils.rm_rf(get_working_path(options))
26
29
  end
27
30
 
28
- def package
29
- cook_args = get_command_args
31
+ def package(recipe, options)
32
+ cook_args = get_command_args(options)
30
33
 
31
34
  cook_args << "package"
32
35
  cook_args << recipe.application_template_path
33
36
 
34
- execute(cook_args)
37
+ execute(cook_args, options)
35
38
  end
36
39
 
37
- def get_working_path
40
+ def get_working_path(options)
38
41
  app_path = File.expand_path(options.app_source)
39
42
  app_name = File.basename(app_path)
40
43
  tmp_path = File.join(FPM_COOKERY_WORKING_DIR, app_name)
@@ -42,21 +45,21 @@ module Gordon
42
45
  tmp_path
43
46
  end
44
47
 
45
- def get_command_args
48
+ def get_command_args(options)
46
49
  cook_args = []
47
50
 
48
51
  cook_args << "--debug" if options.debug
49
52
 
50
53
  cook_args << "--target #{options.package_type}"
51
54
  cook_args << "--pkg-dir #{File.expand_path(options.output_dir)}"
52
- cook_args << "--cache-dir #{File.expand_path(get_working_path)}"
53
- cook_args << "--tmp-root #{File.expand_path(get_working_path)}"
55
+ cook_args << "--cache-dir #{File.expand_path(get_working_path(options))}"
56
+ cook_args << "--tmp-root #{File.expand_path(get_working_path(options))}"
54
57
  cook_args << "--no-deps"
55
58
 
56
59
  cook_args
57
60
  end
58
61
 
59
- def execute(cook_args)
62
+ def execute(cook_args, options)
60
63
  env_vars = EnvVars.from_cook(options)
61
64
 
62
65
  command = "#{env_vars.join " "} #{FPM_COOKERY_COMMAND} #{cook_args.join " "}"
@@ -7,9 +7,9 @@ module Gordon
7
7
  dependencies = []
8
8
 
9
9
  dependencies << get_runtime_package_name(env_vars, platform)
10
- dependencies << get_http_server_package_name(env_vars, platform) unless env_vars.http_server_type.empty?
11
- dependencies << get_init_package_name(env_vars, platform) unless env_vars.init_type.empty?
12
- dependencies << get_web_server_package_name(env_vars, platform) unless env_vars.web_server_type.empty?
10
+ dependencies << get_http_server_package_name(env_vars, platform) unless env_vars.http_server_type.to_s.empty?
11
+ dependencies << get_init_package_name(env_vars, platform) unless env_vars.init_type.to_s.empty?
12
+ dependencies << get_web_server_package_name(env_vars, platform) unless env_vars.web_server_type.to_s.empty?
13
13
 
14
14
  dependencies.collect(&:to_s)
15
15
  end
@@ -19,7 +19,7 @@ module Gordon
19
19
  def get_runtime_package_name(env_vars, platform)
20
20
  runtime_name, runtime_version = env_vars.runtime_name, env_vars.runtime_version
21
21
 
22
- if runtime_name =~ /java/
22
+ if runtime_name =~ /j(dk|re)/
23
23
  package_name = get_java_package_name(runtime_name, runtime_version, platform)
24
24
  else
25
25
  package_name = "#{runtime_name} = #{runtime_version}"
@@ -32,26 +32,40 @@ module Gordon
32
32
  centos = platform == :centos
33
33
 
34
34
  if runtime_name =~ /oracle/ && centos
35
- if damn_oracle_8_jre?(runtime_version)
36
- package_name = "jre#{runtime_version}"
37
- else
38
- package_name = "jre = #{runtime_version}"
39
- end
35
+ package_name = get_oracle_package_name(runtime_name, runtime_version)
40
36
  else
41
- if centos
42
- package_name = "java-#{runtime_version[0..4]}-openjdk"
43
- else
44
- package_name = "openjdk-#{runtime_version[2]}-jre"
45
- end
37
+ package_name = get_osjava_package_name(runtime_name, runtime_version, centos)
46
38
  end
47
39
 
48
40
  package_name
49
41
  end
50
42
 
51
- def damn_oracle_8_jre?(runtime_version)
43
+ def oracle_8_version?(runtime_version)
52
44
  runtime_version[2].to_s == '8'
53
45
  end
54
46
 
47
+ def get_oracle_package_name(runtime_name, runtime_version)
48
+ package_type = runtime_name =~ /jre/ ? :jre : :jdk
49
+
50
+ if oracle_8_version?(runtime_version)
51
+ package_name = "#{package_type}#{runtime_version}"
52
+ else
53
+ package_name = "#{package_type} = #{runtime_version}"
54
+ end
55
+
56
+ package_name
57
+ end
58
+
59
+ def get_osjava_package_name(runtime_name, runtime_version, is_centos)
60
+ if is_centos
61
+ package_name = "java-#{runtime_version[0..4]}-openjdk"
62
+ else
63
+ package_name = "openjdk-#{runtime_version[2]}-jre"
64
+ end
65
+
66
+ package_name
67
+ end
68
+
55
69
  def get_http_server_package_name(env_vars, platform)
56
70
  get_os_package_name(env_vars, :http_server_type, platform)
57
71
  end
@@ -6,7 +6,9 @@ module Gordon
6
6
  def install_http_server_files(env_vars, blacklist)
7
7
  skeleton_path = get_skeleton_path_from_type(env_vars, env_vars.http_server_type)
8
8
 
9
- application_files = all_files_except_blacklisted(blacklist)
9
+ app_source_excludes = env_vars.app_source_excludes
10
+
11
+ application_files = all_files_except_blacklisted(blacklist, app_source_excludes)
10
12
 
11
13
  root(skeleton_path).install application_files
12
14
  end
@@ -6,7 +6,9 @@ module Gordon
6
6
  def install_standalone_files(env_vars, blacklist)
7
7
  skeleton_path = get_skeleton_path_from_type(env_vars, :misc)
8
8
 
9
- application_files = all_files_except_blacklisted(blacklist)
9
+ app_source_excludes = env_vars.app_source_excludes
10
+
11
+ application_files = all_files_except_blacklisted(blacklist, app_source_excludes)
10
12
 
11
13
  root(skeleton_path).install application_files
12
14
  end
@@ -6,7 +6,9 @@ module Gordon
6
6
  def install_web_server_files(env_vars, blacklist)
7
7
  skeleton_path = get_skeleton_path_from_type(env_vars, env_vars.web_server_type)
8
8
 
9
- application_files = all_files_except_blacklisted(blacklist)
9
+ app_source_excludes = env_vars.app_source_excludes
10
+
11
+ application_files = all_files_except_blacklisted(blacklist, app_source_excludes)
10
12
 
11
13
  root(skeleton_path).install application_files
12
14
  end
@@ -1,7 +1,6 @@
1
1
  module Gordon
2
2
  class EnvVars
3
- attr_accessor :app_type
4
- attr_accessor :app_name, :app_description, :app_homepage, :app_version, :app_source
3
+ attr_accessor :app_name, :app_description, :app_homepage, :app_version, :app_source, :app_source_excludes, :app_type
5
4
  attr_accessor :runtime_name, :runtime_version
6
5
  attr_accessor :http_server_type
7
6
  attr_accessor :web_server_type
@@ -9,13 +8,13 @@ module Gordon
9
8
 
10
9
  def self.from_cook(options)
11
10
  env_vars = []
12
-
13
11
  env_vars << "GORDON_APP_TYPE='#{options.app_type}'"
14
12
  env_vars << "GORDON_APP_NAME='#{options.app_name}'"
15
13
  env_vars << "GORDON_APP_DESCRIPTION='#{options.app_description}'"
16
14
  env_vars << "GORDON_APP_HOMEPAGE='#{options.app_homepage}'"
17
15
  env_vars << "GORDON_APP_VERSION='#{options.app_version}'"
18
16
  env_vars << "GORDON_APP_SOURCE='#{File.expand_path(options.app_source)}'"
17
+ env_vars << "GORDON_APP_SOURCE_EXCLUDES='#{options.app_source_excludes.to_a.map { |path| File.expand_path(path)}.join(",") }'"
19
18
  env_vars << "GORDON_RUNTIME_NAME='#{options.runtime_name}'"
20
19
  env_vars << "GORDON_RUNTIME_VERSION='#{options.runtime_version}'"
21
20
  env_vars << "GORDON_HTTP_SERVER_TYPE='#{options.http_server_type}'"
@@ -28,17 +27,18 @@ module Gordon
28
27
  def self.load
29
28
  env_vars = self.new
30
29
 
31
- env_vars.app_type = ENV['GORDON_APP_TYPE']
32
- env_vars.app_name = ENV['GORDON_APP_NAME']
33
- env_vars.app_description = ENV['GORDON_APP_DESCRIPTION']
34
- env_vars.app_homepage = ENV['GORDON_APP_HOMEPAGE']
35
- env_vars.app_version = ENV['GORDON_APP_VERSION']
36
- env_vars.app_source = ENV['GORDON_APP_SOURCE']
37
- env_vars.runtime_name = ENV['GORDON_RUNTIME_NAME']
38
- env_vars.runtime_version = ENV['GORDON_RUNTIME_VERSION']
39
- env_vars.http_server_type = ENV['GORDON_HTTP_SERVER_TYPE']
40
- env_vars.web_server_type = ENV['GORDON_WEB_SERVER_TYPE']
41
- env_vars.init_type = ENV['GORDON_INIT_TYPE']
30
+ env_vars.app_type = ENV['GORDON_APP_TYPE']
31
+ env_vars.app_name = ENV['GORDON_APP_NAME']
32
+ env_vars.app_description = ENV['GORDON_APP_DESCRIPTION']
33
+ env_vars.app_homepage = ENV['GORDON_APP_HOMEPAGE']
34
+ env_vars.app_version = ENV['GORDON_APP_VERSION']
35
+ env_vars.app_source = ENV['GORDON_APP_SOURCE']
36
+ env_vars.app_source_excludes = ENV['GORDON_APP_SOURCE_EXCLUDES'].to_s.split(",")
37
+ env_vars.runtime_name = ENV['GORDON_RUNTIME_NAME']
38
+ env_vars.runtime_version = ENV['GORDON_RUNTIME_VERSION']
39
+ env_vars.http_server_type = ENV['GORDON_HTTP_SERVER_TYPE']
40
+ env_vars.web_server_type = ENV['GORDON_WEB_SERVER_TYPE']
41
+ env_vars.init_type = ENV['GORDON_INIT_TYPE']
42
42
 
43
43
  env_vars
44
44
  end
@@ -1,7 +1,6 @@
1
1
  module Gordon
2
2
  class Options
3
- attr_accessor :app_name, :app_description, :app_homepage, :app_version, :app_source
4
- attr_accessor :app_type
3
+ attr_accessor :app_name, :app_description, :app_homepage, :app_version, :app_source, :app_source_excludes, :app_type
5
4
  attr_accessor :runtime_name, :runtime_version
6
5
  attr_accessor :http_server_type
7
6
  attr_accessor :web_server_type
@@ -9,5 +8,32 @@ module Gordon
9
8
  attr_accessor :package_type
10
9
  attr_accessor :output_dir
11
10
  attr_accessor :debug, :trace
11
+
12
+ def self.from(main_options, recipe)
13
+ self.new.tap do |opt|
14
+ opt.app_type = main_options.app_type || recipe['app_type']
15
+ opt.app_name = main_options.app_name || recipe['app_name']
16
+ opt.app_description = main_options.app_description || recipe['app_description']
17
+ opt.app_homepage = main_options.app_homepage || recipe['app_homepage']
18
+ opt.app_version = main_options.app_version || recipe['app_version']
19
+ opt.app_source = recipe['app_source'] || main_options.app_source
20
+
21
+ opt.app_source_excludes = (main_options.app_source_excludes.to_a + recipe['app_source_excludes'].to_a).flatten
22
+
23
+ opt.runtime_name = main_options.runtime_name || recipe['runtime_name']
24
+ opt.runtime_version = main_options.runtime_version || recipe['runtime_version']
25
+
26
+ opt.http_server_type = main_options.http_server_type || recipe['http_server_type']
27
+ opt.web_server_type = main_options.web_server_type || recipe['web_server_type']
28
+ opt.init_type = main_options.init_type || recipe['init_type']
29
+
30
+ opt.package_type = main_options.package_type || recipe['package_type']
31
+ opt.output_dir = main_options.output_dir || recipe['output_dir']
32
+
33
+ opt.debug = !main_options.debug.nil? ? main_options.debug : recipe['debug']
34
+ opt.trace = !main_options.trace.nil? ? main_options.trace : recipe['trace']
35
+ end
36
+ end
12
37
  end
13
38
  end
39
+
@@ -1,3 +1,3 @@
1
1
  module Gordon
2
- VERSION = "0.0.21"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/gordon.rb CHANGED
@@ -2,6 +2,7 @@ require "gordon/version"
2
2
 
3
3
  module Gordon
4
4
  require 'gordon/cli'
5
+ require 'gordon/cookbook'
5
6
  require 'gordon/cooker'
6
7
  require 'gordon/recipe'
7
8
  require 'gordon/env_vars'
@@ -1,10 +1,56 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Gordon::Application::Factory do
4
- let(:options) { instance_double Gordon::Options, app_type: :web, runtime_name: :java }
4
+ let(:options) { instance_double(Gordon::Options) }
5
5
 
6
- it 'returns a instance of specified runtime and type' do
7
- expect(described_class.create(options)).to be_instance_of(Gordon::Application::Types::JavaWebApp)
6
+ shared_examples_for 'a instance of specified runtime and type' do |expected_class|
7
+ it 'returns a instance of specified runtime and type' do
8
+ expect(described_class.create(options)).to be_instance_of(expected_class)
9
+ end
10
+ end
11
+
12
+ describe 'ruby' do
13
+ before :each do
14
+ allow(options).to receive(:runtime_name).and_return(:ruby)
15
+ end
16
+
17
+ context 'web' do
18
+ before :each do
19
+ allow(options).to receive(:app_type).and_return(:web)
20
+ end
21
+
22
+ it_behaves_like 'a instance of specified runtime and type', Gordon::Application::Types::RubyWebApp
23
+ end
24
+
25
+ context 'standalone' do
26
+ before :each do
27
+ allow(options).to receive(:app_type).and_return(:standalone)
28
+ end
29
+
30
+ it_behaves_like 'a instance of specified runtime and type', Gordon::Application::Types::RubyStandaloneApp
31
+ end
32
+ end
33
+
34
+ describe 'java' do
35
+ before :each do
36
+ allow(options).to receive(:runtime_name).and_return('oracle-jdk')
37
+ end
38
+
39
+ context 'web' do
40
+ before :each do
41
+ allow(options).to receive(:app_type).and_return(:web)
42
+ end
43
+
44
+ it_behaves_like 'a instance of specified runtime and type', Gordon::Application::Types::JavaWebApp
45
+ end
46
+
47
+ context 'standalone' do
48
+ before :each do
49
+ allow(options).to receive(:app_type).and_return(:standalone)
50
+ end
51
+
52
+ it_behaves_like 'a instance of specified runtime and type', Gordon::Application::Types::JavaStandaloneApp
53
+ end
8
54
  end
9
55
  end
10
56
 
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'JavaStandaloneApp' do
4
+ describe 'setup' do
5
+ pending
6
+ end
7
+
8
+ describe 'building' do
9
+ pending
10
+ end
11
+
12
+ describe 'installing' do
13
+ pending
14
+ end
15
+ end
16
+