gordon 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -7
  3. data/gordon.gemspec +0 -1
  4. data/lib/gordon/application/templates/java_web_app.rb +6 -4
  5. data/lib/gordon/application/templates/ruby_standalone_app.rb +4 -6
  6. data/lib/gordon/application/templates/ruby_web_app.rb +4 -6
  7. data/lib/gordon/application/types.rb +1 -1
  8. data/lib/gordon/cli.rb +15 -11
  9. data/lib/gordon/cooker.rb +4 -4
  10. data/lib/gordon/cookery/application_user.rb +1 -1
  11. data/lib/gordon/cookery/common.rb +7 -6
  12. data/lib/gordon/cookery/dependency_resolver.rb +8 -2
  13. data/lib/gordon/cookery/http_server.rb +3 -1
  14. data/lib/gordon/cookery/init.rb +5 -3
  15. data/lib/gordon/cookery/java/common.rb +0 -1
  16. data/lib/gordon/cookery/ruby/common.rb +0 -8
  17. data/lib/gordon/cookery/standalone.rb +3 -1
  18. data/lib/gordon/cookery/web_server.rb +3 -1
  19. data/lib/gordon/env_vars.rb +11 -8
  20. data/lib/gordon/exceptions.rb +10 -0
  21. data/lib/gordon/options.rb +3 -4
  22. data/lib/gordon/process.rb +5 -1
  23. data/lib/gordon/recipe.rb +1 -1
  24. data/lib/gordon/skeleton/types.rb +7 -0
  25. data/lib/gordon/version.rb +1 -1
  26. data/lib/gordon.rb +1 -0
  27. data/spec/gordon/application/types_spec.rb +48 -0
  28. data/spec/gordon/cli_spec.rb +63 -3
  29. data/spec/gordon/cooker_spec.rb +81 -4
  30. data/spec/gordon/cookery/application_user_spec.rb +59 -2
  31. data/spec/gordon/cookery/common_spec.rb +72 -5
  32. data/spec/gordon/cookery/dependency_resolver_spec.rb +58 -1
  33. data/spec/gordon/cookery/http_server_spec.rb +26 -1
  34. data/spec/gordon/cookery/init_spec.rb +52 -2
  35. data/spec/gordon/cookery/java/common_spec.rb +6 -2
  36. data/spec/gordon/cookery/java/web_app_spec.rb +33 -1
  37. data/spec/gordon/cookery/ruby/common_spec.rb +6 -2
  38. data/spec/gordon/cookery/standalone_spec.rb +25 -1
  39. data/spec/gordon/cookery/web_server_spec.rb +33 -0
  40. data/spec/gordon/env_vars_spec.rb +14 -11
  41. data/spec/gordon/factory_spec.rb +15 -1
  42. data/spec/gordon/options_spec.rb +1 -1
  43. data/spec/gordon/process_spec.rb +18 -1
  44. data/spec/gordon/recipe_spec.rb +13 -2
  45. data/spec/gordon/skeleton/types_spec.rb +147 -7
  46. metadata +8 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f6c92da32b5f718a9c6e40061d550a397e44e1d
4
- data.tar.gz: 58e7c34da8d28dc869589d2c9b52a19a45e2a95f
3
+ metadata.gz: b94b6c833eb2861fc1812fd735636616d07f51ac
4
+ data.tar.gz: b9f06696a7edd532fb343e4c3a184744b6a8ab9e
5
5
  SHA512:
6
- metadata.gz: c13ff0c341f5787bd0db48d1fc6cf85546efcb06b39334a7e93d5a9af5ec9b8f10c3893846593508c4379673b583b96152f33742d837bef0f1258bfcfbbe8dd3
7
- data.tar.gz: a81f165ee34ee5a8bc3595812e94e7f26c5747083ad55c66c59c86b41168e788be10b21f6bc5e169c5df92209ff281c72bb47c4e82ff9cc3b9730a498ea3a9e2
6
+ metadata.gz: 445412f2ba34785a24825b292811bf835677bfa106f9fa1e97e7e45c0ab4d6a962fa7a2bfe1b8128311dc6de97ac3cf2491c2bcd39eaa83cd18952e87e68288f
7
+ data.tar.gz: 32a14736b4795a14a46b46d426b8322512f8866cc11d7d74e0a8cd9edbc3c6a7b42e461ae652b96414d5649b0328ad6a97fdb441ff705674fdff41211b91dec8
data/README.md CHANGED
@@ -22,9 +22,17 @@ Per example: create a user that will run app with credentials, whose $HOME is th
22
22
 
