mortar 0.10.1 → 0.11.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: 38d5a25dbe99155f562977e533fa2e8b948069aa
4
- data.tar.gz: e63af25a7d701b20db21f85e6bd121d8193813ee
3
+ metadata.gz: 890d6f0f6d9f9171abb6ebafd62d23c70912eca5
4
+ data.tar.gz: 89ff5f77688e7e4b49d1c5215f3e7186c0f22759
5
5
  SHA512:
6
- metadata.gz: 85e6825c6f0e3198dca99337a2f0bdc656d3c806f3f1061fbdad81cd1edd1b60f399ef21188b513b8153655bafcfdbcffb8742bb1850037005492f939c4a525d
7
- data.tar.gz: 129f36eba0923f01ab3058b83d96f1b6e01e260bf83656f7124a1cc80514c5e27929ecce81c83b0634fac7ef0944dc1b66a23a4c74a615c4002f501da3e026db
6
+ metadata.gz: 924bc9cafb357195565616fbf77bc91b8aa3b58b9271ff09d7365ad44f2c8e8ebef718180c2d6df77bf7280ea3c1834159d555f52effa5d419a06cff136946a2
7
+ data.tar.gz: 63812c555e2a84345d3d1b82779dcaac9a4c4d67a18004cfb38e43c17a8263944f1c8bc8a4b04567d2248b313a4dc35fa65147b1b3c1117e5dfda8fe5b93faf7
@@ -31,11 +31,13 @@ module Mortar::Command
31
31
  end
32
32
  end
33
33
 
34
- # plugins:install git@github.com:user/repo.git
34
+ # plugins:install GIT_URL
35
35
  #
36
36
  # install a plugin
37
37
  #
38
- #Example:
38
+ # -b, --branchname BRANCHNAME # Install plugin from a specific branch.
39
+ #
40
+ # Examples:
39
41
  #
40
42
  # $ mortar plugins:install https://github.com/mortardata/watchtower.git
41
43
  # Installing watchtower... done
@@ -47,7 +49,11 @@ module Mortar::Command
47
49
  action("Installing #{plugin.name}") do
48
50
  begin
49
51
  record_usage("plugin_install", plugin.name)
50
- plugin.install
52
+ if options[:branchname]
53
+ plugin.install(options[:branchname])
54
+ else
55
+ plugin.install
56
+ end
51
57
  Mortar::Plugin.load_plugin(plugin.name)
52
58
  rescue StandardError => e
53
59
  error e.message
@@ -23,8 +23,17 @@ class Mortar::Local::Pig
23
23
  include Mortar::Local::InstallUtil
24
24
 
25
25
  PIG_LOG_FORMAT = "humanreadable"
26
- PIG_TGZ_NAME = "pig.tgz"
27
- PIG_TGZ_DEFAULT_URL_PATH = "resource/pig"
26
+ PIG_TGZ_NAME = "pig-0.9.tar.gz"
27
+ PIG_TGZ_DEFAULT_URL_PATH = "resource/pig_0_9"
28
+ LIB_TGZ_NAME = "lib-common.tar.gz"
29
+ PIG_COMMON_LIB_URL_PATH = "resource/lib_common"
30
+
31
+
32
+ #This needs to be defined for watchtower.
33
+ DEFAULT_PIGOPTS_FILES = %w(
34
+ /lib-common/conf/pig-hawk-global.properties
35
+ /lib-common/conf/pig-cli-local-dev.properties
36
+ )
28
37
 
29
38
  # Tempfile objects have a hook to delete the file when the object is
30
39
  # destroyed by the garbage collector. In practice this means that a
@@ -74,7 +83,11 @@ class Mortar::Local::Pig
74
83
  end
75
84
 
76
85
  def pig_directory
77
- return File.join(local_install_directory, "pig")
86
+ return File.join(local_install_directory, "pig-0.9")
87
+ end
88
+
89
+ def lib_directory
90
+ return File.join(local_install_directory, "lib-common")
78
91
  end
79
92
 
80
93
  def pig_archive_url
@@ -83,31 +96,55 @@ class Mortar::Local::Pig
83
96
  ENV.fetch('PIG_DISTRO_URL', default_url)
84
97
  end
85
98
 
99
+ def lib_archive_url
100
+ full_host = (host =~ /^http/) ? host : "https://api.#{host}"
101
+ default_url = full_host + "/" + PIG_COMMON_LIB_URL_PATH
102
+ ENV.fetch('COMMON_LIB_DISTRO_URL', default_url)
103
+ end
104
+
86
105
  # Determines if a pig install needs to occur, true if no pig install present
87
106
  def should_do_pig_install?
88
107
  not (File.exists?(pig_directory))
89
108
  end
90
109
 
110
+ def should_do_lib_install?
111
+ not (File.exists?(lib_directory))
112
+ end
113
+
91
114
  # Determines if a pig install needs to occur, true if server side
92
115
  # pig tgz is newer than date of the existing install
93
116
  def should_do_pig_update?
94
- return is_newer_version('pig', pig_archive_url)
117
+ return is_newer_version('pig-0.9', pig_archive_url)
118
+ end
119
+
120
+ def should_do_lib_update?
121
+ return is_newer_version('lib-common', lib_archive_url)
95
122
  end
