serverkit-rbenv 0.2.0 → 0.3.0

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: 1ac1ebbe4974fb298789d268f2fb0c8bfd3cdb58
4
- data.tar.gz: 0068580d3d8abf4e6b7b3a27fb5319915c7ecc9a
3
+ metadata.gz: f9e0a154d70b5221a4172560e036b057f0dae64a
4
+ data.tar.gz: b226ef7916adacdd999cc47aa6df47e797f1e68a
5
5
  SHA512:
6
- metadata.gz: f2a96c9b4d97eff91bd48f02f1f9dd7a70b6a00e8444abfce435d85d84a7009734e1c049f9d8730e7f9e4b854af8f21bbcadc6ee1cbef78319c5ccd8353d2877
7
- data.tar.gz: 500fa14f684f34c76519c11f38c0328a004c03e0e70d465e2408ab97447f6855213c0541bcc0b53021f3542a0804ec8c28e749e8edbfe9f40fb3defa84bf4787
6
+ metadata.gz: 04480a54aa224aa0e002916eac40de72d88cded7e8242be22b9dda126c7408eb7b5b45ea546813cde4d64893a0bcbdbd2a99f50875d30c7f0bd20d3c3961bd79
7
+ data.tar.gz: 485394d614b16c75ceb9992233947902314dc6b58b2f2be99f1762eaf8bff9deab3aa0684e4a615e7fcc70c0ccb2d7520e008ed76f66a57f57a13819e98e9038
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.3.0
2
+ - Provide more easy default values for some attributes
3
+
1
4
  ## 0.2.0
2
5
  - Add dependencies attribute for easy installation
3
6
 
data/README.md CHANGED
@@ -19,7 +19,7 @@ Make sure the specified version of Ruby is installed with rbenv.
19
19
  #### Attributes
20
20
  - version - Installed Ruby version (required) (e.g. `"2.2.0"`)
21
21
  - global - Pass true to make it global (default: `false`)
22
- - rbenv_executable_path - Path to rbenv executable (default: `"rbenv"`)
22
+ - rbenv_executable_path - Path to rbenv executable (default: $HOME/.rbenv/bin/rbenv or rbenv)
23
23
  - user - user name (required if dependencies is true)
24
24
  - dependencies - Pass true to install rbenv, ruby-build, their dependencies, profile script
25
25
  - profile_path - Where to append init script for rbenv (required if dependencies is true)
@@ -30,6 +30,10 @@ resources:
30
30
  - type: rbenv_ruby
31
31
  version: 2.2.0
32
32
  global: true
33
+ rbenv_executable_path: /home/foo/.rbenv/bin/rbenv
34
+ user: foo
35
+ dependencies: true
36
+ profile_path: /home/foo/.bash_profile
33
37
  ```
34
38
 
35
39
  ### rbenv_dependent_packages
@@ -41,6 +45,20 @@ resources:
41
45
  - type: rbenv_dependent_packages
42
46
  ```
43
47
 
48
+ ### rbenv_profile
49
+ Append rbenv init lines into profile file.
50
+
51
+ #### Attributes
52
+ - profile_path - path to profile file (default: .bash_profile path if user specified)
53
+ - user - user name (required)
54
+
55
+ #### Example
56
+ ```yml
57
+ resources:
58
+ - type: rbenv_profile
59
+ user: foo
60
+ ```
61
+
44
62
  ### rbenv_rbenv
45
63
  Install rbenv into home directory.
46
64
 
@@ -54,7 +72,7 @@ resources:
54
72
  user: foo
