lambchop 0.0.5 → 0.0.6

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: d80c6e0852ad9d7a44e2743493bf9e8e53b30019
4
- data.tar.gz: ce1a1e09d9368b679fa06cceae088ccd31735cac
3
+ metadata.gz: cb6e7edb6b8897dfc463c70e4e637d42cbcc1e6d
4
+ data.tar.gz: 6e4914af3aebb815e215adb75b30858d14eb7826
5
5
  SHA512:
6
- metadata.gz: eefc0526e495af489968d9056c12b4c833b443bc2abd61b1ac8d10644610d29d954ce135d5850fdd71aad3f7b939110dc500635a0182f3468d22249a4c9f66b0
7
- data.tar.gz: 0b72a2732f81fb0162ecb87b360fc4cffbedbbdf00398c8ab85a8ecd8bacb5a23e5da3675f0f250dcec6185deff0e3f4ea15bf5bd1dad5ae563aef835da92b32
6
+ metadata.gz: cb728da0839f37876e7abc7cb855842e6aac748b2b2d4dbd712f0d2ce73787c57bbde2821bc853e13ab5f708ad3e24c52e3c521216237c99c74ec5e27ce0d4c2
7
+ data.tar.gz: e3e22cfbcda1c72b42896d916f9acdd0e81b91e3e590c41a8277282b4c5b7968f087e6d8bcf83d3159d0ab818e31812d0187bb1fbad8d3c66bc90ff3cc4a1af1
data/README.md CHANGED
@@ -24,6 +24,10 @@ Or install it yourself as:
24
24
 
25
25
  **Terminal 1**:
26
26
  ```sh
27
+ $ export AWS_ACCESS_KEY_ID=...
28
+ $ export AWS_SECRET_ACCESS_KEY=...
29
+ $ export AWS_REGION=us-east-1
30
+
27
31
  $ cat test.js
28
32
  #!/usr/bin/env lambchop
29
33
  /*
@@ -53,6 +57,10 @@ $ ./test.js
53
57
 
54
58
  **Terminal 2**:
55
59
  ```sh
60
+ $ export AWS_ACCESS_KEY_ID=...
61
+ $ export AWS_SECRET_ACCESS_KEY=...
62
+ $ export AWS_REGION=us-east-1
63
+
56
64
  $ lambchop-cat
57
65
  usage: lambchop-cat <function-name>
58
66
 
@@ -62,6 +70,7 @@ $ echo '{"key1":100, "key2":200, "key3":300}' | lambchop-cat test
62
70
 
63
71
  **Terminal 1**:
64
72
  ```sh
73
+ (Wait event...)
65
74
  2014-11-23T08:06:53.212Z xxxxxxxxxxxxxxxx Loading event
66
75
  START RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
67
76
  2014-11-23T08:06:53.330Z xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx value1 = 100
data/bin/lambchop CHANGED
@@ -13,6 +13,28 @@ ARGV.options do |opt|
13
13
  opt.parse!
14
14
  end
15
15
 
16
- open(ARGV[0]) do |f|
17
- Lambchop::Client.start(f.read, f.path, options)
16
+ if ARGV.length < 1
17
+ puts <<-EOS
18
+ Please run the lambda script that has the following header:
19
+
20
+ #!/usr/bin/env lambchop
21
+ /*
22
+ function_name: any_name # default: file name without ext
23
+ runtime: nodejs # default: nodejs
24
+ mode: event # default: event
25
+ description: any_desc # default: (empty)
26
+ timeout: 3 # default: 3
27
+ memory_size: 128 # default: 128
28
+ handler: test.handler # Module name is filename, e.g. index.js -> index.handler
29
+ role: arn:aws:iam::NNNNNNNNNNNN:role/any_lambda_exec_role
30
+ */
31
+ EOS
32
+ exit 1
33
+
34
+ end
35
+
36
+ Lambchop::Utils.with_error_logging do
37
+ open(ARGV[0]) do |f|
38
+ Lambchop::Client.start(f.read, f.path, options)
39
+ end
18
40
  end
data/bin/lambchop-cat CHANGED
@@ -8,4 +8,6 @@ if ARGV.length != 1
8
8
  exit 1
9
9
  end
10
10
 
11
- Lambchop::Cat.cat(ARGV[0], $stdin)
11
+ Lambchop::Utils.with_error_logging do
12
+ Lambchop::Cat.cat(ARGV[0], $stdin)
13
+ end
data/bin/lambchop-diff CHANGED
@@ -8,6 +8,8 @@ if ARGV.length != 2
8
8
  exit 1
9
9
  end
10
10
 
11
- open(ARGV[1]) do |f|
12
- Lambchop::Diff.diff(ARGV[0], f)
11
+ Lambchop::Utils.with_error_logging do
12
+ open(ARGV[1]) do |f|
13
+ Lambchop::Diff.diff(ARGV[0], f)
14
+ end
13
15
  end
data/bin/lambchop-tail CHANGED
@@ -8,4 +8,7 @@ if ARGV.length != 1
8
8
  exit 1
9
9
  end
10
10
 
11
- Lambchop::Tail.tail(ARGV[0])
11
+
12
+ Lambchop::Utils.with_error_logging do
13
+ Lambchop::Tail.tail(ARGV[0])
14
+ end
data/lib/lambchop/diff.rb CHANGED
@@ -24,10 +24,13 @@ class Lambchop::Diff
24
24
  page = @client.get_function(:function_name => @function_name).first
25
25
 
26
26
  Lambchop::Utils.open_source(page.code.location) do |name, func|
27
- @out.puts("--- #{@function_name}:#{name}")
28
- @out.puts("+++ #{@file.path}")
29
27
  diff = Diffy::Diff.new(func, file, :include_diff_info => true).to_s
30
- @out.puts(diff.each_line.to_a.slice(2..-1).join)
28
+
29
+ unless diff.empty?
30
+ @out.puts("--- #{@function_name}:#{name}")
31
+ @out.puts("+++ #{@file.path}")
32
+ @out.puts(diff.each_line.to_a.slice(2..-1).join)
33
+ end
31
34
  end
32
35
  end
33
36
  end
data/lib/lambchop/dump.rb CHANGED
@@ -43,7 +43,10 @@ class Lambchop::Dump
43
43
 
44
44
  def puts_source(location)
45
45
  Lambchop::Utils.open_source(location) do |name, src|
46
- @out.puts("// #{name}")
46
+ unless src =~ %r|\A// #{Regexp.escape(name)}\n|
47
+ @out.puts("// #{name}")
48
+ end
49
+
47
50
  @out.puts(src)
48
51
  end
49
52
  end
@@ -30,5 +30,17 @@ class Lambchop::Utils
30
30
  end
31
31
  end
32
32
  end
33
+
34
+ def with_error_logging
35
+ begin
36
+ yield
37
+ rescue => e
38
+ if ENV['DEBUG'] == '1'
39
+ raise e
40
+ else
41
+ $stdout.puts("[ERROR] #{e.message}")
42
+ end
43
+ end
44
+ end
33
45
  end # of class methods
34
46
  end
@@ -1,3 +1,3 @@
1
1
  module Lambchop
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lambchop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-23 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core