mortar 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/mortar CHANGED
@@ -8,6 +8,10 @@ bin_file = Pathname.new(__FILE__).realpath
8
8
  # add self to libpath
9
9
  $:.unshift File.expand_path("../../lib", bin_file)
10
10
 
11
+ #Check for updates
12
+ require "mortar/updater"
13
+ Mortar::Updater.update_check
14
+
11
15
  # start up the CLI
12
16
  require "mortar/cli"
13
17
  Mortar::CLI.start(*ARGV)
@@ -352,7 +352,7 @@ module Mortar
352
352
  display
353
353
  end
354
354
 
355
- def styled_error(error, message='Mortar client internal error.')
355
+ def styled_error(error, message='Mortar Development Framework internal error.')
356
356
  if Mortar::Helpers.error_with_failure
357
357
  display("failed")
358
358
  Mortar::Helpers.error_with_failure = false
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * Required parameters:
5
5
  *
6
- * -param INPUT_PATH Input path for script data (e.g. s3n://hawk-example-data/tutorial/excite.log.bz2)
7
- * -param OUTPUT_PATH Output path for script data (e.g. s3n://my-output-bucket/<%= script_name %>)
6
+ * - INPUT_PATH Input path for script data (e.g. s3n://hawk-example-data/tutorial/excite.log.bz2)
7
+ * - OUTPUT_PATH Output path for script data (e.g. s3n://my-output-bucket/<%= script_name %>)
8
8
  */
9
9
 
10
10
  <% if not options[:skip_udf] %>
@@ -35,4 +35,4 @@ rmf $OUTPUT_PATH;
35
35
  -- store the results
36
36
  STORE with_udf_output
37
37
  INTO '$OUTPUT_PATH'
38
- USING PigStorage('\t');
38
+ USING PigStorage('\t');
@@ -1,6 +1,6 @@
1
1
  # Welcome to Mortar!
2
2
 
3
- Mortar is a platform-as-a-service for Hadoop. With Mortar, you can run jobs on Hadoop using Apache Pig and Python without any special training. You create your project using the Mortar command-line tool, deploy code using the Git revision control system, and Mortar does the rest.
3
+ Mortar is a platform-as-a-service for Hadoop. With Mortar, you can run jobs on Hadoop using Apache Pig and Python without any special training. You create your project using the Mortar Development Framework, deploy code using the Git revision control system, and Mortar does the rest.
4
4
 
5
5
  # Getting Started
6
6
 
@@ -0,0 +1,52 @@
1
+ #
2
+ # Copyright 2012 Mortar Data Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ # Portions of this code from heroku (https://github.com/heroku/heroku/) Copyright Heroku 2008 - 2012,
17
+ # used under an MIT license (https://github.com/heroku/heroku/blob/master/LICENSE).
18
+ #
19
+
20
+ require 'mortar/helpers'
21
+ require 'mortar/version'
22
+
23
+ module Mortar
24
+ module Updater
25
+ CONNECT_TIMEOUT = 5
26
+ READ_TIMEOUT = 5
27
+
28
+ def self.get_newest_version
29
+ begin
30
+ require "excon"
31
+ gem_data = Mortar::Helpers.json_decode(Excon.get('http://rubygems.org/api/v1/gems/mortar.json', {:connect_timeout => CONNECT_TIMEOUT, :read_timeout => READ_TIMEOUT}).body)
32
+ gem_data.default = "0.0.0"
33
+ gem_data['version']
34
+ rescue Exception => e
35
+ '0.0.0'
36
+ end
37
+ end
38
+
39
+ def self.compare_versions(first_version, second_version)
40
+ first_version.split('.').map {|part| Integer(part) rescue part} <=> second_version.split('.').map {|part| Integer(part) rescue part}
41
+ end
42
+
43
+ def self.update_check
44
+ local_version = Mortar::VERSION
45
+ newest_version = self.get_newest_version
46
+
47
+ if compare_versions(newest_version, local_version) > 0
48
+ Mortar::Helpers.warning("There is a new version of the Mortar development framework available. Please run 'gem install mortar' to install the latest version.\n\n")
49
+ end
50
+ end
51
+ end
52
+ end
@@ -16,5 +16,5 @@
16
16
 
17
17
  module Mortar
18
18
  # see http://semver.org/
19
- VERSION = "0.3.4"
19
+ VERSION = "0.4.0"
20
20
  end
@@ -0,0 +1,95 @@
1
+ #
2
+ # Copyright 2012 Mortar Data Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ # Portions of this code from heroku (https://github.com/heroku/heroku/) Copyright Heroku 2008 - 2012,
17
+ # used under an MIT license (https://github.com/heroku/heroku/blob/master/LICENSE).
18
+ #
19
+
20
+ require "spec_helper"
21
+ require "mortar/updater"
22
+ require "excon"
23
+
24
+ module Mortar
25
+ describe Updater do
26
+ include Mortar::Updater
27
+
28
+ context "compare versions" do
29
+ it "same versions" do
30
+ Updater.compare_versions('1.0.0','1.0.0').should == 0
31
+ end
32
+
33
+ it "higher version" do
34
+ Updater.compare_versions('1.0.0','0.0.0').should > 0
35
+ Updater.compare_versions('0.1.0','0.0.0').should > 0
36
+ Updater.compare_versions('0.0.1','0.0.0').should > 0
37
+ end
38
+
39
+ it "lower version" do
40
+ Updater.compare_versions('1.0.0','2.0.0').should < 0
41
+ Updater.compare_versions('0.1.0','0.2.0').should < 0
42
+ Updater.compare_versions('0.0.1','0.0.2').should < 0
43
+ end
44
+ end
45
+
46
+ context "get ruby version" do
47
+ it "makes gem call" do
48
+ Excon.stub({:method => :get, :path => "/api/v1/gems/mortar.json", :connect_timeout => Mortar::Updater::CONNECT_TIMEOUT, :read_timeout => Mortar::Updater::READ_TIMEOUT}) do
49
+ {:body => Mortar::API::OkJson.encode({"version" => "1.0.0"}), :status => 200}
50
+ end
51
+ Updater.get_newest_version.should == "1.0.0"
52
+ end
53
+
54
+ it "has no version field" do
55
+ Excon.stub({:method => :get, :path => "/api/v1/gems/mortar.json", :connect_timeout => Mortar::Updater::CONNECT_TIMEOUT, :read_timeout => Mortar::Updater::READ_TIMEOUT}) do
56
+ {:body => Mortar::API::OkJson.encode({"no_version" => "none"}), :status => 200}
57
+ end
58
+ Updater.get_newest_version.should == "0.0.0"
59
+ end
60
+
61
+ it "has an exception" do
62
+ Excon.stub({:method => :get, :path => "/api/v1/gems/mortar.json", :connect_timeout => Mortar::Updater::CONNECT_TIMEOUT, :read_timeout => Mortar::Updater::READ_TIMEOUT}) do
63
+ raise Exception
64
+ end
65
+ Updater.get_newest_version.should == "0.0.0"
66
+ end
67
+ end
68
+
69
+ context "update check" do
70
+ it "displays no message when we have a current version" do
71
+ Excon.stub({:method => :get, :path => "/api/v1/gems/mortar.json", :connect_timeout => Mortar::Updater::CONNECT_TIMEOUT, :read_timeout => Mortar::Updater::READ_TIMEOUT}) do
72
+ {:body => Mortar::API::OkJson.encode({"version" => "1.0.0"}), :status => 200}
73
+ end
74
+ capture_stderr do
75
+ Mortar::VERSION = "1.0.0"
76
+ end
77
+ capture_stdout do
78
+ Updater.update_check
79
+ end.should == ""
80
+ end
81
+
82
+ it "displays message when we have an outdated version" do
83
+ Excon.stub({:method => :get, :path => "/api/v1/gems/mortar.json", :connect_timeout => Mortar::Updater::CONNECT_TIMEOUT, :read_timeout => Mortar::Updater::READ_TIMEOUT}) do
84
+ {:body => Mortar::API::OkJson.encode({"version" => "2.0.0"}), :status => 200}
85
+ end
86
+ capture_stderr do
87
+ Mortar::VERSION = "1.0.0"
88
+ end
89
+ capture_stdout do
90
+ Updater.update_check
91
+ end.should == "WARNING: There is a new version of the Mortar development framework available. Please run 'gem install mortar' to install the latest version.\n\n"
92
+ end
93
+ end
94
+ end
95
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
12
+ date: 2012-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mortar-api-ruby
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.3.1
21
+ version: 0.4.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 0.3.1
29
+ version: 0.4.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: netrc
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -217,6 +217,7 @@ files:
217
217
  - lib/mortar/templates/project/pigscripts/pigscript.pig
218
218
  - lib/mortar/templates/project/udfs/python/python_udf.py
219
219
  - lib/mortar/templates/udf/python_udf.py
220
+ - lib/mortar/updater.rb
220
221
  - lib/mortar/version.rb
221
222
  - lib/vendor/mortar/okjson.rb
222
223
  - lib/vendor/mortar/uuid.rb
@@ -237,6 +238,7 @@ files:
237
238
  - spec/mortar/helpers_spec.rb
238
239
  - spec/mortar/project_spec.rb
239
240
  - spec/mortar/snapshot_spec.rb
241
+ - spec/mortar/updater_spec.rb
240
242
  - spec/spec.opts
241
243
  - spec/spec_helper.rb
242
244
  - spec/support/display_message_matcher.rb