hem 1.0.1.beta2 → 1.0.1.beta3

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: a44495fc9c4a95ad2036264a9fbe126f0db119ca
4
- data.tar.gz: d52eb3e5b8abdeb52a5db03c3704c1d6e5f4804e
3
+ metadata.gz: e24a451f5acc1defa6a9387d956e907929a5f7ea
4
+ data.tar.gz: 5b1841273e1dd1ac7845c5aa56476f2341dcce7c
5
5
  SHA512:
6
- metadata.gz: b028dd6c290e07aa872660eecd4c8f5091f8e49829bbe8a52b947a03a7db66476cff4ab8bfc18c7ef0ad23b3383f30643280ea797523d0598a883b87618ecb33
7
- data.tar.gz: eed7903da8c98062cefe33c7a0b5fd21b6eadb37a6cf6e11bdf8d051df56922415d34cfde2c0a9a59c8a309769554bf848e20390b8c5d3e97ead0dbf15db4491
6
+ metadata.gz: a84691eb109695fb6bcd95dbd9a204109fc7ac1a23978c5124ebe03c2a8670f9cb798a8e589e952fd4b52c0c005df9967aea7fb051fbcb7a9f195caace93947e
7
+ data.tar.gz: c18bb3bafa2689768e5bad00541ef6c983f3a23c6d65d2323bc42dec4deaf04fea3bf6a51566451c3019520741160cde192b336d5e0344fc06ade253019a3e12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hem (1.0.1.beta2)
4
+ hem (1.0.1.beta3)
5
5
  aws-sdk (~> 2.0.24)
6
6
  deepstruct (~> 0.0.5)
7
7
  highline (~> 1.6.20)
@@ -6,34 +6,40 @@ module Hem
6
6
  @opts = {
7
7
  :replacer => Replacer.new,
8
8
  :config_class => Hem::Config::File,
9
- :project_config_file => Hem.project_config_file,
10
9
  :ssl_cert_generator => Hem::Lib::SelfSignedCertGenerator
11
10
  }.merge! opts
12
11
  end
13
12
 
14
13
  def setup seed, config
14
+ project_path = config[:project_path]
15
+
15
16
  seed.update
16
- seed.export config[:project_path], config
17
- config[:seed][:version] = seed.version
18
- config[:hostname] = "#{config[:name]}.dev"
19
- config[:asset_bucket] = "inviqa-assets-#{config[:name]}"
20
- config[:vm] = {
21
- :project_mount_path => "/vagrant"
22
- }
23
- config[:ssl] = @opts[:ssl_cert_generator].generate config[:hostname]
24
- config[:chef_ssl] = {}
25
- config[:ssl].each do |k, v|
26
- config[:chef_ssl][k] = v.gsub("\n", "\\n")
27
- end
17
+ seed.export project_path, config
28
18
 
29
- @opts[:replacer].replace(config[:project_path], config)
30
- load_seed_init(config)
19
+ Dir.chdir(project_path) do
20
+ Hem.detect_project_type project_path
21
+ @opts[:project_config_file] = Hem.project_config_file
31
22
 
32
- project_path = config[:project_path]
33
- config.delete :project_path
34
- config.delete :ssl
35
- config.delete :chef_ssl
36
- @opts[:config_class].save @opts[:project_config_file], config
23
+ config[:seed][:version] = seed.version
24
+ config[:hostname] = "#{config[:name]}.dev"
25
+ config[:asset_bucket] = "inviqa-assets-#{config[:name]}"
26
+ config[:vm] = {
27
+ :project_mount_path => "/vagrant"
28
+ }
29
+ config[:ssl] = @opts[:ssl_cert_generator].generate config[:hostname]
30
+ config[:chef_ssl] = {}
31
+ config[:ssl].each do |k, v|
32
+ config[:chef_ssl][k] = v.gsub("\n", "\\n")
33
+ end
34
+
35
+ @opts[:replacer].replace(config[:project_path], config)
36
+ load_seed_init(config)
37
+
38
+ config.delete :project_path
39
+ config.delete :ssl
40
+ config.delete :chef_ssl
41
+ @opts[:config_class].save @opts[:project_config_file], config
42
+ end
37
43
 
38
44
  initialize_git project_path, config[:git_url]
39
45
  end
data/lib/hem/paths.rb CHANGED
@@ -12,8 +12,9 @@ module Hem
12
12
  File.join(config_path, 'seeds')
13
13
  end
14
14
 
15
- def detect_project_type
16
- return unless @project_type.nil?
15
+ def detect_project_type limit_path = nil
16
+ @project_type = 'Hem'
17
+ @project_path = nil
17
18
 
18
19
  searches = [
19
20
  { type: "Hem", indicators: [ "Hemfile", "tools/hem"] },
@@ -21,21 +22,15 @@ module Hem
21
22
  { type: "Hem", indicators: ["tools/vagrant/Vagrantfile"] }
22
23
  ]
23
24
 
24
- searches.each do |search|
25
- next if @project_path
26
- path = project_path_compat search
27
- if path
28
- @project_type = search[:type]
29
- @project_path = path
30
- break
31
- end
25
+ match = project_path_compat searches, limit_path
26
+ if match
27
+ @project_type = match[:type]
28
+ @project_path = match[:path]
32
29
  end
33
-
34
- @project_type ||= 'Hem'
35
30
  end
36
31
 
37
32
  def project_dsl_type
38
- detect_project_type
33
+ detect_project_type if @project_type.nil?
39
34
  @project_type
40
35
  end
41
36
 
@@ -44,26 +39,30 @@ module Hem
44
39
  end
