mortar 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mortar/auth.rb CHANGED
@@ -98,6 +98,10 @@ class Mortar::Auth
98
98
  api.post_login(user, password).body["api_key"]
99
99
  end
100
100
 
101
+ def has_credentials
102
+ (nil != read_credentials)
103
+ end
104
+
101
105
  def get_credentials # :nodoc:
102
106
  @credentials ||= (read_credentials || ask_for_and_save_credentials)
103
107
  end
@@ -66,7 +66,9 @@ class Mortar::Command::Auth < Mortar::Command::Base
66
66
  def whoami
67
67
  validate_arguments!
68
68
 
69
- display Mortar::Auth.user
69
+ if Mortar::Auth.has_credentials
70
+ display Mortar::Auth.user
71
+ end
70
72
  end
71
73
 
72
74
  end
@@ -22,7 +22,7 @@ require "mortar/command/base"
22
22
  class Mortar::Command::Local < Mortar::Command::Base
23
23
 
24
24
 
25
- # configure
25
+ # local:configure
26
26
  #
27
27
  # Install dependencies for running this pig project locally, other
28
28
  # commands will also perform this step automatically.
@@ -54,9 +54,9 @@ class Mortar::Command::Local < Mortar::Command::Base
54
54
  ctrl.run(script, pig_parameters)
55
55
  end
56
56
 
57
- # illustrate [PIGSCRIPT] [ALIAS]
57
+ # local:illustrate [PIGSCRIPT] [ALIAS]
58
58
  #
59
- # Locallay illustrate the effects and output of a pigscript.
59
+ # Locally illustrate the effects and output of a pigscript.
60
60
  #
61
61
  # -s, --skippruning # Don't try to reduce the illustrate results to the smallest size possible.
62
62
  # -p, --parameter NAME=VALUE # Set a pig parameter value in your script.
@@ -84,4 +84,26 @@ class Mortar::Command::Local < Mortar::Command::Base
84
84
  end
85
85
 
86
86
 
87
+ # local:validate SCRIPT
88
+ #
89
+ # Run a job on your local machine
90
+ #
91
+ # -p, --parameter NAME=VALUE # Set a pig parameter value in your script.
92
+ # -f, --param-file PARAMFILE # Load pig parameter values from a file.
93
+ #
94
+ #Examples:
95
+ #
96
+ # Check the pig syntax of the generate_regression_model_coefficients script locally.
97
+ # $ mortar local:validate generate_regression_model_coefficients
98
+ def validate
99
+ script_name = shift_argument
100
+ unless script_name
101
+ error("Usage: mortar local:validate SCRIPT\nMust specify SCRIPT.")
102
+ end
103
+ validate_arguments!
104
+ script = validate_script!(script_name)
105
+ ctrl = Mortar::Local::Controller.new
106
+ ctrl.validate(script, pig_parameters)
107
+ end
108
+
87
109
  end
@@ -122,4 +122,10 @@ EOF
122
122
  pig.illustrate_alias(pig_script, pig_alias, skip_pruning, pig_parameters)
123
123
  end
124
124
 
125
+ def validate(pig_script, pig_parameters)
126
+ install_and_configure
127
+ pig = Mortar::Local::Pig.new()
128
+ pig.validate_script(pig_script, pig_parameters)
129
+ end
130
+
125
131
  end
@@ -123,6 +123,11 @@ class Mortar::Local::Pig
123
123
  note_install("pig")
124
124
  end
125
125
 
126
+ def validate_script(pig_script, pig_parameters)
127
+ run_pig_command(" -check #{pig_script.path}", pig_parameters)
128
+ end
129
+
130
+
126
131
  # run the pig script with user supplied pig parameters
127
132
  def run_script(pig_script, pig_parameters)
128
133
  run_pig_command(" -f #{pig_script.path}", pig_parameters, true)
@@ -284,11 +289,14 @@ class Mortar::Local::Pig
284
289
  opts = {}
285
290
  opts['fs.s3n.awsAccessKeyId'] = ENV['AWS_ACCESS_KEY']
286
291
  opts['fs.s3n.awsSecretAccessKey'] = ENV['AWS_SECRET_KEY']
292
+ opts['fs.s3.awsAccessKeyId'] = ENV['AWS_ACCESS_KEY']
293
+ opts['fs.s3.awsSecretAccessKey'] = ENV['AWS_SECRET_KEY']
287
294
  opts['pig.events.logformat'] = PIG_LOG_FORMAT
