bake 0.18.1 → 0.18.2

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
  SHA256:
3
- metadata.gz: 45dc14db128a03b0d45937817bbbf8b2d74d1762c5eb09706334113b1bcf2102
4
- data.tar.gz: 6ecb1fe731b1440fc73a831d182b00d134d5b8572ac8d37a2f4b7ec188b5af46
3
+ metadata.gz: a3bcf5cd8672eaa2a698d0df26ac16b853d574ff386f2134e2540b6a601cfaa1
4
+ data.tar.gz: d06efeba9bd097c2f5bad7adf529a970a8fe9e010540a6b1d8449d1d3897b005
5
5
  SHA512:
6
- metadata.gz: 75621544ab473d069454794226b840adfb5e670eb3c7ccecd0cc197122b9a3d06e6541d16ab4819ee4037c284eac91da8defd2a45ef747ccfac2e285368f5681
7
- data.tar.gz: '068df1863a48a29cacc02d5ad64b98b8f5af0d6c03b82334699894932fa8aee26e258e8bcf27aab3929680b6c46aa01ba24a5512fe161d226eede9d87c73350f'
6
+ metadata.gz: 8fa7311b0fd77dc5388801f2aeca08395ad9499df10008b087b1bbc172ec131cf57827aceb19dff1d1365d4cbce58975f9cb9addbed830971546297e35411e41
7
+ data.tar.gz: 7ca9417bfb9d2659113c517e4f8ef530bd4fd7d54617e6ea1931694ab2b036dba4d18f092d3403a6cd76ea930b67cc0dc2112c8058cc947bcd67a7f240d27356
checksums.yaml.gz.sig CHANGED
Binary file
data/bake/input.rb CHANGED
@@ -4,11 +4,15 @@ FORMATS = {
4
4
  yaml: ->(file){require 'yaml'; YAML.load(file.read)},
5
5
  }
6
6
 
7
- # Parse an input file (defaulting to stdin) in the specified format (defaulting to JSON).
7
+ # Parse an input file (defaulting to stdin) in the specified format. The format can be extracted from the file extension if left unspecified.
8
8
  # @parameter file [Input] The input file.
9
9
  # @parameter format [Symbol] The input format, e.g. json, yaml.
10
- def input(file: $stdin, format: :json)
11
- format_for(format).call(file)
10
+ def input(file: $stdin, format: nil)
11
+ if format = format_for(file, format)
12
+ format.call(file)
13
+ else
14
+ raise "Unable to determine input format of #{file}!"
15
+ end
12
16
  end
13
17
 
14
18
  # Parse some input text in the specified format (defaulting to JSON).
@@ -16,11 +20,28 @@ end
16
20
  # @parameter format [Symbol] The input format, e.g. json, yaml.
17
21
  def parse(text, format: :json)
18
22
  file = StringIO.new(text)
19
- format_for(format).call(file)
23
+
24
+ if format = format_for(nil, format)
25
+ format.call(file)
26
+ else
27
+ raise "Unable to determine input format!"
28
+ end
20
29
  end
21
30
 
22
31
  private
23
32
 
24
- def format_for(name)
33
+ def format_for(file, name)
34
+ if file.respond_to?(:path) and path = file.path
35
+ name ||= file_type(path)
36
+ end
37
+
25
38
  FORMATS[name]
26
39
  end
40
+
41
+ def file_type(path)
42
+ if extension = File.extname(path)
43
+ extension.sub!(/\A\./, '')
44
+ return if extension.empty?
45
+ return extension.to_sym
46
+ end
47
+ end
data/bake/output.rb CHANGED
@@ -7,11 +7,14 @@ FORMATS = {
7
7
  }
8
8
 
9
9
  # Dump the last result to the specified file (defaulting to stdout) in the specified format (defaulting to Ruby's pretty print).
10
- # @parameter input [Array(Integer)]
11
10
  # @parameter file [Output] The input file.
12
11
  # @parameter format [Symbol] The output format.
13
- def output(input:, file: $stdout, format: :pp)
14
- format_for(format).call(file, input)
12
+ def output(input:, file: $stdout, format: nil)
13
+ if format = format_for(file, format)
14
+ format.call(file, input)
15
+ else
16
+ raise "Unable to determine output format!"
17
+ end
15
18
 
16
19
  # Allow chaining of output processing:
17
20
  return input
@@ -19,6 +22,21 @@ end
19
22
 
20
23
  private
21
24
 
22
- def format_for(name)
25
+ def format_for(file, name)
26
+ if file.respond_to?(:path) and path = file.path
27
+ name ||= file_type(path)
28
+ end
29
+
30
+ # Default to pretty print:
31
+ name ||= :pp
32
+
23
33
  FORMATS[name]
24
34
  end
35
+
36
+ def file_type(path)
37
+ if extension = File.extname(path)
38
+ extension.sub!(/\A\./, '')
39
+ return if extension.empty?
40
+ return extension.to_sym
41
+ end
42
+ end
data/lib/bake/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Bake
24
- VERSION = "0.18.1"
24
+ VERSION = "0.18.2"
25
25
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- F⏧�Z�
2
- �wS���pl���Jt g���{,l]�񄖷�����R�%ahy�����]�Aa � m���y���U�U]W���װĔP5�co{��&k!e�cո��s#���4k[7����H0�&�s#?7��dz% ����kSSzy6�G�H^աn���(! ���)��dW�Z� �+�6�ƛ=Vn,�M�QLϮ�A��˜���=LYN(������c=F־��ⲫo$�}�:�P�|p�@����8A� �dQ�D�wO[��� �_�wπ�1rOG��IQl������T�Ƿ����7UI���3�A���=ww����l�+!�U��WKJ�+�y����()5}��=�wG����Ia�.
1
+ ��/{�&�,fI7�J_e�S�: ���TVe ��u�<�)���YL/Nń��zʥU�� �E
2
+ J��~%��{ap��h����[�U�B6"ܗ�ˑ$���
3
+ �@�Whw���}��L@rm��n�W�,�A����8����vM`zj&G�k�Lk