96
123
 
97
124
  def install_or_update()
98
125
  if should_do_pig_install?
99
126
  action "Installing pig to #{local_install_directory_name}" do
100
- install()
127
+ install_pig()
101
128
  end
102
129
  elsif should_do_pig_update?
103
130
  action "Updating to latest pig in #{local_install_directory_name}" do
104
- install()
131
+ install_pig()
132
+ end
133
+ end
134
+
135
+ if should_do_lib_install?
136
+ action "Installing pig dependencies to #{local_install_directory_name}" do
137
+ install_lib()
138
+ end
139
+ elsif should_do_lib_update?
140
+ action "Updating to latest pig dependencies in #{local_install_directory_name}" do
141
+ install_lib()
105
142
  end
106
143
  end
107
144
  end
108
145
 
109
146
  # Installs pig for this project if it is not already present
110
- def install
147
+ def install_pig
111
148
  FileUtils.mkdir_p(local_install_directory)
112
149
  local_tgz = File.join(local_install_directory, PIG_TGZ_NAME)
113
150
  download_file(pig_archive_url, local_tgz)
@@ -118,7 +155,17 @@ class Mortar::Local::Pig
118
155
  FileUtils.chmod(0755, command)
119
156
 
120
157
  File.delete(local_tgz)
121
- note_install("pig")
158
+ note_install("pig-0.9")
159
+ end
160
+
161
+ def install_lib
162
+ FileUtils.mkdir_p(local_install_directory)
163
+ local_tgz = File.join(local_install_directory, LIB_TGZ_NAME)
164
+ download_file(lib_archive_url, local_tgz)
165
+ extract_tgz(local_tgz, local_install_directory)
166
+
167
+ File.delete(local_tgz)
168
+ note_install("lib-common")
122
169
  end
123
170
 
124
171
  def validate_script(pig_script, pig_parameters)
@@ -275,13 +322,22 @@ class Mortar::Local::Pig
275
322
  File.expand_path("../../templates/script/runpig.sh", __FILE__)
276
323
  end
277
324
 
325
+ def template_params_classpath
326
+ "#{pig_directory}/*:#{pig_directory}/lib-local/*:#{pig_directory}/lib-pig/*:#{pig_directory}/lib-cluster/*:#{lib_directory}/lib-pig/*:#{lib_directory}/lib-cluster/*:#{jython_directory}/jython.jar:#{lib_directory}/conf/jets3t.properties"
327
+ end
328
+
329
+ def log4j_conf
330
+ "#{lib_directory}/conf/log4j-cli-local-dev.properties"
331
+ end
332
+
278
333
  # Parameters necessary for rendering the bash script template
279
334
  def pig_command_script_template_parameters(cmd, pig_parameters)
280
335
  template_params = {}
281
336
  template_params['pig_params_file'] = make_pig_param_file(pig_parameters)
282
337
  template_params['pig_home'] = pig_directory
283
- template_params['pig_classpath'] = "#{pig_directory}/lib-pig/*:#{jython_directory}/jython.jar"
284
- template_params['classpath'] = "#{pig_directory}/lib/*:#{jython_directory}/jython.jar:#{pig_directory}/conf/jets3t.properties"
338
+ template_params['pig_classpath'] = "#{pig_directory}/lib-local/*:#{pig_directory}/lib-pig/*:#{pig_directory}/lib-cluster/*:#{lib_directory}/lib-pig/*:#{lib_directory}/lib-cluster/*:#{jython_directory}/jython.jar"
339
+ template_params['classpath'] = template_params_classpath
340
+ template_params['log4j_conf'] = log4j_conf
285
341
  template_params['project_home'] = File.expand_path("..", local_install_directory)
286
342
  template_params['local_install_dir'] = local_install_directory
287
343
  template_params['pig_sub_command'] = cmd
data/lib/mortar/plugin.rb CHANGED
@@ -151,20 +151,35 @@ ERROR
151
151
  "#{self.class.directory}/#{name}"
152
152
  end
153
153
 
154
- def install
154
+ def install(branch = nil)
155
155
  if File.directory?(path)
156
156
  uninstall
157
157
  end
158
158
  FileUtils.mkdir_p(self.class.directory)
159
159
  Dir.chdir(self.class.directory) do
160
- git.git("clone #{uri}", check_success=true, check_git_directory=false)
161
- unless $?.success?
160
+ begin
161
+ git.git("clone #{uri}", check_success=true, check_git_directory=false)
162
+ rescue Mortar::Git::GitError
162
163
  FileUtils.rm_rf path
163
164
  raise Mortar::Plugin::ErrorInstallingPlugin, <<-ERROR
164
165
  Unable to install plugin #{name}.
165
166
  Please check the URL and try again.
166
167
  ERROR
167
168
  end