288
295
  opts['pig.logfile'] = local_pig_logfile
289
296
  opts['python.verbose'] = 'error'
290
297
  opts['jython.output'] = true
291
298
  opts['python.home'] = jython_directory
299
+ opts['python.path'] = local_install_directory + "/../controlscripts"
292
300
  opts['python.cachedir'] = jython_cache_directory
293
301
  return opts
294
302
  end
@@ -16,5 +16,5 @@
16
16
 
17
17
  module Mortar
18
18
  # see http://semver.org/
19
- VERSION = "0.7.3"
19
+ VERSION = "0.7.4"
20
20
  end
@@ -160,5 +160,15 @@ module Mortar
160
160
  @cli.user_s3_safe.should == 'myemail-dontspam-somedomain-com'
161
161
  end
162
162
 
163
+ it "is true if the user is currently logged in" do
164
+ # login (aka writing the auth file) is done in setup
165
+ expect(@cli.has_credentials).to be_true
166
+ end
167
+
168
+ it "is false if the user is not logged in" do
169
+ @cli.logout
170
+ expect(@cli.has_credentials).to be_false
171
+ end
172
+
163
173
  end
164
174
  end
@@ -35,12 +35,21 @@ STDOUT
35
35
 
36
36
  describe "auth:whoami" do
37
37
  it "displays the user's email address" do
38
- mock(Mortar::Auth).user {"sam@mortardata.com"}
38
+ mock(Mortar::Auth).has_credentials.returns(true)
39
+ mock(Mortar::Auth).get_credentials {["sam@mortardata.com", nil]}
39
40
  stderr, stdout = execute("auth:whoami")
40
41
  stderr.should == ""
41
42
  stdout.should == <<-STDOUT
42
43
  sam@mortardata.com
43
44
  STDOUT
44
45
  end
46
+
47
+ it "displays nothing if not logged in" do
48
+ mock(Mortar::Auth).has_credentials.returns(false)
49
+ stderr, stdout = execute("auth:whoami")
50
+ stderr.should == ""
51
+ stdout.should == ""
52
+ end
53
+
45
54
  end
46
55
  end
@@ -150,6 +150,28 @@ STDERR
150
150
  # configure
151
151
  end
152
152
 
153
+ context "local:validate" do
154
+
155
+ it "Runs pig with the -check command option" do
156
+ with_git_initialized_project do |p|
157
+ script_name = "some_script"
158
+ script_path = File.join(p.pigscripts_path, "#{script_name}.pig")
159
+ write_file(script_path)
160
+ pigscript = Mortar::Project::PigScript.new(script_name, script_path)
161
+ mock(Mortar::Project::PigScript).new(script_name, script_path).returns(pigscript)
162
+ any_instance_of(Mortar::Local::Controller) do |u|
163
+ mock(u).install_and_configure
164
+ end
165
+ any_instance_of(Mortar::Local::Pig) do |u|
166
+ mock(u).run_pig_command(" -check #{pigscript.path}", [])
167
+ end
168
+ stderr, stdout = execute("local:validate #{script_name}", p)
169
+ stderr.should == ""
170
+ end
171
+ end
172
+
173
+ end
174
+
153
175
  end
154
176
  end
155
177
 
metadata CHANGED
@@ -1,164 +1,122 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mortar
3
- version: !ruby/object:Gem::Version
4
- hash: 5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.4
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 3
10
- version: 0.7.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Mortar Data
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-03-29 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: mortar-api-ruby
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &71949150 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 1
29
- segments:
30
- - 0
31
- - 6
32
- - 3
20
+ - !ruby/object:Gem::Version
33
21
  version: 0.6.3
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: netrc
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *71949150
25
+ - !ruby/object:Gem::Dependency
26
+ name: netrc
27
+ requirement: &71948490 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
29
+ requirements:
42
30
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 5
45
- segments:
46
- - 0
47
- - 7
48
- version: "0.7"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
49
33
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: launchy
53
34
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *71948490
36
+ - !ruby/object:Gem::Dependency
37
+ name: launchy
38
+ requirement: &71983980 !ruby/object:Gem::Requirement
55
39
  none: false
56
- requirements:
40
+ requirements:
57
41
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 1
60
- segments:
61
- - 2
62
- - 1
63
- version: "2.1"
42
+ - !ruby/object:Gem::Version
43
+ version: '2.1'
64
44
  type: :runtime
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: excon
68
45
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *71983980
47
+ - !ruby/object:Gem::Dependency
48
+ name: excon
49
+ requirement: &71982970 !ruby/object:Gem::Requirement
70
50
  none: false
71
- requirements:
51
+ requirements:
72
52
  - - ~>
73
- - !ruby/object:Gem::Version
74
- hash: 21
75
- segments:
76
- - 0
77
- - 15
78
- version: "0.15"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.15'
79
55
  type: :development
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- name: fakefs
83
56
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *71982970
58
+ - !ruby/object:Gem::Dependency
59
+ name: fakefs
60
+ requirement: &71981360 !ruby/object:Gem::Requirement
85
61
  none: false
86
- requirements:
62
+ requirements:
87
63
  - - ~>
88
- - !ruby/object:Gem::Version
89
- hash: 11
90
- segments:
91
- - 0
92
- - 4
93
- - 2
64
+ - !ruby/object:Gem::Version
94
65
  version: 0.4.2
95
66
  type: :development
96
- version_requirements: *id005
97
- - !ruby/object:Gem::Dependency
98
- name: gem-release
99
67
  prerelease: false
100
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *71981360
69
+ - !ruby/object:Gem::Dependency
70
+ name: gem-release
71
+ requirement: &71980140 !ruby/object:Gem::Requirement
101
72
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
109
77
  type: :development
110
- version_requirements: *id006
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
78
  prerelease: false
114
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *71980140
80
+ - !ruby/object:Gem::Dependency
81
+ name: rake
82
+ requirement: &71978220 !ruby/object:Gem::Requirement
115
83
  none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
123
88
  type: :development
124
- version_requirements: *id007
125
- - !ruby/object:Gem::Dependency
126
- name: rr
127
89
  prerelease: false
128
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *71978220
91
+ - !ruby/object:Gem::Dependency
92
+ name: rr
93
+ requirement: &71977800 !ruby/object:Gem::Requirement
129
94
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
135
- - 0
136
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
137
99
  type: :development
138
- version_requirements: *id008
139
- - !ruby/object:Gem::Dependency
140
- name: rspec
141
100
  prerelease: false
142
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *71977800
102
+ - !ruby/object:Gem::Dependency
103
+ name: rspec
104
+ requirement: &71977380 !ruby/object:Gem::Requirement
143
105
  none: false
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- hash: 3
148
- segments:
149
- - 0
150
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
151
110
  type: :development
152
- version_requirements: *id009
111
+ prerelease: false
112
+ version_requirements: *71977380
153
113
  description: Client library and command-line tool to interact with the Mortar service.
154
114
  email: support@mortardata.com
155
- executables:
115
+ executables:
156
116
  - mortar
157
117
  extensions: []
158
-
159
118
  extra_rdoc_files: []
160
-
161
- files:
119
+ files:
162
120
  - README.md
163
121
  - bin/mortar
164
122
  - css/illustrate.css
@@ -249,38 +207,26 @@ files:
249
207
  - spec/support/display_message_matcher.rb
250
208
  homepage: http://mortardata.com/
251
209
  licenses: []
252
-
253
210
  post_install_message:
254
211
  rdoc_options: []
255
-
256
- require_paths:
212
+ require_paths:
257
213
  - lib
258
- required_ruby_version: !ruby/object:Gem::Requirement
214
+ required_ruby_version: !ruby/object:Gem::Requirement
259
215
  none: false
260
- requirements:
261
- - - ">="
262
- - !ruby/object:Gem::Version
263
- hash: 57
264
- segments:
265
- - 1
266
- - 8
267
- - 7
216
+ requirements:
217
+ - - ! '>='
218
+ - !ruby/object:Gem::Version
268
219
  version: 1.8.7
269
- required_rubygems_version: !ruby/object:Gem::Requirement
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
270
221
  none: false
271
- requirements:
272
- - - ">="
273
- - !ruby/object:Gem::Version
274
- hash: 3
275
- segments:
276
- - 0
277
- version: "0"
222
+ requirements:
223
+ - - ! '>='
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
278
226
  requirements: []
279
-
280
227
  rubyforge_project:
281
- rubygems_version: 1.8.24
228
+ rubygems_version: 1.8.11
282
229
  signing_key:
283
230
  specification_version: 3
284
231
  summary: Client library and CLI to interact with the Mortar service.
285
232
  test_files: []
286
-