55
73
  ```
56
74
 
57
- ### rbenv_ruby
75
+ ### rbenv_ruby_build
58
76
  Install ruby-build into home directory.
59
77
 
60
78
  #### Attributes
@@ -1,5 +1,5 @@
1
1
  module Serverkit
2
2
  module Rbenv
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -3,7 +3,8 @@ require "serverkit/resources/base"
3
3
  module Serverkit
4
4
  module Resources
5
5
  class RbenvProfile < Base
6
- attribute :profile_path, required: true, type: String
6
+ attribute :profile_path, type: String
7
+ attribute :user, at_least_one_of: [:profile_path], type: String
7
8
 
8
9
  # @note Override
9
10
  def apply
@@ -23,13 +24,18 @@ module Serverkit
23
24
  resource = Serverkit::Resources::Line.new(
24
25
  @recipe,
25
26
  "line" => line,
26
- "path" => profile_path,
27
+ "path" => proper_profile_path,
27
28
  )
28
29
  resource.backend = backend
29
30
  resource
30
31
  end
31
32
  end
32
33
 
34
+ # @return [String]
35
+ def get_user_home_directory
36
+ run_command_from_identifier(:get_user_home_directory, user).stdout.rstrip
37
+ end
38
+
33
39
  # @return [Array<String>]
34
40
  def lines
35
41
  [
@@ -37,6 +43,11 @@ module Serverkit
37
43
  %<eval "$(rbenv init -)">,
38
44
  ]
39
45
  end
46
+
47
+ # @return [String]
48
+ def proper_profile_path
49
+ @proper_profile_path ||= profile_path || "#{get_user_home_directory}/.bash_profile"
50
+ end
40
51
  end
41
52
  end
42
53
  end
@@ -9,7 +9,7 @@ module Serverkit
9
9
  attribute :dependencies, type: [TrueClass, FalseClass]
10
10
  attribute :global, default: DEFAULT_GLOBAL, type: [FalseClass, TrueClass]
11
11
  attribute :profile_path, type: String
12
- attribute :rbenv_executable_path, default: DEFAULT_RBENV_EXECUTABLE_PATH, type: String
12
+ attribute :rbenv_executable_path, type: String
13
13
  attribute :version, required: true, type: String
14
14
 
15
15
  # Install the specified version of Ruby with rbenv if rbenv is executable
@@ -51,8 +51,13 @@ module Serverkit
51
51
  version
52
52
  end
53
53
 
54
+ # @return [String]
55
+ def get_user_home_directory
56
+ run_command_from_identifier(:get_user_home_directory, user).stdout.rstrip
57
+ end
58
+
54
59
  def global_version
55
- run_command("#{rbenv_executable_path} global").stdout.rstrip
60
+ run_command("#{proper_rbenv_executable_path} global").stdout.rstrip
56
61
  end
57
62
 
58
63
  def has_correct_dependencies?
@@ -66,12 +71,12 @@ module Serverkit
66
71
 
67
72
  # @return [true, false] True if rbenv command is executable
68
73
  def has_rbenv?
69
- check_command("which #{rbenv_executable_path}")
74
+ check_command("which #{proper_rbenv_executable_path}")
70
75
  end
71
76
 
72
77
  # @return [true, false] True if the specified version of Ruby is installed
73
78
  def has_specified_ruby_version?
74
- check_command("#{rbenv_executable_path} prefix #{version}")
79
+ check_command("#{proper_rbenv_executable_path} prefix #{version}")
75
80
  end
76
81
 
77
82
  def install_dependencies
@@ -79,11 +84,23 @@ module Serverkit
79
84
  end
80
85
 
81
86
  def install_specified_ruby_version
82
- run_command("#{rbenv_executable_path} install #{version}")
87
+ run_command("#{proper_rbenv_executable_path} install #{version}")
88
+ end
89
+
90
+ # @return [String]
91
+ def proper_rbenv_executable_path
92
+ case
93
+ when rbenv_executable_path
94
+ rbenv_executable_path
95
+ when user
96
+ "#{get_user_home_directory}/.rbenv/bin/rbenv"
97
+ else
98
+ DEFAULT_RBENV_EXECUTABLE_PATH
99
+ end
83
100
  end
84
101
 
85
102
  def set_specified_global_version
86
- run_command("#{rbenv_executable_path} global #{version}")
103
+ run_command("#{proper_rbenv_executable_path} global #{version}")
87
104
  end
88
105
  end
89
106
  end
@@ -16,7 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_runtime_dependency "serverkit"
19
+ spec.add_runtime_dependency "serverspec", ">= 0.6.2"
20
+ spec.add_runtime_dependency "specinfra", ">= 2.31.1"
20
21
  spec.add_development_dependency "bundler", "~> 1.9"
21
22
  spec.add_development_dependency "rake", "~> 10.0"
22
23
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverkit-rbenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-10 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: serverkit
14
+ name: serverspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.6.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.6.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: specinfra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.31.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.31.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement