itamae-recipe-loader 0.0.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd4b91290b1b3ddde9f992d0afbb306f613c81dd2c958288a717b83228072ca1
4
- data.tar.gz: 22c2b3dcd9950208f92dfd81b98fb946c609ba50b748a464605e0360a580795f
3
+ metadata.gz: 222b34648e7caa130ae32e018287fe0838690fdad962fbae00b7e617919db47c
4
+ data.tar.gz: a8d0b2221a20df75f1a48d0fbcc828984f9c8c53ad02d32aabdfa07c5111b2c6
5
5
  SHA512:
6
- metadata.gz: 76d2d364cc4b069a2aa940847f2450f01bb0fb4a72163a71ffa37bc33858f6cb06c323aa1b182f7484d8e1449ac5c343871bc596306f05a24b371ea989bfe481
7
- data.tar.gz: '083eef4a066ae50e3e665cda267a3cb9d894d9bf3856148a45ad800ae6bd29a4d70e965fbf9aff70f73d3725465c11924960f8cd9211c78a255a4460b270929d'
6
+ metadata.gz: 76752c809edd0cce01db1e9040c343821bcd162f953d452e18af5d41ce804ac4b248843f1f9d2b77aa8e3330680c366baa5538883020e5f021cac6a404ecc1f7
7
+ data.tar.gz: bf22acb27ca0586961e9a15f053e7d7e9e368719964689c07e746ea9be3ee098829e696b6d41405dc269f91615f53324723ea4b908984e57080a396fcb504664
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itamae-recipe-loader (0.0.2)
4
+ itamae-recipe-loader (0.1.0)
5
5
  itamae
6
6
 
7
7
  GEM
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  rake (~> 10.0)
39
39
 
40
40
  BUNDLED WITH
41
- 1.16.0
41
+ 1.16.1
data/README.md CHANGED
@@ -1,2 +1,5 @@
1
1
  # itamae-recipe-loader
2
2
  Get out recipe names from itamae for using serverspec.
3
+
4
+ ## Badge
5
+ * [![Gem Version](https://badge.fury.io/rb/itamae-recipe-loader.svg)](https://badge.fury.io/rb/itamae-recipe-loader)
@@ -1,2 +1,37 @@
1
- require 'itamae/recipe_loader/recipe_loader'
1
+ require 'itamae'
2
2
  require 'itamae/recipe_loader/version'
3
+
4
+ module Itamae
5
+ class RecipeLoader
6
+ attr_reader :backend
7
+ attr_reader :runner
8
+
9
+ def initialize(recipe_files, backend_type, options)
10
+ self.class.logger_init(options)
11
+ @targets = []
12
+ backend = Itamae::Backend.create(backend_type, options)
13
+ @runner = Itamae::Runner.new(backend, options)
14
+ @runner.load_recipes(recipe_files)
15
+ end
16
+
17
+ def self.logger_init(options)
18
+ Itamae.logger.level = ::Logger.const_get(options[:log_level].upcase) if options[:log_level]
19
+ Itamae.logger.formatter.colored = options[:color] if options[:color]
20
+ end
21
+
22
+ def all_recipe_names(reject_recipes = ['recipes'])
23
+ recipe_names(@runner.children) - reject_recipes
24
+ end
25
+
26
+ private
27
+
28
+ def recipe_names(children)
29
+ children.each do |child|
30
+ next unless child.is_a?(Itamae::Recipe)
31
+ @targets.push(File.basename(child.dir))
32
+ recipe_names(child.children) if child.children.count.positive?
33
+ end
34
+ @targets.uniq
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  module Itamae
2
2
  class RecipeLoader
3
- VERSION = '0.0.2'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-recipe-loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ntrv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-28 00:00:00.000000000 Z
11
+ date: 2018-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,7 +68,6 @@ files:
68
68
  - Rakefile
69
69
  - itamae-recipe-loader.gemspec
70
70
  - lib/itamae/recipe_loader.rb
71
- - lib/itamae/recipe_loader/recipe_loader.rb
72
71
  - lib/itamae/recipe_loader/version.rb
73
72
  homepage: https://github.com/ntrv/itamae-recipe-loader
74
73
  licenses:
@@ -1,36 +0,0 @@
1
- require 'itamae'
2
-
3
- module Itamae
4
- class RecipeLoader
5
- attr_reader :backend
6
- attr_reader :runner
7
-
8
- def initialize(recipe_files, options)
9
- self.class.logger_init(options)
10
- @targets = []
11
- backend = Itamae::Backend.create(:ssh, options)
12
- @runner = Itamae::Runner.new(backend, options)
13
- @runner.load_recipes(recipe_files)
14
- end
15
-
16
- def self.logger_init(options)
17
- Itamae.logger.level = ::Logger.const_get(options[:log_level].upcase) if options[:log_level]
18
- Itamae.logger.formatter.colored = options[:color] if options[:color]
19
- end
20
-
21
- def all_recipe_names(reject_recipes = ['recipes'])
22
- recipe_names(@runner.children) - reject_recipes
23
- end
24
-
25
- private
26
-
27
- def recipe_names(children)
28
- children.each do |child|
29
- next unless child.is_a?(Itamae::Recipe)
30
- @targets.push(File.basename(child.dir))
31
- recipe_names(child.children) if child.children.count.positive?
32
- end
33
- @targets.uniq
34
- end
35
- end
36
- end