23
23
  ## How are the options?
24
24
 
25
- * Web Servers: Nginx or Apache (Tomcat soon);
25
+ * Http Servers: Nginx or Apache;
26
+
27
+ * Web Servers: Tomcat or Jetty;
28
+
26
29
  * Init scripts: Systemd (all generated by Foreman soon);
27
- * Apps supported: at this time, Ruby Web App. Java soon and others when needed.
30
+
31
+ * Apps supported:
32
+
33
+ * Ruby Web App (resides based on Http Server of choice)
34
+ * Ruby Standalone App (resides on /opt/*app_name*)
35
+ * Java Web App (resides based on Web Server of choice)
28
36
 
29
37
  ## Installation
30
38
 
@@ -42,15 +50,21 @@ Or install it yourself as:
42
50
 
43
51
  ## Usage
44
52
 
53
+ First, you need to vendorize all gems in deployment mode:
54
+
55
+ $ ruby -S bundle package --all
56
+
57
+ $ ruby -S bundle install --deployment --without development test debug
58
+
45
59
  Here a simple example to build a Ruby Web App that runs Nginx and uses Systemd as init process. Just enter on source folder of your app and run in your terminal:
46
60
 
47
61
  $ ruby -S gordon \
48
62
  --app-type ruby_web_app \
49
63
  --app-name $APP_NAME \
50
64
  --app-desc $APP_DESC \
51
- --app-repo $APP_REPO \
65
+ --app-home $APP_HOME \
52
66
  --app-version $APP_VERSION \
53
- --app-source-dir . \
67
+ --app-source . \
54
68
  --runtime-version $MRI_VERSION \
55
69
  --http-server-type nginx \
56
70
  --init-type systemd \
@@ -71,7 +85,7 @@ Sounds good?
71
85
 
72
86
  ## Why you not use Omnibus or Heroku buildpacks?
73
87
 
74
- Because I want to create a tool able to create Linux packages.
88
+ Because I want a tool able to create Linux packages that can be extensible based on my needs.
75
89
 
76
90
  ## Why you use fpm-cookery templates instead of fpm?
77
91
 
@@ -84,8 +98,8 @@ Because I like Gordon Ramsay.
84
98
  ## TODO
85
99
 
86
100
  * Validate outputs
87
- * Tests
88
- * Very unstable, need to fix it
101
+ * Refactor to have only one FPM::Cookery recipe.
102
+ * Integrate directly with FPM::Cookery classes
89
103
  * Debian check (gem heavly developed under CentOS environment)
90
104
 
91
105
  ## Contributing
@@ -95,3 +109,4 @@ Because I like Gordon Ramsay.
95
109
  3. Commit your changes (`git commit -am 'Add some feature'`)
96
110
  4. Push to the branch (`git push origin my-new-feature`)
97
111
  5. Create new Pull Request
112
+
data/gordon.gemspec CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "rake"
22
22
  spec.add_development_dependency "rspec"
23
23
 
24
- spec.add_dependency "bundler"
25
24
  spec.add_dependency "fpm-cookery"
26
25
  spec.add_dependency "foreman"
27
26
  end
@@ -14,12 +14,12 @@ class JavaWebApp < FPM::Cookery::Recipe
14
14
  Gordon::Cookery::Java::WebApp
15
15
 
16
16
  name $env_vars.app_name
17
- description $env_vars.app_desc
17
+ description $env_vars.app_description
18
18
  version $env_vars.app_version
19
- homepage $env_vars.app_repo
19
+ homepage $env_vars.app_homepage
20
20
  arch :noarch
21
21
 
22
- source $env_vars.app_source_dir, with: :local_path
22
+ source $env_vars.app_source, with: :local_path
23
23
 
24
24
  depends *resolve_dependencies($env_vars)
25
25
 
@@ -27,7 +27,9 @@ class JavaWebApp < FPM::Cookery::Recipe
27
27
  fpm_attributes[:rpm_group] = 'tomcat'
28
28
 
29
29
  def build
30
- war_path = File.join(get_skeleton_path_from_type($env_vars.web_server_type), $env_vars.app_name)
30
+ web_server_path = get_skeleton_path_from_type($env_vars, $env_vars.web_server_type)
31
+
32
+ war_path = File.join(web_server_path, $env_vars.app_name)
31
33
 
32
34
  clean_java_web_workdir($env_vars, war_path)
33
35
  end
@@ -15,23 +15,21 @@ class RubyStandaloneApp < FPM::Cookery::Recipe
15
15
  Gordon::Cookery::Ruby::Common
16
16
 
17
17
  name $env_vars.app_name
18
- description $env_vars.app_desc
18
+ description $env_vars.app_description
19
19
  version $env_vars.app_version
20
- homepage $env_vars.app_repo
20
+ homepage $env_vars.app_homepage
21
21
 
22
- source $env_vars.app_source_dir, with: :local_path
22
+ source $env_vars.app_source, with: :local_path
23
23
 
24
24
  depends *resolve_dependencies($env_vars)
25
25
 
26
26
  def build
27
- home_path = get_skeleton_path_from_type(:misc)
27
+ home_path = get_skeleton_path_from_type($env_vars, :misc)
28
28
 
29
29
  create_user_and_group($env_vars, home_path)
30
30
  setup_user_permissions($env_vars, home_path)
31
31
 
32
32
  create_init($env_vars, :misc)
33
-
34
- ruby_vendor_gems
35
33
  end
36
34
 
37
35
  def install
@@ -15,23 +15,21 @@ class RubyWebApp < FPM::Cookery::Recipe
15
15
  Gordon::Cookery::Ruby::Common
16
16
 
17
17
  name $env_vars.app_name
18
- description $env_vars.app_desc
18
+ description $env_vars.app_description
19
19
  version $env_vars.app_version
20
- homepage $env_vars.app_repo
20
+ homepage $env_vars.app_homepage
21
21
 
22
- source $env_vars.app_source_dir, with: :local_path
22
+ source $env_vars.app_source, with: :local_path
23
23
 
24
24
  depends *resolve_dependencies($env_vars)
25
25
 
26
26
  def build
27
- home_path = get_skeleton_path_from_type($env_vars.http_server_type)
27
+ home_path = get_skeleton_path_from_type($env_vars, $env_vars.http_server_type)
28
28
 
29
29
  create_user_and_group($env_vars, home_path)
30
30
  setup_user_permissions($env_vars, home_path)
31
31
 
32
32
  create_init($env_vars, $env_vars.http_server_type)
33
-
34
- ruby_vendor_gems
35
33
  end
36
34
 
37
35
  def install
@@ -2,7 +2,7 @@ module Gordon
2
2
  module Application
3
3
  module Types
4
4
  module Base
5
- def template_path
5
+ def get_template_path
6
6
  curdir = File.dirname(__FILE__)
7
7
  template_path = File.join(curdir, 'templates', "#{get_template}.rb")
8
8
 
data/lib/gordon/cli.rb CHANGED
@@ -4,7 +4,7 @@ module Gordon
4
4
  class CLI
5
5
  def self.run
6
6
  options = Options.new
7
- options.app_source_dir = Dir.pwd
7
+ options.app_source = Dir.pwd
8
8
  options.output_dir = Dir.pwd
9
9
 
10
10
  parser = create_option_parser(options)
@@ -19,28 +19,32 @@ module Gordon
19
19
  parser = OptionParser.new do |opts|
20
20
  opts.banner = 'Usage: gordon [options]'
21
21
 
22
- opts.on('-T', '--app-type APP_TYPE', 'Application Type') do |app_type|
23
- options.app_type = app_type
24
- end
25
-
26
22
  opts.on('-N', '--app-name APP_NAME', 'Application Name') do |app_name|
27
23
  options.app_name = app_name
28
24
  end
29
25
 
30
- opts.on('-D', '--app-desc APP_DESC', 'Application Description') do |app_desc|
31
- options.app_desc = app_desc
26
+ opts.on('-D', '--app-description APP_DESCRIPTION', 'Application Description') do |app_description|
27
+ options.app_description = app_description
32
28
  end
33
29
 
34
- opts.on('-R', '--app-repo APP_REPO', 'Application Repository URL') do |app_repo|
35
- options.app_repo = app_repo
30
+ opts.on('-G', '--app-homepage APP_HOMEPAGE', 'Application Homepage') do |app_homepage|
31
+ options.app_homepage = app_homepage
36
32
  end
37
33
 
38
34
  opts.on('-V', '--app-version APP_VERSION', 'Application Version') do |app_version|
39
35
  options.app_version = app_version
40
36
  end
41
37
 
42
- opts.on('-S', '--app-source-dir APP_SOURCE_DIR', 'Application Source Directory') do |app_source_dir|
43
- options.app_source_dir = app_source_dir
38
+ opts.on('-S', '--app-source APP_SOURCE', 'Application Source') do |app_source|
39
+ options.app_source = app_source
40
+ end
41
+
42
+ opts.on('-T', '--app-type APP_TYPE', 'Application Type') do |app_type|
43
+ options.app_type = app_type
44
+ end
45
+
46
+ opts.on('-X', '--runtime-name RUNTIME_NAME', 'Runtime Name') do |runtime_name|
47
+ options.runtime_name = runtime_name
44
48
  end
45
49
 
46
50
  opts.on('-R', '--runtime-version RUNTIME_VERSION', 'Runtime Version') do |runtime_version|
data/lib/gordon/cooker.rb CHANGED
@@ -2,7 +2,7 @@ module Gordon
2
2
  class Cooker
3
3
  attr_reader :recipe, :options
4
4
 
5
- FPM_COOKERY_COMMAND = 'ruby -S fpm-cook'
5
+ FPM_COOKERY_COMMAND = 'fpm-cook'
6
6
  FPM_COOKERY_CACHE_DIR = '/tmp/gordon/cache'
7
7
  FPM_COOKERY_BUILD_DIR = '/tmp/gordon/build'
8
8
 
@@ -39,10 +39,10 @@ module Gordon
39
39
  def get_command_args
40
40
  cook_args = []
41
41
 
42
- cook_args << "--debug" if options.debug?
42
+ cook_args << "--debug" if options.debug
43
43
 
44
44
  cook_args << "--target #{options.package_type}"
45
- cook_args << "--platform #{recipe.platform}" if recipe.requires_platform?
45
+ # cook_args << "--platform #{recipe.platform}" if recipe.requires_platform?
46
46
  cook_args << "--pkg-dir #{File.expand_path(options.output_dir)}"
47
47
  cook_args << "--cache-dir #{File.expand_path(FPM_COOKERY_CACHE_DIR)}"
48
48
  cook_args << "--tmp-root #{File.expand_path(FPM_COOKERY_BUILD_DIR)}"
@@ -56,7 +56,7 @@ module Gordon
56
56
 
57
57
  command = "#{env_vars.join " "} #{FPM_COOKERY_COMMAND} #{cook_args.join " "}"
58
58
 
59
- debug(command) if options.debug?
59
+ debug(command) if options.debug
60
60
 
61
61
  Process.run(command)
62
62
  end
@@ -9,7 +9,7 @@ module Gordon
9
9
  set -e
10
10
 
11
11
  /usr/bin/getent group #{env_vars.app_name} >/dev/null || /usr/sbin/groupadd --system #{env_vars.app_name};
12
- /usr/bin/getent passwd #{env_vars.app_name} >/dev/null || /usr/sbin/useradd --system --gid #{env_vars.app_name} --home-dir #{home_path} --shell /sbin/nologin --comment "#{env_vars.app_desc}" #{env_vars.app_name} >/dev/null || :;
12
+ /usr/bin/getent passwd #{env_vars.app_name} >/dev/null || /usr/sbin/useradd --system --gid #{env_vars.app_name} --home-dir #{home_path} --shell /sbin/nologin --comment "#{env_vars.app_description}" #{env_vars.app_name} >/dev/null || :;
13
13
  __BASH
14
14
 
15
15
  f.write(bash)
@@ -7,9 +7,14 @@ module Gordon
7
7
  base.send(:extend, self)
8
8
  end
9
9
 
10
- def get_skeleton_path_from_type(type)
10
+ def get_skeleton_path_from_type(env_vars, type)
11
11
  skeleton_type = create_skeleton_type(type)
12
- skeleton_type.path(skeleton_type.requires_app_name? ? $env_vars.app_name : '')
12
+ appended_path = skeleton_type.requires_app_name? ? env_vars.app_name : ''
13
+ skeleton_type.path(appended_path)
14
+ end
15
+
16
+ def create_skeleton_type(type)
17
+ Skeleton::Factory.create(type)
13
18
  end
14
19
 
15
20
  def all_files_except_blacklisted(*custom_blacklist_files)
@@ -26,10 +31,6 @@ module Gordon
26
31
 
27
32
  files
28
33
  end
29
-
30
- def create_skeleton_type(type)
31
- Skeleton::Factory.create(type)
32
- end
33
34
  end
34
35
  end
35
36
  end
@@ -1,6 +1,10 @@
1
+ require 'fpm/cookery/facts'
2
+
1
3
  module Gordon
2
4
  module Cookery
3
5
  module DependencyResolver
6
+ include Common
7
+
4
8
  def resolve_dependencies(env_vars)
5
9
  fragments = env_vars.app_type.split('_')
6
10
  app_runtime, app_type = fragments[0], fragments[1]
@@ -23,6 +27,8 @@ module Gordon
23
27
 
24
28
  runtime_version = "#{runtime_name}#{env_vars.runtime_version}"
25
29
  else
30
+ runtime_name = app_runtime
31
+
26
32
  runtime_version = "#{runtime_name} = #{env_vars.runtime_version}"
27
33
  end
28
34
 
@@ -42,10 +48,10 @@ module Gordon
42
48
  end
43
49
 
44
50
  def get_os_package_name(env_vars, attribute)
45
- package_type = FPM::Cookery::Facts.platform.to_sym
51
+ platform = FPM::Cookery::Facts.platform.to_sym
46
52
 
47
53
  skeleton_type = create_skeleton_type(env_vars.send(attribute))
48
- os_package_name = skeleton_type.get_os_package_map[package_type]
54
+ os_package_name = skeleton_type.get_os_package_name(platform)
49
55
 
50
56
  os_package_name
51
57
  end
@@ -1,8 +1,10 @@
1
1
  module Gordon
2
2
  module Cookery
3
3
  module HttpServer
4
+ include Common
5
+
4
6
  def install_http_server_files(env_vars, blacklist)
5
- skeleton_path = get_skeleton_path_from_type(env_vars.http_server_type)
7
+ skeleton_path = get_skeleton_path_from_type(env_vars, env_vars.http_server_type)
6
8
 
7
9
  application_files = all_files_except_blacklisted(blacklist)
8
10
 
@@ -1,11 +1,13 @@
1
1
  module Gordon
2
2
  module Cookery
3
3
  module Init
4
+ include Common
5
+
4
6
  def create_init(env_vars, skeleton_type)
5
7
  init_build_dir_path = builddir(env_vars.init_type)
6
- skeleton_path = get_skeleton_path_from_type(skeleton_type)
8
+ skeleton_path = get_skeleton_path_from_type(env_vars, skeleton_type)
7
9
 
8
- command = "ruby -S foreman export --procfile Procfile --root #{skeleton_path} --app #{env_vars.app_name} --user #{env_vars.app_name} #{env_vars.init_type} #{init_build_dir_path}"
10
+ command = "foreman export --procfile Procfile --root #{skeleton_path} --app #{env_vars.app_name} --user #{env_vars.app_name} #{env_vars.init_type} #{init_build_dir_path}"
9
11
 
10
12
  safesystem(command)
11
13
  end
@@ -13,7 +15,7 @@ module Gordon
13
15
  def install_init(env_vars)
14
16
  init_build_dir_path = builddir(env_vars.init_type)
15
17
 
16
- skeleton_path = get_skeleton_path_from_type(env_vars.init_type)
18
+ skeleton_path = get_skeleton_path_from_type(env_vars, env_vars.init_type)
17
19
  skeleton_files = Dir["#{init_build_dir_path}/*"]
18
20
 
19
21
  root(skeleton_path).install skeleton_files
@@ -8,4 +8,3 @@ module Gordon
8
8
  end
9
9
  end
10
10
 
11
-
@@ -3,14 +3,6 @@ module Gordon
3
3
  module Ruby
4
4
  module Common
5
5
  RUBY_BLACKLIST_FILES = %w(.rspec coverage log spec tmp)
6
-
7
- def ruby_vendor_gems
8
- command = 'ruby -S bundle package --all'
9
- safesystem(command)
10
-
11
- command = 'ruby -S bundle install --deployment --without development test'
12
- safesystem(command)
13
- end
14
6
  end
15
7
  end
16
8
  end
@@ -1,8 +1,10 @@
1
1
  module Gordon
2
2
  module Cookery
3
3
  module Standalone
4
+ include Common
5
+
4
6
  def install_standalone_files(env_vars, blacklist)
5
- skeleton_path = get_skeleton_path_from_type(:misc)
7
+ skeleton_path = get_skeleton_path_from_type(env_vars, :misc)
6
8
 
7
9
  application_files = all_files_except_blacklisted(blacklist)
8
10
 
@@ -1,8 +1,10 @@
1
1
  module Gordon
2
2
  module Cookery
3
3
  module WebServer
4
+ include Common
5
+
4
6
  def install_web_server_files(env_vars, blacklist)
5
- skeleton_path = get_skeleton_path_from_type(env_vars.web_server_type)
7
+ skeleton_path = get_skeleton_path_from_type(env_vars, env_vars.web_server_type)
6
8
 
7
9
  application_files = all_files_except_blacklisted(blacklist)
8
10
 
@@ -1,7 +1,8 @@
1
1
  module Gordon
2
2
  class EnvVars
3
- attr_accessor :app_type, :app_name, :app_desc, :app_repo, :app_version, :app_source_dir
4
- attr_accessor :runtime_version
3
+ attr_accessor :app_type
4
+ attr_accessor :app_name, :app_description, :app_homepage, :app_version, :app_source
5
+ attr_accessor :runtime_name, :runtime_version
5
6
  attr_accessor :http_server_type
6
7
  attr_accessor :web_server_type
7
8
  attr_accessor :init_type
@@ -11,10 +12,11 @@ module Gordon
11
12
 
12
13
  env_vars << "GORDON_APP_TYPE='#{options.app_type}'"
13
14
  env_vars << "GORDON_APP_NAME='#{options.app_name}'"
14
- env_vars << "GORDON_APP_DESC='#{options.app_desc}'"
15
- env_vars << "GORDON_APP_REPO='#{options.app_repo}'"
15
+ env_vars << "GORDON_APP_DESCRIPTION='#{options.app_description}'"
16
+ env_vars << "GORDON_APP_HOMEPAGE='#{options.app_homepage}'"
16
17
  env_vars << "GORDON_APP_VERSION='#{options.app_version}'"
17
- env_vars << "GORDON_APP_SOURCE_DIR='#{File.expand_path(options.app_source_dir)}'"
18
+ env_vars << "GORDON_APP_SOURCE='#{File.expand_path(options.app_source)}'"
19
+ env_vars << "GORDON_RUNTIME_NAME='#{options.runtime_name}'"
18
20
  env_vars << "GORDON_RUNTIME_VERSION='#{options.runtime_version}'"
19
21
  env_vars << "GORDON_HTTP_SERVER_TYPE='#{options.http_server_type}'"
20
22
  env_vars << "GORDON_WEB_SERVER_TYPE='#{options.web_server_type}'"
@@ -28,10 +30,11 @@ module Gordon
28
30
 
29
31
  env_vars.app_type = ENV['GORDON_APP_TYPE']
30
32
  env_vars.app_name = ENV['GORDON_APP_NAME']
31
- env_vars.app_desc = ENV['GORDON_APP_DESC']
32
- env_vars.app_repo = ENV['GORDON_APP_REPO']
33
+ env_vars.app_description = ENV['GORDON_APP_DESCRIPTION']
34
+ env_vars.app_homepage = ENV['GORDON_APP_HOMEPAGE']
33
35
  env_vars.app_version = ENV['GORDON_APP_VERSION']
34
- env_vars.app_source_dir = ENV['GORDON_APP_SOURCE_DIR']
36
+ env_vars.app_source = ENV['GORDON_APP_SOURCE']
37
+ env_vars.runtime_name = ENV['GORDON_RUNTIME_NAME']
35
38
  env_vars.runtime_version = ENV['GORDON_RUNTIME_VERSION']
36
39
  env_vars.http_server_type = ENV['GORDON_HTTP_SERVER_TYPE']
37
40
  env_vars.web_server_type = ENV['GORDON_WEB_SERVER_TYPE']
@@ -0,0 +1,10 @@
1
+ module Gordon
2
+ module Exceptions
3
+ class OperationalSystemNotMapped < RuntimeError
4
+ def initialize(class_name, os_name)
5
+ super("Operational System not mapped for #{class_name}. OS: #{os_name}")
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -1,14 +1,13 @@
1
1
  module Gordon
2
2
  class Options
3
- attr_accessor :app_type, :app_name, :app_desc, :app_repo, :app_version, :app_source_dir
4
- attr_accessor :runtime_version
3
+ attr_accessor :app_name, :app_description, :app_homepage, :app_version, :app_source
4
+ attr_accessor :app_type
5
+ attr_accessor :runtime_name, :runtime_version
5
6
  attr_accessor :http_server_type
6
7
  attr_accessor :web_server_type
7
8
  attr_accessor :init_type
8
9
  attr_accessor :package_type
9
10
  attr_accessor :output_dir
10
11
  attr_accessor :debug
11
-
12
- def debug? ; !!debug ; end
13
12
  end
14
13
  end
@@ -2,7 +2,11 @@ module Gordon
2
2
  class Process
3
3
  def self.run(command)
4
4
  pid = ::Process.spawn(command, out: $stdout, err: $stderr)
5
- _, status = ::Process.wait2(pid)
5
+ _, exit_status = ::Process.wait2(pid)
6
+
7
+ raise SystemCallError.new("Failed to execute [#{command}]. Exit code: #{exit_status}") unless exit_status == 0
8
+
9
+ true
6
10
  end
7
11
  end
8
12
  end
data/lib/gordon/recipe.rb CHANGED
@@ -21,7 +21,7 @@ module Gordon
21
21
  end
22
22
 
23
23
  def application_template_path
24
- application.template_path
24
+ application.get_template_path
25
25
  end
26
26
  end
27
27
  end
@@ -6,6 +6,13 @@ module Gordon
6
6
  File.join(get_default_path, app.to_s)
7
7
  end
8
8
 
9
+ def get_os_package_name(os_name)
10
+ package = get_os_package_map[os_name]
11
+ raise Exceptions::OperationalSystemNotMapped.new(self.class.name, os_name) if package.nil?
12
+
13
+ package
14
+ end
15
+
9
16
  def requires_app_name?
10
17
  false
11
18
  end
@@ -1,3 +1,3 @@
1
1
  module Gordon
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
data/lib/gordon.rb CHANGED
@@ -5,6 +5,7 @@ module Gordon
5
5
  require 'gordon/cooker'
6
6
  require 'gordon/recipe'
7
7
  require 'gordon/env_vars'
8
+ require 'gordon/exceptions'
8
9
  require 'gordon/factory'
9
10
  require 'gordon/options'
10
11
  require 'gordon/process'
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gordon::Application::Types::Base do
4
+ subject do
5
+ class MyApplicationTypesBase
6
+ include Gordon::Application::Types::Base
7
+
8
+ def get_template ; 'vudu_eh_pra_jacoo' ; end
9
+ end
10
+
11
+ MyApplicationTypesBase.new
12
+ end
13
+
14
+ it 'returns template path based on class' do
15
+ path = '/a/strange/path'
16
+ curdir = File.join(path, 'lib', 'gordon')
17
+ expect(File).to receive(:dirname).and_return(curdir)
18
+
19
+ expected = File.join(curdir, 'templates', 'vudu_eh_pra_jacoo.rb')
20
+
21
+ expect(subject.get_template_path).to eq(expected)
22
+ end
23
+ end
24
+
25
+ describe Gordon::Application::Types::RubyWebApp do
26
+ it 'returns a template' do
27
+ expect(subject.get_template).to eq('ruby_web_app')
28
+ end
29
+ end
30
+
31
+ describe Gordon::Application::Types::RubyStandaloneApp do
32
+ it 'returns a template' do
33
+ expect(subject.get_template).to eq('ruby_standalone_app')
34
+ end
35
+ end
36
+
37
+ describe Gordon::Application::Types::JavaWebApp do
38
+ it 'returns a template' do
39
+ expect(subject.get_template).to eq('java_web_app')
40
+ end
41
+ end
42
+
43
+ describe Gordon::Application::Types::JavaStandaloneApp do
44
+ it 'returns a template' do
45
+ expect(subject.get_template).to eq('java_standalone_app')
46
+ end
47
+ end
48
+