ricojson 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/ricojson +34 -17
  2. metadata +22 -6
@@ -1,21 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- require 'rico_json'
4
-
5
- args = ARGV.dup
6
-
7
- # TODO: Validate args
8
- case args.size
9
- when 0
10
- RicoJSON.read_string(STDIN.read)
11
- when 1
12
- if args[0] != '-o'
13
- RicoJSON.read_file(args[0])
14
- else
15
- RicoJSON.read_string(STDIN.read, true)
16
- end
17
- when 2
18
- RicoJSON.read_file(args[1], true)
3
+ require 'ricojson'
4
+ require 'clap'
5
+
6
+ input_file = nil
7
+ open_result = false
8
+ help_message = <<EOS
9
+ Usage: ricojson [-oh] [-f file]
10
+
11
+ Synopsis:
12
+
13
+ ricojson is a command line utility that will format a given JSON input
14
+ so that it can be read by humans.
15
+
16
+ The default action for ricojson consists on reading from STDIN and is
17
+ meant to be used by piping other commnands results into it, however you
18
+ can also specify a file to read from.
19
+
20
+ Flags:
21
+
22
+ -f file Read JSON from specified file.
23
+ -o Opens the resulting formatted JSON in your default
24
+ text editor.
25
+ -h Prints this message.
26
+ EOS
27
+
28
+
29
+ Clap.run ARGV,
30
+ '-f' => lambda { |file| input_file = file },
31
+ '-o' => lambda { open_result = true },
32
+ '-h' => lambda { abort(help_message) }
33
+
34
+ if input_file.nil?
35
+ RicoJSON.read_string(STDIN.read, open_result)
19
36
  else
20
- puts 'Usage: json-rico [-o] [file]'
37
+ RicoJSON.read_file(input_file, open_result)
21
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ricojson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-27 00:00:00.000000000 Z
12
+ date: 2014-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: clap
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: minitest
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -43,8 +59,8 @@ dependencies:
43
59
  - - ~>
44
60
  - !ruby/object:Gem::Version
45
61
  version: '0.19'
46
- description: Uses Ruby's JSON to parse and format json files and opens them in the
47
- system's default application.
62
+ description: Uses Ruby's JSON to parse and format json files, includes an option to
63
+ open them in the system's default application.
48
64
  email: fernando@picandocodigo.net
49
65
  executables:
50
66
  - ricojson
@@ -55,7 +71,7 @@ files:
55
71
  - bin/ricojson
56
72
  homepage: https://github.com/picandocodigo/json-pretty
57
73
  licenses:
58
- - GPL-3
74
+ - LGPL-3.0
59
75
  post_install_message:
60
76
  rdoc_options: []
61
77
  require_paths:
@@ -77,6 +93,6 @@ rubyforge_project:
77
93
  rubygems_version: 1.8.23
78
94
  signing_key:
79
95
  specification_version: 3
80
- summary: A gem to prettify JSON files and open them in default app
96
+ summary: A gem to prettify JSON files and (optionally) open them in default app
81
97
  test_files: []
82
98
  has_rdoc: