gordon 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b043e25a6b4c3ccf9b888fbed5a49bdebdf81e84
4
- data.tar.gz: ee2b1c564897fe0ae5873ebec8cd49fdb1ece79d
3
+ metadata.gz: 41d53eb623de67ea61bd4512fbbf6ee0dabeeb10
4
+ data.tar.gz: daf61b33e4c44a9669b55b8175df89d6ac28ba0d
5
5
  SHA512:
6
- metadata.gz: 277914dad0840a1435c46241f80b6ccf44e581ac542f39a0923ac2a3133e7e3f5bd775256eb814d52491fc77e4005c1616a9e9e0e8b7420822e532d67cfc26ca
7
- data.tar.gz: 652c41bb215b2f5c650109d8ca8267aa2e295fa86a3b7858e7d2136081c8ccc63b0fed32ae2dc78f541c06cf17ea397e94eff3a70d1c185c6bbb1fe983f91b94
6
+ metadata.gz: 7a8bec5a44e817b32b6a6a243e92aa4514ebc2ac75f9146e7b21de623d269b5523d126add34286fc23be4b27e5aa255ad742f0916419deae828fae03160e0897
7
+ data.tar.gz: aec74f74cef7db913b7b850326acfed100495cfa36d994cce87cdc4070add4d01fffe0c3bf3e9da41d9322a1a1b219c7d1d292d3652979a1e2473a436778ba9c
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Gordon
2
2
 
3
- We all know that build application packages is a pain. A lot of pain.
3
+ We all know that packaging applications is a pain. A lot of pain.
4
4
 