169
+
170
+ if !!branch
171
+ Dir.chdir(name) do
172
+ begin
173
+ git.git("checkout #{branch}", check_success=true, check_git_directory=true)
174
+ rescue Mortar::Git::GitError
175
+ FileUtils.rm_rf path
176
+ raise Mortar::Plugin::ErrorInstallingPlugin, <<-ERROR
177
+ Unable to checkout branch #{branch} for plugin #{name}.
178
+ Please check the URL and branch and try again.
179
+ ERROR
180
+ end
181
+ end
182
+ end
168
183
  end
169
184
  install_dependencies
170
185
  return true
@@ -15,9 +15,9 @@ cd <%= @project_home %>/pigscripts
15
15
  source <%= @local_install_dir %>/pythonenv/bin/activate
16
16
 
17
17
  # Run Pig
18
- <%= @local_install_dir %>/pig/bin/pig -exectype local \
19
- -log4jconf <%= @local_install_dir %>/pig/conf/log4j-cli-local-dev.properties \
20
- -propertyFile <%= @local_install_dir %>/pig/conf/pig-hawk-global.properties \
21
- -propertyFile <%= @local_install_dir %>/pig/conf/pig-cli-local-dev.properties \
18
+ <%= @local_install_dir %>/pig-0.9/bin/pig -exectype local \
19
+ -log4jconf <%= @log4j_conf %> \
20
+ -propertyFile <%= @local_install_dir %>/lib-common/conf/pig-hawk-global.properties \
21
+ -propertyFile <%= @local_install_dir %>/lib-common/conf/pig-cli-local-dev.properties \
22
22
  -param_file <%= @pig_params_file %> \
23
23
  <%= @pig_sub_command %>
@@ -16,5 +16,5 @@
16
16
 
17
17
  module Mortar
18
18
  # see http://semver.org/
19
- VERSION = "0.10.1"
19
+ VERSION = "0.11.0"
20
20
  end
@@ -152,7 +152,8 @@ PARAMS
152
152
  stub(j).check_install.returns(true)
153
153
  end
154
154
  any_instance_of(Mortar::Local::Pig) do |j|
155
- stub(j).install.returns(true)
155
+ stub(j).install_pig.returns(true)
156
+ stub(j).install_lib.returns(true)
156
157
  end
157
158
  any_instance_of(Mortar::Local::Python) do |j|
158
159
  stub(j).check_or_install.returns(false)
@@ -166,7 +167,8 @@ PARAMS
166
167
  mock(j).check_install.returns(true)
167
168
  end
168
169
  any_instance_of(Mortar::Local::Pig) do |j|
169
- mock(j).install.returns(true)
170
+ mock(j).install_pig.returns(true)
171
+ stub(j).install_lib.returns(true)
170
172
  end
171
173
  any_instance_of(Mortar::Local::Python) do |j|
172
174
  mock(j).check_or_install.returns(true)
@@ -41,10 +41,10 @@ module Mortar::Local
41
41
  FileUtils.touch(local_pig_archive)
42
42
  end
43
43
  mock(pig).extract_tgz(local_pig_archive, pig.local_install_directory)
44
- mock(pig).note_install("pig")
44
+ mock(pig).note_install("pig-0.9")
45
45
  begin
46
46
  previous_stdout, $stdout = $stdout, StringIO.new
47
- pig.install
47
+ pig.install_pig
48
48
  ensure
49
49
  $stdout = previous_stdout
50
50
  end
@@ -60,18 +60,25 @@ module Mortar::Local
60
60
  pig = Mortar::Local::Pig.new
61
61
  mock(pig).should_do_pig_install?.returns(false)
62
62
  mock(pig).should_do_pig_update?.returns(false)
63
+ mock(pig).should_do_lib_install?.returns(false)
64
+ mock(pig).should_do_lib_update?.returns(false)
63
65
  FakeFS do
64
66
  FileUtils.mkdir_p(File.dirname(pig.local_install_directory))
65
67
  FileUtils.rm_rf(pig.local_install_directory, :force => true)
66
68
  pig.install_or_update
67
- expect(File.exists?(pig.local_install_directory)).to be_false
69
+ expect(File.exists?(pig.pig_directory)).to be_false
70
+ expect(File.exists?(pig.lib_directory)).to be_false
71
+
68
72
  end
69
73
  end
70
74
 
71
75
  it "does install if none has been done before" do
72
76
  pig = Mortar::Local::Pig.new
73
77
  mock(pig).should_do_pig_install?.returns(true)
74
- mock(pig).install
78
+ mock(pig).should_do_lib_install?.returns(true)
79
+
80
+ mock(pig).install_pig
81
+ mock(pig).install_lib
75
82
  capture_stdout do
76
83
  pig.install_or_update
77
84
  end
@@ -81,7 +88,10 @@ module Mortar::Local
81
88
  pig = Mortar::Local::Pig.new
82
89
  mock(pig).should_do_pig_install?.returns(false)
83
90
  mock(pig).should_do_pig_update?.returns(true)
84
- mock(pig).install
91
+ mock(pig).should_do_lib_install?.returns(false)
92
+ mock(pig).should_do_lib_update?.returns(true)
93
+ mock(pig).install_pig
94
+ mock(pig).install_lib
85
95
  capture_stdout do
86
96
  pig.install_or_update
87
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mortar Data
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2013-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc