minarai 0.0.2 → 0.0.3

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: 1e706e4ae78dafce3b8a70421c6edf7c270a2eba
4
- data.tar.gz: 935db788fd1279270a7318bf1b744d398c642763
3
+ metadata.gz: c04f414d627ba508af6b92196764eedde11fb7e1
4
+ data.tar.gz: 75848c007915cc99573b5e06993d2e02530fc226
5
5
  SHA512:
6
- metadata.gz: eca12c2bff209b6c3d731bf0ccec4b618e1688d4479a2a89a5ca9cba982f962ce36bcdb30f6c63f5a7e966e91df229b4742b96345e5064361657c01bb4787a76
7
- data.tar.gz: d52478c893f18abb0c98f26956b33f5137573f84160531b9cb7dc6fbc8297736fb46688e7c68b6b1e8acddaec4d7330d6eeaf200bf0d998346bc27fe69c57cc4
6
+ metadata.gz: a72f8db9c19f587ff5f28da1bfca44e9e226b47e1e0b5157910a1c8e9df6bdd640e8550974b358f9114ac1f6aff4f5b64c1baac08347d736d8a12f47e059cf59
7
+ data.tar.gz: 4e6faea2438bcf134fdc0133e1edc7032d16032787984086ce8bbeee0317d33dbbd1f97ae53d76b496cb84c876ab47fb951c629312cda37c9d10ee41980e114b
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Minarai
2
+ [![Gem Version](https://badge.fury.io/rb/minarai.svg)](http://badge.fury.io/rb/minarai)
2
3
  [![Build Status](https://travis-ci.org/ganmacs/minarai.svg?branch=master)](https://travis-ci.org/ganmacs/minarai)
4
+ [![Code Climate](https://codeclimate.com/github/ganmacs/minarai/badges/gpa.svg)](https://codeclimate.com/github/ganmacs/minarai)
3
5
 
4
6
  Configuration-Management Tool
5
7
 
@@ -42,13 +44,14 @@ $ minarai RECIPE [--variable=VARIABLE_PATH]
42
44
 
43
45
  ## Action type
44
46
 
45
- * hoembrew
46
- * directory
47
- * file
48
47
  * git
49
- * hoembrew_cask
48
+ * file
50
49
  * link
50
+ * rbenv
51
51
  * url_get
52
+ * hoembrew
53
+ * directory
54
+ * hoembrew_cask
52
55
 
53
56
  ## recipe
54
57
 
@@ -0,0 +1 @@
1
+ invalid
@@ -2,6 +2,10 @@
2
2
  type: homebrew
3
3
  item: vim
4
4
 
5
+ - name: create tmp directory
6
+ type: directory
7
+ destination: <%= tmp_dir %>
8
+
5
9
  - name: clone dotfile
6
10
  type: git
7
11
  repository: <%= remote_dotfile_repo %>
@@ -0,0 +1,4 @@
1
+ - name: install ruby 2.3.0-dev
2
+ type: rbenv
3
+ version: 2.3.0-dev
4
+ global: true
@@ -1,4 +1,5 @@
1
1
  remote_dotfile_repo: git@github.com:ganmacs/dotfiles.git
2
+ tmp_dir: /Users/ganmacs/tmp
2
3
  dotfile_path: /Users/ganmacs/tmp/dotfile
3
4
  vim_config_in_dotfile: /Users/ganmacs/tmp/dotfile/vim/vimrc
4
5
  dot_vim_path: /Users/ganmacs/tmp/.vim
@@ -7,6 +7,7 @@ require 'minarai/actions/link'
7
7
  require 'minarai/actions/unknown'
8
8
  require 'minarai/actions/directory'
9
9
  require 'minarai/actions/url_get'
10
+ require 'minarai/actions/rbenv'
10
11
 
11
12
  module Minarai
12
13
  class ActionBuilder
@@ -0,0 +1,49 @@
1
+ require 'minarai/actions/base'
2
+
3
+ module Minarai
4
+ module Actions
5
+ class Rbenv < Base
6
+ attribute :version, required: true, type: String
7
+ attribute :global, type: [TrueClass, FalseClass], default: true
8
+
9
+ def run
10
+ install_specific_ruby_version unless has_specific_ruby_version?
11
+ set_global_ruby_version unless set_specific_ruby_version?
12
+ end
13
+
14
+ private
15
+
16
+ def install_specific_ruby_version
17
+ run_command "rbenv install #{version}"
18
+ end
19
+
20
+ def complete?
21
+ has_rbenv? && has_specific_ruby_version? && set_specific_ruby_version?
22
+ end
23
+
24
+ def has_rbenv?
25
+ check_command 'which rbenv'
26
+ end
27
+
28
+ def has_specific_ruby_version?
29
+ check_command "rbenv prefix #{version}"
30
+ end
31
+
32
+ def set_valid_glbal_ruby_version?
33
+ global_version == version
34
+ end
35
+
36
+ def global_version
37
+ run_command('rbenv global').stdout.rstrip
38
+ end
39
+
40
+ def set_specific_ruby_version?
41
+ check_command "rbenv global #{version}"
42
+ end
43
+
44
+ def name
45
+ super || "rbenv install ruby version #{version}"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,5 +1,5 @@
1
1
  require 'minarai/actions/base'
2
- require 'minarai/errors/invalid_action_type_error'
2
+ require 'minarai/errors/unknown_action_type_error'
3
3
 
4
4
  module Minarai
5
5
  module Actions
@@ -9,7 +9,7 @@ module Minarai
9
9
  end
10
10
 
11
11
  def error_messages
12
- [Minarai::Errors::InvalidActionTypeError.new(name)]
12
+ [Minarai::Errors::UnknownActionTypeError.new(type)]
13
13
  end
14
14
 
15
15
  private
@@ -0,0 +1,15 @@
1
+ require 'minarai/errors/base'
2
+
3
+ module Minarai
4
+ module Errors
5
+ class UnknownActionTypeError < Base
6
+ def initialize(type)
7
+ @type = type
8
+ end
9
+
10
+ def to_s
11
+ "`type` : #{@type} is unknown"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Minarai
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -5,9 +5,13 @@ class TypeValidator < ActiveModel::EachValidator
5
5
  super.merge(allow_nil: true)
6
6
  end
7
7
 
8
+ def klasses
9
+ options[:in] || [options[:with]]
10
+ end
11
+
8
12
  def validate_each(record, attribute, value)
9
- unless value.is_a?(options[:with])
10
- record.errors.add(attribute, "must be a #{options[:with]}, not #{value.class}")
13
+ unless klasses.any? { |klass| value.is_a?(klass) }
14
+ record.errors.add(attribute, "must be a #{klasses}, not #{value.class}")
11
15
  end
12
16
  end
13
17
  end
@@ -0,0 +1,36 @@
1
+ require 'minarai/loaders/recipe_loader'
2
+ require 'minarai/recipe'
3
+
4
+ describe Minarai::Loaders::RecipeLoader do
5
+ subject { loader.load }
6
+
7
+ let!(:loader) { described_class.new(*option) }
8
+
9
+ describe 'loading recipe and variable ' do
10
+ context 'with recipe file' do
11
+ context 'when valid path received' do
12
+ let(:option) { 'examples/recipe_git.yml' }
13
+ it { is_expected.to be_a Minarai::Recipe }
14
+ end
15
+
16
+ context 'when valid path received' do
17
+ let(:option) { 'examples/invalid' }
18
+ it { expect { loader.load }.to raise_error }
19
+ end
20
+
21
+ context 'when excpept yml or erb file received' do
22
+ let(:option) { 'examples/recipe.invalid' }
23
+ it { expect { loader.load }.to raise_error }
24
+ end
25
+ end
26
+
27
+ context 'with recipe file and variables files' do
28
+ context 'when valid path received' do
29
+ let(:option) do
30
+ ['examples/recipe_erb.yml.erb', { variable_path: 'examples/recipe_variable.yml' }]
31
+ end
32
+ it { is_expected.to be_a Minarai::Recipe }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -3,3 +3,6 @@ RSpec.configure do |config|
3
3
  config.filter_run :focus
4
4
  config.order = 'random'
5
5
  end
6
+
7
+ require 'specinfra'
8
+ Specinfra.configuration.backend = :exec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minarai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ganmacs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-09 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -167,6 +167,7 @@ files:
167
167
  - README.md
168
168
  - Rakefile
169
169
  - bin/minarai
170
+ - examples/recipe.invalid
170
171
  - examples/recipe_directory.yml
171
172
  - examples/recipe_erb.yml.erb
172
173
  - examples/recipe_file.yml
@@ -174,6 +175,7 @@ files:
174
175
  - examples/recipe_homebrew.yml
175
176
  - examples/recipe_homebrew_cask.yml
176
177
  - examples/recipe_link.yml
178
+ - examples/recipe_rbenv.yml
177
179
  - examples/recipe_url_get.yml
178
180
  - examples/recipe_variable.yml
179
181
  - lib/minarai.rb
@@ -185,6 +187,7 @@ files:
185
187
  - lib/minarai/actions/homebrew.rb
186
188
  - lib/minarai/actions/homebrew_cask.rb
187
189
  - lib/minarai/actions/link.rb
190
+ - lib/minarai/actions/rbenv.rb
188
191
  - lib/minarai/actions/unknown.rb
189
192
  - lib/minarai/actions/url_get.rb
190
193
  - lib/minarai/command.rb
@@ -192,6 +195,7 @@ files:
192
195
  - lib/minarai/errors/base.rb
193
196
  - lib/minarai/errors/invalid_action_type_error.rb
194
197
  - lib/minarai/errors/missing_recipe_path_error.rb
198
+ - lib/minarai/errors/unknown_action_type_error.rb
195
199
  - lib/minarai/loaders/base.rb
196
200
  - lib/minarai/loaders/recipe_loader.rb
197
201
  - lib/minarai/loaders/variable_loader.rb
@@ -203,8 +207,9 @@ files:
203
207
  - lib/validator/required_validator.rb
204
208
  - lib/validator/type_validator.rb
205
209
  - minarai.gemspec
206
- - spec/minarai/unit/action/base_spec.rb
207
210
  - spec/minarai/unit/action_builder_spec.rb
211
+ - spec/minarai/unit/actions/base_spec.rb
212
+ - spec/minarai/unit/loaders/recipe_loader_spec.rb
208
213
  - spec/minarai/unit/logger_spec.rb
209
214
  - spec/minarai/unit/variable_spec.rb
210
215
  - spec/spec_helper.rb
@@ -233,8 +238,9 @@ signing_key:
233
238
  specification_version: 4
234
239
  summary: Minarai Configuration Tool
235
240
  test_files:
236
- - spec/minarai/unit/action/base_spec.rb
237
241
  - spec/minarai/unit/action_builder_spec.rb
242
+ - spec/minarai/unit/actions/base_spec.rb
243
+ - spec/minarai/unit/loaders/recipe_loader_spec.rb
238
244
  - spec/minarai/unit/logger_spec.rb
239
245
  - spec/minarai/unit/variable_spec.rb
240
246
  - spec/spec_helper.rb