gordon 0.0.4 → 0.0.6

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: c54664a1e5359e5fd1fcbba7441631a573126523
4
- data.tar.gz: f7891f315e9960dc15cec108bea040aa6158327f
3
+ metadata.gz: 8807e453ec5c7d49cef487a753959d7a88e53a46
4
+ data.tar.gz: 3ed6815c1615d8c5a39ee20c862dd509c8b63056
5
5
  SHA512:
6
- metadata.gz: 99b6cff85548e38b072b5d28750bb8da757117fdbb0c1ab03d60ae07fd12c89399f51d38c99f42b1a91f45469b4750b4de39acc23bbfa82d22ffa602fb9cee12
7
- data.tar.gz: f97b983cf4239584ed6e007cba368f865792b18da71f944c7bc8f4f38650c43633c85134c2da5f8a149c28e92f199345e57ff974322f8b7d33d38573b4fef5b6
6
+ metadata.gz: 2d25d8c05b10dd34c1e7ef11cc7adf9695897f6930efebe2afbee1949e0a636a5fe636c84713e0a7fae07c58ff0ab06052f11a1e92c823fd43c6e6c0eb29c25a
7
+ data.tar.gz: 9c5fd2889928bb9a481d785c7900e4739021c4bfbc52a07f13820add8bae277f722d9ba4c6a343fb88c4d64d91d247a77fa3a1619b6b7fb29c55b62066b16bc9
data/README.md CHANGED
@@ -6,20 +6,25 @@ Of course, [fpm](https://github.com/jordansissel/fpm) is a awesome tool to abstr
6
6
 
7
7
  Of course, [fpm-cookery](https://github.com/bernd/fpm-cookery) is another great tool to approach building as a simple recipe.
8
8
 
9
- But, unfortunately, create recipes for each application can be boring and repetitive. You need to create init files (inittab, systemd, etc) for each project
10
- and, if a webserver changes (example: from Thin to Unicorn) you need to change script again, again and again.
9
+ Of course, [foreman](https://github.com/ddollar/foreman) is a great tool to handle Procfile-based applications and have the amazing feature of export to init files (systemd, runit, inittab).
10
+
11
+ But, unfortunately, create fpm-cookery recipes for each application can be boring and repetitious. You need to create init files (inittab, systemd, etc) for each project and, if a webserver changes (example: from Thin to Unicorn) you need to change script again, again and again.
11
12
 
12
13
  And when you are in front with a web application that breaks Nginx or Apache conventions? Do you remember that feel, bro?
13
14
 
14
- Gordon is a try to automagically create init files using Foreman and build artifacts using FPM. Make developers free to develop, while you take apps under a minimal control.
15
+ Gordon is a try to automagically create init files using Foreman and build artifacts using fpm-cookery, on the shoulder of conventions. Make developers free to develop, while you have apps under a minimal control in ops side of view.
15
16
 
16
17
  ## How it works?
17
18
 
18
- Gordon have a lot of restrictions:
19
+ Gordon have a lot of restrictions, because they are liberating. These restrictions are a result of years packaging apps, since code generation to minimal security & ops conventions.
20
+
21
+ Per example: create a user that will run app with credentials, whose $HOME is the directory of application, is a good practice. Therefore, any web app will follow this rule with Gordon. Period.
22
+
23
+ ## How are the options?
19
24
 
20
25
  * Web Servers: Nginx or Apache (Tomcat soon);
21
- * Init scripts: all generated by Foreman;
22
- * Apps supported: at this time, Ruby. Java soon and others too.
26
+ * Init scripts: Systemd (all generated by Foreman soon);
27
+ * Apps supported: at this time, Ruby Web App. Java soon and others when needed.
23
28
 
24
29
  ## Installation
25
30
 
@@ -39,30 +44,33 @@ Or install it yourself as:
39
44
 
40
45
  A simple example to build a Ruby Web App that runs Nginx and uses Systemd as init process:
41
46
 
42
- $ ruby -S gordon \
43
- --app-type ruby_web_app \
44
- --app-name $APP_NAME \
45
- --app-desc $APP_DESC \
46
- --app-repo $APP_REPO \
47
- --app-version $APP_VERSION \
48
- --package-type rpm \
49
- --package-dir . \
50
- --source-dir . \
51
- --build-dir /tmp \
52
- --skeleton-type nginx \
53
- --init-type systemd \
54
- --init-build-dir /tmp/systemd
55
-
56
- It will generate a RPM package with the following structure:
47
+ $ ruby -S gordon \
48
+ --app-name $APP_NAME \
49
+ --app-desc $APP_DESC \
50
+ --app-repo $APP_REPO \
51
+ --app-version $APP_VERSION \
52
+ --app-source-dir . \
53
+ --app-type ruby_web_app \
54
+ --http-server-type nginx \
55
+ --init-type systemd \
56
+ --package-type rpm \
57
+ --output pkg
58
+
59
+ It will generate a RPM package in pkg/ with the following structure:
57
60
 
58
61
  * /usr/share/nginx/html/*all-app-stuff*
59
62
  * /usr/lib/systemd/system/*app-name*/*all-systemd-stuff*
60
63
 
64
+ Due for conventions, remember:
65
+
66
+ * /usr/share/nginx/html is $HOME of user *app-name*
67
+ * Systemd will run app using user *app-name*
68
+
61
69
  Sounds good?
62
70
 
63
71
  ## Why you not use Omnibus or Heroku buildpacks?
64
72
 
65
- Because I want to create a tool that can be used as a transition step.
73
+ Because I want to create a tool that can be used as a transition step for building apps.
66
74
 
67
75
  ## Why you use fpm-cookery templates instead of fpm?
68
76
 
@@ -76,10 +84,8 @@ Because I like Gordon Ramsay.
76
84
 
77
85
  * Very unstable, need to fix it
78
86
  * Validate outputs
79
- * Fix annoying --package-dir OptionParser::InvalidOption error
80
87
  * Add a way to map package dependencies
81
88
  * Adapt to use Debian and other OS conventions for Nginx and Apache
82
- * Create a better way to handle env vars than injecting a lot of global variables in fpm-cookery ruby-web-app template
83
89
  * Tests
84
90
 
85
91
  ## Contributing
data/gordon.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Gordon::VERSION
9
9
  spec.authors = ["Marcelo Pinheiro"]
10
10
  spec.email = ["salizzar@gmail.com"]
11
- spec.description = %q{Gordon is a tool to create artifacts using fpm-cookery and foreman.}
12
- spec.summary = %q{A tool to create application artifacts}
11
+ spec.description = %q{Gordon is a tool to create OS packages using fpm-cookery and foreman, based on a lot of conventions.}
12
+ spec.summary = %q{A tool to create application OS packages}
13
13
  spec.homepage = "https://github.com/salizzar/gordon"
14
14
  spec.license = "MIT"
15
15
 
@@ -20,6 +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 "debugger"
23
24
 
24
25
  spec.add_dependency "fpm-cookery"
25
26
  spec.add_dependency "foreman"
@@ -0,0 +1,12 @@
1
+ module Gordon
2
+ module Application
3
+ class Factory
4
+ def self.create(application_type)
5
+ namespace = "Application::Types"
6
+
7
+ ::Gordon::Factory.create_instance(namespace, application_type)
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -1,41 +1,38 @@
1
- $app_name = ENV['GORDON_APP_NAME']
2
- $app_desc = ENV['GORDON_APP_DESC']
3
- $app_repo = ENV['GORDON_APP_REPO']
4
- $app_version = ENV['GORDON_APP_VERSION']
5
- #app_depends = ENV['GORDON_APP_DEPENDS']
6
- $app_source_dir = ENV['GORDON_APP_SOURCE_DIR']
7
-
8
- $skeleton_type = ENV['GORDON_SKELETON_TYPE']
9
- $skeleton_files = ENV['GORDON_SKELETON_FILES']
10
-
11
- $init_type = ENV['GORDON_INIT_TYPE']
12
- $init_build_dir = ENV['GORDON_INIT_BUILD_DIR']
13
-
14
1
  path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib'))
15
2
  $LOAD_PATH.unshift path
16
3
 
17
4
  require 'gordon'
18
5
 
6
+ $env_vars = Gordon::EnvVars.load
7
+
19
8
  class RubyWebApp < FPM::Cookery::Recipe
20
9
  include Gordon::Cookery::Common,
21
10
  Gordon::Cookery::Init,
22
- Gordon::Cookery::Webserver
11
+ Gordon::Cookery::ApplicationUser,
12
+ Gordon::Cookery::HttpServer,
13
+ Gordon::Cookery::Ruby::Common
23
14
 
24
- name $app_name
25
- description $app_desc
26
- version $app_version
27
- homepage $app_repo
15
+ name $env_vars.app_name
16
+ description $env_vars.app_desc
17
+ version $env_vars.app_version
18
+ homepage $env_vars.app_repo
28
19
 
29
- source $app_source_dir, with: :local_path
30
- # depends $app_depends
20
+ source $env_vars.app_source_dir, with: :local_path
31
21
 
32
22
  def build
33
- vendor_gems
23
+ home_path = get_skeleton_path_from_type($env_vars.http_server_type)
24
+
25
+ create_user_and_group(home_path)
26
+ setup_user_permissions(home_path)
27
+
28
+ create_init
29
+
30
+ ruby_vendor_gems
34
31
  end
35
32
 
36
33
  def install
37
- setup_init_files
38
- setup_webserver_files
34
+ install_init
35
+ install_http_server_files(RUBY_BLACKLIST_FILES)
39
36
  end
40
37
  end
41
38
 
@@ -28,14 +28,6 @@ module Gordon
28
28
  def get_template ; 'java_standalone_app' ; end
29
29
  end
30
30
  end
31
-
32
- class Factory
33
- def self.create(application_type)
34
- namespace = "Application::Types"
35
-
36
- ::Gordon::Factory.create_instance(namespace, application_type)
37
- end
38
- end
39
31
  end
40
32
  end
41
33
 
data/lib/gordon/cli.rb CHANGED
@@ -4,18 +4,14 @@ module Gordon
4
4
  class CLI
5
5
  def self.run
6
6
  options = Options.new
7
- options.source_dir = Dir.pwd
8
- options.build_dir = '/tmp'
9
- options.package_dir = Dir.pwd
10
- options.init_build_dir = '/tmp'
7
+ options.source_dir = Dir.pwd
8
+ options.output_dir = Dir.pwd
11
9
 
12
10
  parser = create_option_parser(options)
13
11
  parser.parse!
14
12
 
15
- file_path = File.join(Dir.pwd, 'gordon.yml')
16
-
17
13
  recipe = Recipe.new(options)
18
- cooker = Cooker.new(recipe, options)
14
+ cooker = Cooker.new(recipe)
19
15
  cooker.cook
20
16
  end
21
17
 
@@ -23,19 +19,15 @@ module Gordon
23
19
  parser = OptionParser.new do |opts|
24
20
  opts.banner = 'Usage: gordon [options]'
25
21
 
26
- opts.on('-t', '--app-type APP_TYPE', 'Application Type') do |type|
27
- options.app_type = type
28
- end
29
-
30
- opts.on('-n', '--app-name APP_NAME', 'Application Name') do |name|
22
+ opts.on('-N', '--app-name APP_NAME', 'Application Name') do |name|
31
23
  options.app_name = name
32
24
  end
33
25
 
34
- opts.on('-d', '--app-desc APP_DESC', 'Application Description') do |desc|
26
+ opts.on('-D', '--app-desc APP_DESC', 'Application Description') do |desc|
35
27
  options.app_desc = desc
36
28
  end
37
29
 
38
- opts.on('-r', '--app-repo APP_REPO', 'Application Repository URL') do |repo|
30
+ opts.on('-R', '--app-repo APP_REPO', 'Application Repository URL') do |repo|
39
31
  options.app_repo = repo
40
32
  end
41
33
 
@@ -43,35 +35,31 @@ module Gordon
43
35
  options.app_version = version
44
36
  end
45
37
 
46
- opts.on('-p', '--package-type PACKAGE', 'Package type') do |package_type|
47
- options.package_type = package_type
48
- end
49
-
50
- opts.on('-P' '--package-dir PACKAGE_DIR', 'Package Directory') do |package_dir|
51
- options.package_dir = package_dir
52
- end
53
-
54
- opts.on('-s', '--source-dir SOURCE_DIR', 'Source Directory') do |source_dir|
38
+ opts.on('-S', '--app-source-dir APP_SOURCE_DIR', 'Application Source Directory') do |source_dir|
55
39
  options.source_dir = source_dir
56
40
  end
57
41
 
58
- opts.on('-b', '--build-dir BUILD_DIR', 'Build Directory') do |build_dir|
59
- options.build_dir = build_dir
42
+ opts.on('-T', '--app-type APP_TYPE', 'Application Type') do |type|
43
+ options.app_type = type
60
44
  end
61
45
 
62
- opts.on('-S', '--skeleton-type SKELETON_TYPE', 'Skeleton Type') do |skeleton_type|
63
- options.skeleton_type = skeleton_type
46
+ opts.on('-H', '--http-server-type HTTP_SERVER_TYPE', 'HTTP Server Type') do |http_server_type|
47
+ options.http_server_type = http_server_type
64
48
  end
65
49
 
66
- opts.on('-i', '--init-type INIT_TYPE', 'Init Type') do |init_type|
50
+ opts.on('-I', '--init-type INIT_TYPE', 'Init Type') do |init_type|
67
51
  options.init_type = init_type
68
52
  end
69
53
 
70
- opts.on('-I', '--init-build-dir INIT_BUILD_DIR', 'Init Build Directory') do |init_build_dir|
71
- options.init_build_dir = init_build_dir
54
+ opts.on('-P', '--package-type PACKAGE', 'Package type') do |package_type|
55
+ options.package_type = package_type
56
+ end
57
+
58
+ opts.on('-O', '--output-dir OUTPUT_DIR', 'Output Directory') do |output_dir|
59
+ options.output_dir = output_dir
72
60
  end
73
61
 
74
- opts.on('-D', '--debug DEBUG', 'Debug Mode') do |debug|
62
+ opts.on('-d', '--debug DEBUG', 'Debug Mode') do |debug|
75
63
  options.debug = debug
76
64
  end
77
65
 
@@ -79,6 +67,11 @@ module Gordon
79
67
  puts opts
80
68
  exit
81
69
  end
70
+
71
+ opts.on('-v', '--version', 'Displays Version') do
72
+ puts VERSION
73
+ exit
74
+ end
82
75
  end
83
76
 
84
77
  parser
data/lib/gordon/cooker.rb CHANGED
@@ -1,55 +1,69 @@
1
1
  module Gordon
2
2
  class Cooker
3
- attr_reader :options, :recipe
3
+ attr_reader :recipe, :options
4
4
 
5
- def initialize(recipe, options)
5
+ FPM_COOKERY_COMMAND = 'ruby -S fpm-cook'
6
+ FPM_COOKERY_CACHE_DIR = '/tmp/gordon/cache'
7
+ FPM_COOKERY_BUILD_DIR = '/tmp/gordon/build'
8
+
9
+ def initialize(recipe)
6
10
  @recipe = recipe
7
- @options = options
11
+ @options = recipe.options
8
12
  end
9
13
 
10
14
  def cook
11
- cook_args = []
15
+ clean
16
+ package
17
+ end
12
18
 
13
- cook_args << "--debug" if options.debug?
19
+ private
14
20
 
15
- cook_args << "--target #{options.package_type}"
16
- cook_args << "--platform #{recipe.platform}" if recipe.requires_platform?
17
- cook_args << "--cache-dir #{File.expand_path(options.build_dir)}"
18
- cook_args << "--tmp-root #{File.expand_path(options.build_dir)}"
19
- cook_args << "--pkg-dir #{File.expand_path(options.package_dir)}"
20
- cook_args << "package"
21
+ def clean
22
+ cook_args = get_command_args
23
+
24
+ cook_args << "clean"
21
25
  cook_args << recipe.application_template_path
22
26
 
23
- env_vars = get_env_vars
24
- command = "#{env_vars.join " "} ruby -S fpm-cook #{cook_args.join " "}"
27
+ execute(cook_args)
28
+ end
25
29
 
26
- if options.debug?
27
- STDOUT.puts ''
28
- STDOUT.puts command
29
- STDOUT.puts ''
30
- end
30
+ def package
31
+ cook_args = get_command_args
31
32
 
32
- Process.run(command)
33
+ cook_args << "package"
34
+ cook_args << recipe.application_template_path
35
+
36
+ execute(cook_args)
33
37
  end
34
38
 
35
- private
39
+ def get_command_args
40
+ cook_args = []
41
+
42
+ cook_args << "--debug" if options.debug?
43
+
44
+ cook_args << "--target #{options.package_type}"
45
+ cook_args << "--platform #{recipe.platform}" if recipe.requires_platform?
46
+ cook_args << "--pkg-dir #{File.expand_path(options.output_dir)}"
47
+ cook_args << "--cache-dir #{File.expand_path(FPM_COOKERY_CACHE_DIR)}"
48
+ cook_args << "--tmp-root #{File.expand_path(FPM_COOKERY_BUILD_DIR)}"
49
+
50
+ cook_args
51
+ end
36
52
 
37
- def get_env_vars
38
- env_vars = []
53
+ def execute(cook_args)
54
+ env_vars = EnvVars.from_cook(options)
39
55
 
40
- env_vars << "GORDON_APP_NAME=#{options.app_name}"
41
- env_vars << "GORDON_APP_DESC=#{options.app_desc}"
42
- env_vars << "GORDON_APP_REPO=#{options.app_repo}"
43
- env_vars << "GORDON_APP_VERSION=#{options.app_version}"
44
- env_vars << "GORDON_APP_SOURCE_DIR=#{File.expand_path(options.source_dir)}"
56
+ command = "#{env_vars.join " "} #{FPM_COOKERY_COMMAND} #{cook_args.join " "}"
45
57
 
46
- env_vars << "GORDON_SKELETON_TYPE=#{recipe.skeleton.type}"
47
- env_vars << "GORDON_SKELETON_FILES=#{recipe.skeleton.artifacts.join(',')}"
58
+ debug(command) if options.debug?
48
59
 
49
- env_vars << "GORDON_INIT_TYPE=#{options.init_type}"
50
- env_vars << "GORDON_INIT_BUILD_DIR=#{File.expand_path(options.init_build_dir)}"
60
+ Process.run(command)
61
+ end
51
62
 
52
- env_vars
63
+ def debug(command)
64
+ STDOUT.puts ''
65
+ STDOUT.puts command
66
+ STDOUT.puts ''
53
67
  end
54
68
  end
55
69
  end
@@ -0,0 +1,41 @@
1
+ module Gordon
2
+ module Cookery
3
+ module ApplicationUser
4
+ def create_user_and_group(home_path)
5
+ File.open(builddir('.gordon-before-install'), 'w', 0755) do |f|
6
+ bash = <<-__BASH
7
+ #!/bin/sh
8
+
9
+ set -e
10
+
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 || :;
13
+
14
+ __BASH
15
+
16
+ f.write(bash)
17
+
18
+ self.class.pre_install(File.expand_path(f.path))
19
+ end
20
+ end
21
+
22
+ def setup_user_permissions(home_path)
23
+ File.open(builddir('.gordon-after-install'), 'w', 0755) do |f|
24
+ bash = <<-__BASH
25
+ #!/bin/sh
26
+
27
+ set -e
28
+
29
+ /usr/bin/chown -R #{$env_vars.app_name}:#{$env_vars.app_name} #{home_path}
30
+
31
+ __BASH
32
+
33
+ f.write(bash)
34
+
35
+ self.class.post_install(File.expand_path(f.path))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
@@ -1,16 +1,26 @@
1
1
  module Gordon
2
2
  module Cookery
3
3
  module Common
4
- def vendor_gems
5
- safesystem('ruby -S bundle install --deployment --without development test')
6
- end
4
+ MAIN_BLACKLIST_FILES = %w(.git .gitignore .pki Vagrantfile)
7
5
 
8
- def common_ruby_files
9
- %w(.bundle Gemfile Gemfile.lock Procfile config.ru vendor)
6
+ def get_skeleton_path_from_type(type)
7
+ skeleton_type = Skeleton::Factory.create(type)
8
+ skeleton_type.path(skeleton_type.requires_app_name? ? $env_vars.app_name : '')
10
9
  end
11
10
 
12
- def get_skeleton_path(skeleton_type)
13
- skeleton_type.path(skeleton_type.requires_app_name? ? $app_name : '')
11
+ def all_files_except_blacklisted(*custom_blacklist_files)
12
+ blacklist = (MAIN_BLACKLIST_FILES + custom_blacklist_files).flatten
13
+
14
+ # TODO: create a way to make a performatic grep here to avoid undesired/directory/*
15
+ files = Dir['{*,.*}'].sort[2..-1].reject do |entry|
16
+ pattern = entry.gsub(/\./, '\.').gsub(/\//, '\/')
17
+
18
+ found = blacklist.grep(/#{pattern}/i)
19
+
20
+ found.any?
21
+ end
22
+
23
+ files
14
24
  end
15
25
  end
16
26
  end
@@ -0,0 +1,14 @@
1
+ module Gordon
2
+ module Cookery
3
+ module HttpServer
4
+ def install_http_server_files(blacklist)
5
+ skeleton_path = get_skeleton_path_from_type($env_vars.http_server_type)
6
+
7
+ application_files = all_files_except_blacklisted(blacklist)
8
+
9
+ root(skeleton_path).install application_files
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -1,25 +1,21 @@
1
1
  module Gordon
2
2
  module Cookery
3
3
  module Init
4
- def setup_init_files
5
- create_init_files
6
- install_init_files
7
- end
4
+ def create_init
5
+ init_build_dir_path = builddir($env_vars.init_type)
8
6
 
9
- def create_init_files
10
- init_build_dir_path = File.join($init_build_dir, $init_type)
7
+ command = "ruby -S foreman export --app #{$env_vars.app_name} --user #{$env_vars.app_name} #{$env_vars.init_type} #{init_build_dir_path}"
11
8
 
12
- command = "ruby -S foreman export --app #{$app_name} #{$init_type} #{init_build_dir_path}"
13
- ::Gordon::Process.run(command)
9
+ safesystem(command)
14
10
  end
15
11
 
16
- def install_init_files
17
- init_build_dir_path = File.join($init_build_dir, $init_type)
12
+ def install_init
13
+ init_build_dir_path = builddir($env_vars.init_type)
18
14
 
19
- skeleton_type = ::Gordon::Skeleton::Types::Factory.create($init_type)
20
- path = get_skeleton_path(skeleton_type)
15
+ skeleton_path = get_skeleton_path_from_type($env_vars.init_type)
16
+ skeleton_files = Dir["#{init_build_dir_path}/*"]
21
17
 
22
- root(path).install Dir["#{init_build_dir_path}/*"]
18
+ root(skeleton_path).install skeleton_files
23
19
  end
24
20
  end
25
21
  end
@@ -0,0 +1,18 @@
1
+ module Gordon
2
+ module Cookery
3
+ module Ruby
4
+ module Common
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
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,36 @@
1
+ module Gordon
2
+ class EnvVars
3
+ attr_accessor :app_name, :app_desc, :app_repo, :app_version, :app_source_dir
4
+ attr_accessor :http_server_type
5
+ attr_accessor :init_type
6
+
7
+ def self.from_cook(options)
8
+ env_vars = []
9
+
10
+ env_vars << "GORDON_APP_NAME='#{options.app_name}'"
11
+ env_vars << "GORDON_APP_DESC='#{options.app_desc}'"
12
+ env_vars << "GORDON_APP_REPO='#{options.app_repo}'"
13
+ env_vars << "GORDON_APP_VERSION='#{options.app_version}'"
14
+ env_vars << "GORDON_APP_SOURCE_DIR='#{File.expand_path(options.source_dir)}'"
15
+ env_vars << "GORDON_HTTP_SERVER_TYPE='#{options.http_server_type}'"
16
+ env_vars << "GORDON_INIT_TYPE='#{options.init_type}'"
17
+
18
+ env_vars
19
+ end
20
+
21
+ def self.load
22
+ env_vars = self.new
23
+
24
+ env_vars.app_name = ENV['GORDON_APP_NAME']
25
+ env_vars.app_desc = ENV['GORDON_APP_DESC']
26
+ env_vars.app_repo = ENV['GORDON_APP_REPO']
27
+ env_vars.app_version = ENV['GORDON_APP_VERSION']
28
+ env_vars.app_source_dir = ENV['GORDON_APP_SOURCE_DIR']
29
+ env_vars.http_server_type = ENV['GORDON_HTTP_SERVER_TYPE']
30
+ env_vars.init_type = ENV['GORDON_INIT_TYPE']
31
+
32
+ env_vars
33
+ end
34
+ end
35
+ end
36
+
@@ -1,10 +1,11 @@
1
1
  module Gordon
2
2
  class Options
3
3
  attr_accessor :app_type, :app_name, :app_desc, :app_repo, :app_version
4
- attr_accessor :package_type, :package_dir
5
- attr_accessor :source_dir, :build_dir
6
- attr_accessor :skeleton_type
7
- attr_accessor :init_type, :init_build_dir
4
+ attr_accessor :package_type
5
+ attr_accessor :source_dir
6
+ attr_accessor :output_dir
7
+ attr_accessor :http_server_type
8
+ attr_accessor :init_type
8
9
  attr_accessor :debug
9
10
 
10
11
  def debug? ; !!debug ; end
data/lib/gordon/recipe.rb CHANGED
@@ -1,12 +1,10 @@
1
- require 'forwardable'
2
-
3
1
  module Gordon
4
2
  class Recipe
5
- attr_reader :options, :skeleton
3
+ attr_reader :options, :application
6
4
 
7
5
  def initialize(options)
8
6
  @options = options
9
- @skeleton = Skeleton::Info.new(options.skeleton_type, options.source_dir)
7
+ @application = Application::Factory.create(options.app_type)
10
8
  end
11
9
 
12
10
  def platform
@@ -23,8 +21,6 @@ module Gordon
23
21
  end
24
22
 
25
23
  def application_template_path
26
- application = Application::Factory.create(options.app_type)
27
-
28
24
  application.template_path
29
25
  end
30
26
  end
@@ -0,0 +1,12 @@
1
+ module Gordon
2
+ module Skeleton
3
+ class Factory
4
+ def self.create(skeleton_type)
5
+ namespace = "Skeleton::Types"
6
+
7
+ ::Gordon::Factory.create_instance(namespace, skeleton_type)
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -3,7 +3,7 @@ module Gordon
3
3
  module Types
4
4
  module Base
5
5
  def path(app = '')
6
- File.join(get_default_path, app)
6
+ File.join(get_default_path, app.to_s)
7
7
  end
8
8
 
9
9
  def requires_app_name?
@@ -42,14 +42,6 @@ module Gordon
42
42
  true
43
43
  end
44
44
  end
45
-
46
- class Factory
47
- def self.create(skeleton_type)
48
- namespace = "Skeleton::Types"
49
-
50
- ::Gordon::Factory.create_instance(namespace, skeleton_type)
51
- end
52
- end
53
45
  end
54
46
  end
55
47
  end
@@ -1,3 +1,3 @@
1
1
  module Gordon
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/gordon.rb CHANGED
@@ -4,14 +4,18 @@ module Gordon
4
4
  require 'gordon/cli'
5
5
  require 'gordon/cooker'
6
6
  require 'gordon/recipe'
7
+ require 'gordon/env_vars'
7
8
  require 'gordon/factory'
8
9
  require 'gordon/options'
9
10
  require 'gordon/process'
11
+ require 'gordon/application/factory'
10
12
  require 'gordon/application/types'
13
+ require 'gordon/cookery/application_user'
11
14
  require 'gordon/cookery/common'
12
15
  require 'gordon/cookery/init'
13
- require 'gordon/cookery/webserver'
14
- require 'gordon/skeleton/info'
16
+ require 'gordon/cookery/http_server'
17
+ require 'gordon/cookery/ruby/common'
18
+ require 'gordon/skeleton/factory'
15
19
  require 'gordon/skeleton/types'
16
20
  end
17
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gordon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Pinheiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-13 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: debugger
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'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: fpm-cookery
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +80,8 @@ dependencies:
66
80
  - - '>='
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
- description: Gordon is a tool to create artifacts using fpm-cookery and foreman.
83
+ description: Gordon is a tool to create OS packages using fpm-cookery and foreman,
84
+ based on a lot of conventions.
70
85
  email:
71
86
  - salizzar@gmail.com
72
87
  executables:
@@ -82,18 +97,22 @@ files:
82
97
  - bin/gordon
83
98
  - gordon.gemspec
84
99
  - lib/gordon.rb
100
+ - lib/gordon/application/factory.rb
85
101
  - lib/gordon/application/templates/ruby_web_app.rb
86
102
  - lib/gordon/application/types.rb
87
103
  - lib/gordon/cli.rb
88
104
  - lib/gordon/cooker.rb
105
+ - lib/gordon/cookery/application_user.rb
89
106
  - lib/gordon/cookery/common.rb
107
+ - lib/gordon/cookery/http_server.rb
90
108
  - lib/gordon/cookery/init.rb
91
- - lib/gordon/cookery/webserver.rb
109
+ - lib/gordon/cookery/ruby/common.rb
110
+ - lib/gordon/env_vars.rb
92
111
  - lib/gordon/factory.rb
93
112
  - lib/gordon/options.rb
94
113
  - lib/gordon/process.rb
95
114
  - lib/gordon/recipe.rb
96
- - lib/gordon/skeleton/info.rb
115
+ - lib/gordon/skeleton/factory.rb
97
116
  - lib/gordon/skeleton/types.rb
98
117
  - lib/gordon/version.rb
99
118
  homepage: https://github.com/salizzar/gordon
@@ -119,5 +138,5 @@ rubyforge_project:
119
138
  rubygems_version: 2.0.14
120
139
  signing_key:
121
140
  specification_version: 4
122
- summary: A tool to create application artifacts
141
+ summary: A tool to create application OS packages
123
142
  test_files: []
@@ -1,14 +0,0 @@
1
- module Gordon
2
- module Cookery
3
- module Webserver
4
- def setup_webserver_files
5
- skeleton_type = ::Gordon::Skeleton::Types::Factory.create($skeleton_type)
6
- skeleton_path = get_skeleton_path(skeleton_type)
7
-
8
- root(skeleton_path).install common_ruby_files
9
- root(skeleton_path).install $skeleton_files.split(',')
10
- end
11
- end
12
- end
13
- end
14
-
@@ -1,28 +0,0 @@
1
- module Gordon
2
- module Skeleton
3
- class Info
4
- attr_reader :type, :artifacts
5
-
6
- BLACKLIST = %w(.git log spec Vagrantfile coverage tmp/cache)
7
-
8
- def initialize(type, source_dir)
9
- @type, @artifacts = type, clean_source_files(source_dir)
10
- end
11
-
12
- private
13
-
14
- def clean_source_files(source_dir)
15
- source_path = File.join(source_dir, '*')
16
-
17
- all_files = Dir[source_path]
18
-
19
- blacklist = BLACKLIST.map do |file|
20
- File.join(source_dir, file)
21
- end
22
-
23
- all_files - blacklist
24
- end
25
- end
26
- end
27
- end
28
-