Module: Hem
- Defined in:
- lib/hem/ui.rb,
lib/hem/cli.rb,
lib/hem/null.rb,
lib/hem/util.rb,
lib/hem/paths.rb,
lib/hem/config.rb,
lib/hem/errors.rb,
lib/hem/logging.rb,
lib/hem/plugins.rb,
lib/hem/version.rb,
lib/hem/metadata.rb,
lib/hem/config/file.rb,
lib/hem/lib/s3/sync.rb,
lib/hem/helper/shell.rb,
lib/hem/helper/github.rb,
lib/hem/lib/seed/seed.rb,
lib/hem/help_formatter.rb,
lib/hem/helper/command.rb,
lib/hem/lib/host_check.rb,
lib/hem/lib/vm/command.rb,
lib/hem/asset_applicator.rb,
lib/hem/lib/seed/project.rb,
lib/hem/lib/vm/inspector.rb,
lib/hem/helper/vm_command.rb,
lib/hem/lib/local/command.rb,
lib/hem/lib/s3/local/file.rb,
lib/hem/lib/seed/replacer.rb,
lib/hem/lib/seed/template.rb,
lib/hem/lib/host_check/git.rb,
lib/hem/lib/s3/remote/file.rb,
lib/hem/helper/file_locator.rb,
lib/hem/lib/host_check/deps.rb,
lib/hem/error_handlers/debug.rb,
lib/hem/helper/http_download.rb,
lib/hem/helper/argument_parser.rb,
lib/hem/lib/host_check/vagrant.rb,
lib/hem/lib/s3/local/iohandler.rb,
lib/hem/error_handlers/friendly.rb,
lib/hem/lib/s3/remote/iohandler.rb,
lib/hem/error_handlers/exit_code_map.rb,
lib/hem/lib/self_signed_cert_generator.rb
Defined Under Namespace
Modules: Config, ErrorHandlers, Helper, Lib, Logging
Classes: AssetApplicator, AssetApplicatorRegistry, Cli, Error, ExternalCommandError, Halt, HelpFormatter, HemVersionError, HostCheckError, InvalidCommandOrOpt, Metadata, MissingArgumentsError, MissingDependencies, MissingDependency, NonInteractiveError, Null, Plugins, PluginsAlreadySetupError, ProjectOnlyError, RubyVersionError, Ui, UndefinedEditorError, UserError
Constant Summary
collapse
- VERSION =
'1.2.4'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
Utility method to access (with initialization) the asset applicator registry. This allows you to register new asset applicator methods on a per-project basis. For example:
Hem.asset_applicators.register /.*\.zip/ do |file|
Dir.chdir File.dirname(file) do
shell "unzip", file
end
end
17
18
19
|
# File 'lib/hem/asset_applicator.rb', line 17
def asset_applicators
@asset_applicators
end
|
.cli ⇒ Object
Returns the value of attribute cli.
4
5
6
|
# File 'lib/hem/cli.rb', line 4
def cli
@cli
end
|
.logger ⇒ Object
Returns the value of attribute logger.
3
4
5
|
# File 'lib/hem/logging.rb', line 3
def logger
@logger
end
|
.plugins ⇒ Object
Returns the value of attribute plugins.
3
4
5
|
# File 'lib/hem/plugins.rb', line 3
def plugins
@plugins
end
|
.project_bar_cache ⇒ Object
Returns the value of attribute project_bar_cache.
4
5
6
|
# File 'lib/hem/util.rb', line 4
def project_bar_cache
@project_bar_cache
end
|
.project_config ⇒ Object
Returns the value of attribute project_config.
3
4
5
|
# File 'lib/hem/config.rb', line 3
def project_config
@project_config
end
|
.project_path ⇒ Object
Returns the value of attribute project_path.
3
4
5
|
# File 'lib/hem/paths.rb', line 3
def project_path
@project_path
end
|
.ui ⇒ Object
Returns the value of attribute ui.
3
4
5
|
# File 'lib/hem/ui.rb', line 3
def ui
@ui
end
|
.user_config ⇒ Object
Returns the value of attribute user_config.
3
4
5
|
# File 'lib/hem/config.rb', line 3
def user_config
@user_config
end
|
Class Method Details
.aws_credentials ⇒ Object
48
49
50
51
52
53
|
# File 'lib/hem/util.rb', line 48
def aws_credentials
{
:access_key_id => maybe(Hem.user_config.aws.access_key_id) || ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => maybe(Hem.user_config.aws.secret_access_key) || ENV['AWS_SECRET_ACCESS_KEY']
}
end
|
.config_path ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/hem/paths.rb', line 5
def config_path
@config_path ||= begin
config_paths = [ File.join(ENV['HOME'], '.hem'), File.join(ENV['HOME'], '.hobo') ]
config_paths.each do |path|
return path if File.exists? File.join(path, 'config.yaml')
end
FileUtils.mkdir_p(config_paths.first)
config_paths.first
end
end
|
.detect_project_type(limit_path = nil) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/hem/paths.rb', line 21
def detect_project_type limit_path = nil
@project_type = 'Hem'
@project_path = nil
searches = [
{ type: "Hem", indicators: [ "Hemfile", "tools/hem"] },
{ type: "Hobo", indicators: [ "Hobofile", "tools/hobo"] },
{ type: "Hem", indicators: ["tools/vagrant/Vagrantfile"] }
]
match = project_path_compat searches, limit_path
if match
@project_type = match[:type]
@project_path = match[:path]
end
end
|
.hemfile_path ⇒ Object
83
84
85
86
|
# File 'lib/hem/paths.rb', line 83
def hemfile_path
return nil if !project_path
File.join(project_path, project_dsl_file)
end
|
.in_project? ⇒ Boolean
10
11
12
|
# File 'lib/hem/util.rb', line 10
def in_project?
!!Hem.project_path
end
|
.progress(file, increment, total, type, opts = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/hem/util.rb', line 14
def progress file, increment, total, type, opts = {}
require 'ruby-progressbar'
opts = {
:title => File.basename(file),
:total => total,
:format => "%t [%B] %p%% %e"
}.merge(opts)
opts[:length] = 79 if Gem::win_platform?
@progress_bar_cache ||= {}
if type == :reset
type = :update
@progress_bar_cache.delete file
end
@progress_bar_cache[file] ||= ProgressBar.create(opts)
case type
when :update
@progress_bar_cache[file].progress = [
@progress_bar_cache[file].progress + increment,
total
].min
when :finished
@progress_bar_cache[file].finish
end
return @progress_bar_cache[file]
end
|
.project_bin_path ⇒ Object
78
79
80
81
|
# File 'lib/hem/paths.rb', line 78
def project_bin_path
return nil if !project_path
File.join(project_path, 'bin')
end
|
.project_config_file ⇒ Object
88
89
90
91
|
# File 'lib/hem/paths.rb', line 88
def project_config_file
return nil if !project_path
File.join(project_path, 'tools', project_dsl_type.downcase, 'config.yaml')
end
|
.project_dsl_file ⇒ Object
43
44
45
|
# File 'lib/hem/paths.rb', line 43
def project_dsl_file
"#{project_dsl_type}file"
end
|
.project_dsl_type ⇒ Object
38
39
40
41
|
# File 'lib/hem/paths.rb', line 38
def project_dsl_type
detect_project_type if @project_type.nil?
@project_type
end
|
.project_path_compat(searches, limit_path = nil) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/hem/paths.rb', line 52
def project_path_compat searches, limit_path = nil
dir = Dir.pwd.split('/').reverse
min_length = Gem.win_platform? ? 1 : 0
Hem::Logging.logger.debug("paths.project: Searching backwards from #{Dir.pwd}")
while dir.length > min_length
test_dir = dir.reverse.join('/')
return nil unless limit_path.nil? || test_dir.start_with?(limit_path)
Hem::Logging.logger.debug("paths.project: Testing #{test_dir}")
searches.each do |search|
results = search[:indicators].map do |s|
File.exists?(File.join(test_dir, s))
end
match = results - [false]
return {type: search[:type], path: test_dir} if match.length > 0
end
dir.shift
end
return nil
end
|
.relaunch!(env = {}) ⇒ Object
6
7
8
|
# File 'lib/hem/util.rb', line 6
def relaunch! env = {}
Kernel.exec(env, 'hem', '--skip-host-checks', *$HEM_ARGV)
end
|
.require_version(*requirements) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/hem/version.rb', line 5
def require_version *requirements
req = Gem::Requirement.new(*requirements)
if req.satisfied_by?(Gem::Version.new(VERSION))
return
end
raise HemVersionError.new(requirements)
end
|
.seed_cache_path ⇒ Object
17
18
19
|
# File 'lib/hem/paths.rb', line 17
def seed_cache_path
File.join(config_path, 'seeds')
end
|
.system_ruby? ⇒ Boolean
60
61
62
63
|
# File 'lib/hem/util.rb', line 60
def system_ruby?
require 'rbconfig'
File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"]).match(/\/rvm\/|\/\.rvm\/|\/\.rbenv/) != nil
end
|
.user_config_file ⇒ Object
93
94
95
|
# File 'lib/hem/paths.rb', line 93
def user_config_file
File.join(config_path, 'config.yaml')
end
|
.user_hemfile_path ⇒ Object
97
98
99
|
# File 'lib/hem/paths.rb', line 97
def user_hemfile_path
File.join(config_path, project_dsl_file)
end
|
.vagrant_plugin(plugin, constraint = nil) ⇒ Object
65
66
67
68
|
# File 'lib/hem/util.rb', line 65
def vagrant_plugin plugin, constraint = nil
return [plugin, nil] if constraint.nil?
return [plugin, Gem::Dependency.new(plugin, constraint)]
end
|
.windows? ⇒ Boolean
55
56
57
58
|
# File 'lib/hem/util.rb', line 55
def windows?
require 'rbconfig'
!!(RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/)
end
|