5
- Of course, [fpm](https://github.com/jordansissel/fpm) is a awesome tool to abstract package building for a lot of Operational Systems. Period.
5
+ Of course, [fpm](https://github.com/jordansissel/fpm) is a awesome tool to abstract package generation for a lot of Operational Systems. Period.
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
 
@@ -12,7 +12,7 @@ But, unfortunately, create fpm-cookery recipes for each application can be borin
12
12
 
13
13
  And when you are in front with a web application that breaks Nginx or Apache conventions? Do you remember that feel, bro?
14
14
 
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
+ Gordon is a try to automagically create init files using Foreman and export 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.
16
16
 
17
17
  ## How it works?
18
18
 
@@ -51,7 +51,7 @@ Or install it yourself as:
51
51
 
52
52
  ## Usage
53
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 how to package two apps: ruby web and standalone java.
54
+ Gordon have two ways to package applications. You can create a yaml file called `gordon.yml` on root of your app and CLI will detect it automatically. Here an example how to package two apps: ruby web and standalone java.
55
55
 
56
56
  ```
57
57
  recipes:
@@ -90,7 +90,7 @@ recipes:
90
90
 
91
91
  ```
92
92
 
93
- For more details about all parameters available, please run `gordon --help` for more details.
93
+ For more details about all parameters available, please run `gordon --help`.
94
94
 
95
95
  Another way is using CLI directly. Below some examples how to use it.
96
96
 
@@ -10,7 +10,7 @@ module Gordon
10
10
  parser = create_option_parser(options)
11
11
  parser.parse!
12
12
 
13
- recipes = Cookbook.exists? ? Cookbook.read_and_merge_with(options) : [ Recipe.new(options) ]
13
+ recipes = Cookbook.exists?(options) ? Cookbook.read_and_merge_with(options) : [ Recipe.new(options) ]
14
14
  cooker = Cooker.new(recipes)
15
15
  cooker.cook
16
16
  end
@@ -75,6 +75,10 @@ module Gordon
75
75
  options.output_dir = output_dir
76
76
  end
77
77
 
78
+ opts.on('-C', '--recipe RECIPE', 'Gordon YAML Recipe') do |recipe|
79
+ options.recipe = recipe
80
+ end
81
+
78
82
  opts.on('-d', '--debug', 'Debug Mode') do |debug|
79
83
  options.debug = debug
80
84
  end
@@ -3,12 +3,15 @@ require 'erb'
3
3
 
4
4
  module Gordon
5
5
  class Cookbook
6
- def self.exists?
7
- File.exists?(self.get_path)
6
+ def self.exists?(options)
7
+ path = self.get_path(options)
8
+ !path.nil?
8
9
  end
9
10
 
10
11
  def self.read_and_merge_with(main_options)
11
- path = self.get_path
12
+ path = self.get_path(main_options)
13
+ raise Exceptions::RecipeNotFound.new if path.nil?
14
+
12
15
  body = File.read(path)
13
16
  yaml = ERB.new(body)
14
17
  data = YAML.load(yaml.result)
@@ -21,8 +24,38 @@ module Gordon
21
24
 
22
25
  private
23
26
 
24
- def self.get_path
25
- File.join(Dir.pwd, 'gordon.yml')
27
+ def self.get_path(options)
28
+ recipe = options.recipe.to_s
29
+
30
+ unless recipe.empty?
31
+ recipe_yaml_path = self.get_recipe_yaml_path(recipe)
32
+ return recipe_yaml_path if File.exists?(recipe_yaml_path)
33
+ end
34
+
35
+ gordon_yaml_path = self.get_gordon_yaml_path
36
+ return gordon_yaml_path if File.exists?(gordon_yaml_path)
37
+
38
+ nil
39
+
40
+ # recipe = options.recipe.to_s
41
+ # return nil if recipe.empty?
42
+
43
+ # recipe_yaml_path = self.get_recipe_yaml_path(recipe)
44
+ # return recipe_yaml_path if File.exists?(recipe_yaml_path)
45
+
46
+ # nil
47
+ end
48
+
49
+ def self.get_gordon_yaml_path
50
+ self.get_recipe_path('gordon.yml')
51
+ end
52
+
53
+ def self.get_recipe_yaml_path(recipe)
54
+ self.get_recipe_path(recipe)
55
+ end
56
+
57
+ def self.get_recipe_path(recipe)
58
+ File.join(Dir.pwd, recipe)
26
59
  end
27
60
  end
28
61
  end
@@ -16,4 +16,3 @@ module Gordon
16
16
  end
17
17
  end
18
18
 
19
-
@@ -5,6 +5,12 @@ module Gordon
5
5
  super("Operational System not mapped for #{class_name}. OS: #{os_name}")
6
6
  end
7
7
  end
8
+
9
+ class RecipeNotFound < RuntimeError
10
+ def initialize
11
+ super("Cannot found gordon.yml or custom gordon recipe yaml.")
12
+ end
13
+ end
8
14
  end
9
15
  end
10
16
 
@@ -2,6 +2,7 @@ module Gordon
2
2
  class Options
3
3
  attr_accessor :app_name, :app_description, :app_homepage, :app_version, :app_source, :app_source_excludes, :app_type
4
4
  attr_accessor :runtime_name, :runtime_version
5
+ attr_accessor :recipe
5
6
  attr_accessor :http_server_type
6
7
  attr_accessor :web_server_type
7
8
  attr_accessor :init_type
@@ -28,7 +29,7 @@ module Gordon
28
29
  opt.init_type = main_options.init_type || recipe['init_type']
29
30
 
30
31
  opt.package_type = main_options.package_type || recipe['package_type']
31
- opt.output_dir = main_options.output_dir || recipe['output_dir']
32
+ opt.output_dir = recipe['output_dir'] || main_options.output_dir
32
33
 
33
34
  opt.debug = !main_options.debug.nil? ? main_options.debug : recipe['debug']
34
35
  opt.trace = !main_options.trace.nil? ? main_options.trace : recipe['trace']
@@ -1,3 +1,3 @@
1
1
  module Gordon
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -51,6 +51,7 @@ describe Gordon::CLI do
51
51
  [ %w(-S --app-source), "." ],
52
52
  [ %w(-E --app-source-excludes), %(an path) ],
53
53
  [ %w(-T --app-type), "web" ],
54
+ [ %w(-C --recipe), "xirubiru.yml" ],
54
55
  [ %w(-X --runtime-name), "ruby" ],
55
56
  [ %w(-R --runtime-version), "2.2.0" ],
56
57
  [ %w(-H --http-server-type), "nginx" ],
@@ -1,19 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Gordon::Cookbook do
4
- let(:path) { File.join(Dir.pwd, 'gordon.yml') }
4
+ let(:gordon_yaml_path) { File.join(Dir.pwd, 'gordon.yml') }
5
+ let(:recipe_yaml_path) { File.join(Dir.pwd, 'recipe.yml') }
5
6
 
6
7
  context 'checking if file exists' do
7
- it 'returns true when exists' do
8
- expect(File).to receive(:exists?).with(path).and_return(true)
8
+ let(:options) { instance_double(Gordon::Options) }
9
9
 
10
- expect(described_class.exists?).to be_truthy
10
+ it 'returns true when recipe yaml exists' do
11
+ expect(options).to receive(:recipe).and_return('recipe.yml')
12
+
13
+ expect(File).to receive(:exists?).with(recipe_yaml_path).and_return(true)
14
+ expect(File).to_not receive(:exists?).with(gordon_yaml_path)
15
+
16
+ expect(described_class.exists?(options)).to be_truthy
11
17
  end
12
18
 
13
- it 'returns false otherwise' do
14
- expect(File).to receive(:exists?).with(path).and_return(false)
19
+ it 'returns true when gordon yaml exists' do
20
+ expect(options).to receive(:recipe).and_return(nil)
21
+
22
+ expect(File).to receive(:exists?).with(gordon_yaml_path).and_return(true)
23
+ expect(File).to_not receive(:exists?).with(recipe_yaml_path)
15
24
 
16
- expect(described_class.exists?).to be_falsey
25
+ expect(described_class.exists?(options)).to be_truthy
17
26
  end
18
27
  end
19
28
 
@@ -37,12 +46,37 @@ describe Gordon::Cookbook do
37
46
  let(:recipe) { instance_double(Gordon::Recipe) }
38
47
  let(:recipes) { [ recipe ] }
39
48
 
49
+ it 'renders recipe yaml file and returns a list of recipes' do
50
+ expect(main_options).to receive(:recipe).and_return('recipe.yml')
51
+
52
+ expect(File).to receive(:exists?).with(recipe_yaml_path).and_return(true)
53
+ expect(File).to_not receive(:exists?).with(gordon_yaml_path)
54
+
55
+ expect(File).to receive(:read).with(recipe_yaml_path).and_return(content)
56
+
57
+ erb = instance_double(ERB)
58
+ expect(erb).to receive(:result).and_return(result)
59
+ expect(ERB).to receive(:new).with(content).and_return(erb)
60
+ expect(YAML).to receive(:load).with(result).and_return(yaml)
61
+
62
+ option = instance_double(Gordon::Options)
63
+ expect(Gordon::Options).to receive(:from).with(main_options, yaml['recipes'].first).and_return(option)
64
+ expect(Gordon::Recipe).to receive(:new).with(option).and_return(recipe)
65
+
66
+ expect(described_class.read_and_merge_with(main_options)).to eq(recipes)
67
+ end
68
+
40
69
  it 'renders gordon yaml file and returns a list of recipes' do
41
- expect(File).to receive(:read).with(path).and_return(content)
70
+ expect(main_options).to receive(:recipe).and_return(nil)
71
+
72
+ expect(File).to_not receive(:exists?).with(recipe_yaml_path)
73
+ expect(File).to receive(:exists?).with(gordon_yaml_path).and_return(true)
74
+
75
+ expect(File).to receive(:read).with(gordon_yaml_path).and_return(content)
42
76
 
43
77
  erb = instance_double(ERB)
44
- expect(erb).to receive(:result).and_return(result)
45
- expect(ERB).to receive(:new).with(content).and_return(erb)
78
+ expect(erb).to receive(:result).and_return(result)
79
+ expect(ERB).to receive(:new).with(content).and_return(erb)
46
80
  expect(YAML).to receive(:load).with(result).and_return(yaml)
47
81
 
48
82
  option = instance_double(Gordon::Options)
@@ -51,6 +85,14 @@ describe Gordon::Cookbook do
51
85
 
52
86
  expect(described_class.read_and_merge_with(main_options)).to eq(recipes)
53
87
  end
88
+
89
+ it 'raises error when no recipe is found' do
90
+ expect(main_options).to receive(:recipe).and_return(nil)
91
+
92
+ expect(File).to receive(:exists?).with(gordon_yaml_path).and_return(false)
93
+
94
+ expect{ described_class.read_and_merge_with(main_options) }.to raise_error(Gordon::Exceptions::RecipeNotFound)
95
+ end
54
96
  end
55
97
  end
56
98
 
@@ -62,6 +62,12 @@ describe Gordon::Options do
62
62
  expect(instance.app_source).to eq(recipe['app_source'])
63
63
  end
64
64
 
65
+ it 'priorizes output dir from recipe instead of main option' do
66
+ instance = described_class.from(main_options, recipe)
67
+
68
+ expect(instance.output_dir).to eq(recipe['output_dir'])
69
+ end
70
+
65
71
  it 'merges app source excludes values from main options and recipes' do
66
72
  instance = described_class.from(main_options, recipe)
67
73
 
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Pinheiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-28 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.4.8
191
+ rubygems_version: 2.4.6
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: A tool to create application OS packages