json-waveform 0.0.3 → 0.1.0

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
  SHA1:
3
- metadata.gz: 83938d351b35d92ff6e575264f09bb78a1f88371
4
- data.tar.gz: fbc56a07a8090835f63b6839c515f32619e7b9e2
3
+ metadata.gz: bd2e33a91089ceb6931b15602438bdd1cc4a3c9d
4
+ data.tar.gz: 9122243fe4acaef1954a929f17e53acf4cd44e8f
5
5
  SHA512:
6
- metadata.gz: f2c02e06ce94bf75b535a48954da2fb4ebe578e5db27c709d2e00b50985fec37470a6fc93541c7310b2bd31e0fd322802053c2ede0cc719c11a7375fa494836f
7
- data.tar.gz: 33257f3fa1b08ae0c7e271c6c14a24c3321a4e5ff97e92eabe83b07761eaccbcb550c8069c6fff10e5898b0c3065911a6ec533150391b278f722e5b4ec571b6d
6
+ metadata.gz: 3e3489489c328093edc783aea97563b9f9e14997dfe9df02fe17cf3cc7ce2b641f1f839c434f84710c847dfa53d2fd3a497f33f971808796dfbf673b65101fb5
7
+ data.tar.gz: b0fcc8bb42c729fbe4bbc5a3b6c0a224cf21ebecec5421ebc065420844b8cdb1eafbfd528f3708eaa79c9385c455a8767b4740e7607a162433d865fc43160952
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "json-waveform"
3
+ require "json"
3
4
  require "optparse"
4
5
 
5
6
  options = JsonWaveform::DEFAULT_OPTIONS
@@ -7,6 +8,10 @@ optparse = OptionParser.new do |o|
7
8
  o.banner = "Usage: json-waveform [options] source_audio"
8
9
  o.version = JsonWaveform::VERSION
9
10
 
11
+ o.on("-o", "--output FILE", "File where to write the JSON -- Default is stdout.") do |output|
12
+ options[:output] = output
13
+ end
14
+
10
15
  o.on("-s", "--samples SAMPLES", "Samples generated from the original file (i.e.: waveform width) -- Default #{JsonWaveform::DEFAULT_OPTIONS[:samples]}.") do |samples|
11
16
  options[:samples] = samples.to_i
12
17
  end
@@ -32,8 +37,14 @@ end
32
37
  optparse.parse!
33
38
 
34
39
  begin
35
- result = JsonWaveform.generate(ARGV[0], options)
36
- puts result
40
+ result = JSON.dump(JsonWaveform.generate(ARGV[0], options))
41
+ if options[:output]
42
+ File.open(options[:output], 'w') do |file|
43
+ file.write result
44
+ end
45
+ else
46
+ puts result
47
+ end
37
48
  rescue JsonWaveform::ArgumentError => e
38
49
  puts e.message + "\n\n"
39
50
  puts optparse
@@ -1,3 +1,3 @@
1
1
  class JsonWaveform
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.1.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-waveform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esteban Pastorino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-11 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-audio