45
40
 
46
41
  def project_path
47
- detect_project_type
42
+ detect_project_type if @project_type.nil?
48
43
  @project_path
49
44
  end
50
45
 
51
- def project_path_compat search
46
+ def project_path_compat searches, limit_path = nil
52
47
  dir = Dir.pwd.split('/').reverse
53
48
  min_length = Gem.win_platform? ? 1 : 0
54
49
  Hem::Logging.logger.debug("paths.project: Searching backwards from #{Dir.pwd}")
55
50
 
56
51
  while dir.length > min_length
57
52
  test_dir = dir.reverse.join('/')
53
+ return nil unless limit_path.nil? || test_dir.start_with?(limit_path)
54
+
58
55
  Hem::Logging.logger.debug("paths.project: Testing #{test_dir}")
59
56
 
60
- results = search[:indicators].map do |s|
61
- File.exists?(File.join(test_dir, s))
62
- end
57
+ searches.each do |search|
58
+ results = search[:indicators].map do |s|
59
+ File.exists?(File.join(test_dir, s))
60
+ end
63
61
 
64
- match = results - [false]
62
+ match = results - [false]
65
63
 
66
- return test_dir if match.length > 0
64
+ return {type: search[:type], path: test_dir} if match.length > 0
65
+ end
67
66
 
68
67
  dir.shift
69
68
  end
@@ -5,10 +5,18 @@ namespace :deps do
5
5
  desc "Install Gem dependencies"
6
6
  task :gems do
7
7
  locate "*Gemfile" do
8
- required = shell("bundle", "check", :exit_status => true) != 0
8
+ required = shell("bundle check", :exit_status => true) != 0
9
9
  if required
10
10
  Hem.ui.title "Installing Gem dependencies"
11
- shell "bundle", "install", realtime: true, indent: 2
11
+
12
+ bundler_args = "#{Hem.user_config.bundler_args} #{Hem.project_config.bundler_args}".strip
13
+
14
+ command = [
15
+ 'bundle install',
16
+ bundler_args.empty? ? nil : bundler_args
17
+ ].compact.join(' ')
18
+
19
+ shell command, realtime: true, indent: 2
12
20
  Hem.ui.separator
13
21
  end
14
22
  end
@@ -50,24 +58,35 @@ namespace :deps do
50
58
 
51
59
  desc "Install vagrant plugins"
52
60
  task :vagrant_plugins => [ "deps:gems" ] do
61
+ require 'semantic'
53
62
  plugins = shell "vagrant plugin list", :capture => true
54
63
  locate "*Vagrantfile" do
55
- to_install = []
64
+ to_install = {}
56
65
  File.read("Vagrantfile").split("\n").each do |line|
57
- if line.match /#\s*Hem.vagrant_plugin (.*)/ or line.match /#\s*Hobo.vagrant_plugin (.*)/
58
- to_install << $1
66
+ if line.match(/#\s*(?:Hem|Hobo)\.(vagrant_plugin.*)/)
67
+ to_install.merge! Hash[[eval("Hem.#{$1}")]]
59
68
  else
60
69
  next if line.match /^\s*#/
61
70
  next unless line.match /Vagrant\.require_plugin (.*)/
62
- to_install << $1
71
+ to_install[$1.gsub(/['"]*/, '')] = nil
63
72
  end
64
73
  end
65
74
 
66
- to_install.each do |plugin|
67
- plugin.gsub!(/['"]*/, '')
68
- next if plugins.include? "#{plugin} "
69
- Hem.ui.title "Installing vagrant plugin: #{plugin}"
70
- shell "vagrant", "plugin", "install", plugin, :realtime => true, :indent => 2
75
+ plugins = Hash[
76
+ plugins.scan(/^([^\s]+)\s+\(([^,\)]+)(?:,[^\)]+)?\)$/).map do |plugin, version|
77
+ [plugin, Semantic::Version.new(version)]
78
+ end
79
+ ]
80
+
81
+ to_install.each do |plugin, constraint|
82
+ next if plugins.has_key?(plugin) && (constraint.nil? || plugins[plugin].satisfies(constraint))
83
+ Hem.ui.title "Installing vagrant plugin: #{plugin}#{constraint && " #{constraint}"}"
84
+ args = ["vagrant", "plugin", "install", plugin]
85
+ if constraint
86
+ args << '--plugin-version'
87
+ args << constraint
88
+ end
89
+ shell *args, :realtime => true, :indent => 2
71
90
  Hem.ui.separator
72
91
  end
73
92
  end
data/lib/hem/util.rb CHANGED
@@ -72,5 +72,9 @@ module Hem
72
72
  ENV['PATH'] = (chef_paths + paths).join ':'
73
73
  end
74
74
  end
75
+
76
+ def vagrant_plugin plugin, constraint = nil
77
+ return [plugin, constraint]
78
+ end
75
79
  end
76
80
  end
data/lib/hem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hem
2
- VERSION = '1.0.1-beta2'
2
+ VERSION = '1.0.1-beta3'
3
3
  end
@@ -72,7 +72,6 @@ describe Hem::Helper do
72
72
  it "should enable auto echo of piped commands" do
73
73
  c = create_mysql_command(:pwd => '/')
74
74
  c << "SELECT 1"
75
- puts c.to_s
76
75
  c.to_s.should match /echo\\ SELECT\\\\\\\\\\ 1\\ \\\|/
77
76
  end
78
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1.beta2
4
+ version: 1.0.1.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Simons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-03 00:00:00.000000000 Z
11
+ date: 2015-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop