jarbs 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00319947788f0b023a2448fa5ec31590d0daaa40
4
- data.tar.gz: 57727ea98e33ba9322fd2280387c4439f02a257b
3
+ metadata.gz: 7e0b7e12ac209ca690fa3878add1fa2dd87fcd4a
4
+ data.tar.gz: faef4d7bab85db92b5d63c07c2ebf5f7b65420ac
5
5
  SHA512:
6
- metadata.gz: ca6ef2149782919ad94d4542d339bdf41aee825e1fd475104c1da06753cc94c5e61d94e2e838ad06237bcfb7f3a680e29d2241a8f5736055bf8e630a71a8f201
7
- data.tar.gz: 56ef77f08d6487dbddaa317a6b85871d75ffee5ae72238cacb4ab0766db1939529316442fadc60e032f67a88f317fdeafba5cbba5d20b1a9bb78e53466a29d74
6
+ metadata.gz: 947badeb36fab1e41d7d415c4e08fbd0caf60b13dba5544f116fa7f1be70025cf0fb8bd3f66b18a16f97d1c7f66990eb768f2253bd83d62b1deaaaa4ba75ceaa
7
+ data.tar.gz: 9e19e63289b56712357b2bd86a45feabe35f4c26a29c0fbfe51808e69a5374b6a82fc64da11e30cec0f68282978df00ceda6347f54a71fd522da945e59707e13
@@ -19,9 +19,9 @@ module Jarbs
19
19
  def initialize
20
20
  @config = Config.new
21
21
 
22
- if @config.get('crashes.report')
22
+ if @config.get('crashes.report', from_global: true)
23
23
  CrashReporter.configure do |c|
24
- c.engines = [CrashReporter::GithubIssues.new('articulate/jarbs', @config.get('github.token'))]
24
+ c.engines = [CrashReporter::GithubIssues.new('articulate/jarbs', @config.get('github.token', from_global: true))]
25
25
  c.version = Jarbs::VERSION
26
26
  end
27
27
  end
@@ -33,10 +33,30 @@ module Jarbs
33
33
 
34
34
  global_option('-e', '--env [dev]', String, 'Set deployment environment')
35
35
  global_option('-d', '--debug', 'Enable debug mode') { $debug = true }
36
- global_option('-p', '--profile [default]', String, 'AWS credential profile to use') do |profile|
36
+ global_option('-p', '--profile PROFILE', String, 'AWS credential profile to use') do |profile|
37
37
  @config.set('aws.profile', profile)
38
38
  end
39
39
 
40
+ command :config do |c|
41
+ c.syntax = 'jarbs config [options]'
42
+ c.option '-g', '--global', String, "Use global config"
43
+ c.action do |args, options|
44
+ method = args.shift
45
+
46
+ if method == 'set'
47
+ args.each do |settings|
48
+ k, v = settings.split("=")
49
+
50
+ @config.set(k, v, from_global: options.global)
51
+ end
52
+ elsif method == 'get'
53
+ @config.get(args.first, from_global: options.global)
54
+ else
55
+ @config.print(for_global: options.global)
56
+ end
57
+ end
58
+ end
59
+
40
60
  command :init do |c|
41
61
  c.syntax = 'jarbs init'
42
62
  c.summary = 'Setup lambda project in an existing directory'
@@ -156,7 +176,7 @@ for compatability.
156
176
  private
157
177
 
158
178
  def profile
159
- @config.get('aws.profile') { 'default' }
179
+ @config.get('aws.profile') || 'default'
160
180
  end
161
181
 
162
182
  def global_defaults
@@ -178,7 +198,7 @@ for compatability.
178
198
  if remove
179
199
  lambda.function.remove!
180
200
  else
181
- abort("Function #{lambda.name} exists. Use the -f flag to force overwrite.")
201
+ abort("Function #{lambda.function.name} exists. Use the -f flag to force overwrite.")
182
202
  end
183
203
  end
184
204
  end
@@ -1,9 +1,17 @@
1
+ require 'pp'
2
+
1
3
  module Jarbs
2
4
  class Config
3
5
  FILE_NAME = '.jarbs'
6
+ GLOBAL_CONFIG = File.join(Dir.home, FILE_NAME)
7
+
8
+ def self.touch(for_global: false)
9
+ path = for_global ? GLOBAL_CONFIG : FILE_NAME
10
+ File.open(path, 'w') {|f| f.write JSON.pretty_generate({}) }
11
+ end
4
12
 
5
- def self.touch
6
- File.open(FILE_NAME, 'w') {|f| f.write JSON.pretty_generate({}) }
13
+ def self.global
14
+ new GLOBAL_CONFIG
7
15
  end
8
16
 
9
17
  def initialize(file=FILE_NAME)
@@ -11,12 +19,20 @@ module Jarbs
11
19
  @config = read
12
20
  end
13
21
 
14
- def set(key, value)
22
+ def global
23
+ @global ||= self.class.global
24
+ end
25
+
26
+ def set(key, value, from_global: false)
27
+ return global.set(key, value) if from_global
28
+
15
29
  @config[key] = value
16
30
  finalize
17
31
  end
18
32
 
19
- def get(key, &block)
33
+ def get(key, from_global: false, &block)
34
+ return global.get(key, &block) if from_global
35
+
20
36
  val = @config[key]
21
37
 
22
38
  if !val && block_given?
@@ -27,6 +43,12 @@ module Jarbs
27
43
  val
28
44
  end
29
45
 
46
+ def print(for_global: false)
47
+ return global.print if for_global
48
+
49
+ pp @config
50
+ end
51
+
30
52
  private
31
53
 
32
54
  def finalize
@@ -13,7 +13,7 @@ module Jarbs
13
13
 
14
14
  def generate_token(name)
15
15
  resp = @client.create_authorization scopes: ['public_repo'],
16
- note: "Jarbs error reporting for #{name}",
16
+ note: "Jarbs error reporting",
17
17
  headers: { 'X-GitHub-OTP' => ask('GitHub two-factor token: ') }
18
18
 
19
19
  @config.set('github.token', resp.token)
@@ -48,12 +48,12 @@ module Jarbs
48
48
 
49
49
  capture_errors do
50
50
  @client.create_function function_name: @function.env_name,
51
- runtime: 'nodejs',
52
- handler: 'index.handler',
53
- role: role,
54
- memory_size: 128,
55
- timeout: 10,
56
- code: { zip_file: @package }
51
+ runtime: 'nodejs',
52
+ handler: 'index.handler',
53
+ role: role,
54
+ memory_size: 128,
55
+ timeout: 10,
56
+ code: { zip_file: @package }
57
57
  end
58
58
 
59
59
  say_ok "Complete!"
@@ -63,7 +63,8 @@ module Jarbs
63
63
  say "Updating #{@function.env_name} on Lambda..."
64
64
 
65
65
  capture_errors do
66
- @client.update_function_code function_name: @function.env_name, zip_file: @package
66
+ @client.update_function_code function_name: @function.env_name,
67
+ zip_file: @package
67
68
  end
68
69
 
69
70
  say_ok "Complete!"
@@ -47,7 +47,7 @@ module Jarbs
47
47
  end
48
48
 
49
49
  def setup_crash_logging
50
- config = Config.new
50
+ config = Config.global
51
51
  autolog = config.get('crashes.report') do
52
52
  agree("Would you like to log jarbs crashes to GitHub automatically (y/n)? ")
53
53
  end
@@ -1,3 +1,3 @@
1
1
  module Jarbs
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jarbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke van der Hoeven
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-17 00:00:00.000000000 Z
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander