ricojson 0.1.1 → 0.1.2
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 +4 -4
- data/lib/ricojson.rb +52 -54
- metadata +26 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daf902da688595a645f37c40decebcac2fab0bcf2c10da87d7dae4e7e8004c6c
|
4
|
+
data.tar.gz: 5261c53f1f4b1bd0a1ce503b4a4c9eb01e5c1f5f201c9508438948e77c14a261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73370e82bca9938863d117b843688bb2fa76bc384b3cec97ba78c22e88dedcf8a042c60f9012a3ea60c995db711eeab21f6cf9d0cdd62fb279806a35da44e5f2
|
7
|
+
data.tar.gz: 7387c2951762faaf17d6012616a4daf9b89ee8799bf248d222129fd82b0c0228b67d01fb62016a7b37b6fa5bd50d0e7e29a66edd6f8f8c18204f84ed8f68f613
|
data/lib/ricojson.rb
CHANGED
@@ -1,67 +1,65 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require 'json'
|
3
2
|
require 'tempfile'
|
4
3
|
|
5
4
|
# Main RicoJSON functionality
|
6
5
|
module RicoJSON
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
`open -t #{json.path}`
|
6
|
+
class << self
|
7
|
+
# Define open_in_app method for GNU/Linux or Mac OS X platforms
|
8
|
+
def open_in_app(json)
|
9
|
+
if RUBY_PLATFORM =~ /linux/
|
10
|
+
`xdg-open #{json.path}`
|
11
|
+
elsif RUBY_PLATFORM =~ /macos|darwin/
|
12
|
+
`open -t #{json.path}`
|
13
|
+
end
|
16
14
|
end
|
17
|
-
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
# Method for reading a file as an input
|
17
|
+
#
|
18
|
+
# Example:
|
19
|
+
# $ ricojson -f comics.json
|
20
|
+
#
|
21
|
+
# Arguments:
|
22
|
+
# filename: Name of the input file
|
23
|
+
# open: Open the file in the default app/text editor for ,json
|
24
|
+
# files (optional)
|
25
|
+
#
|
26
|
+
# == Returns:
|
27
|
+
# JSON Rico y Suave
|
28
|
+
def read_file(filename, open = false)
|
29
|
+
read_string(File.read(filename), open)
|
30
|
+
end
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
32
|
+
# Method for reading a String as an input
|
33
|
+
#
|
34
|
+
# Example:
|
35
|
+
# $ cat comics.json | ricojson
|
36
|
+
#
|
37
|
+
# Arguments:
|
38
|
+
# json_string: Incoming String (could be piped from curl, cat,
|
39
|
+
# echo, etc)
|
40
|
+
# open: Open the file in the default app/text editor for ,json
|
41
|
+
# files (optional)
|
42
|
+
#
|
43
|
+
# == Returns:
|
44
|
+
# JSON Rico y Suave
|
45
|
+
def read_string(json_string, open = false)
|
46
|
+
body = JSON.pretty_generate(JSON.parse(json_string))
|
47
|
+
if open
|
48
|
+
open_in_file(body)
|
49
|
+
else
|
50
|
+
puts body
|
51
|
+
end
|
54
52
|
end
|
55
|
-
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
54
|
+
# Used to open the prettified JSON in a text editor or other
|
55
|
+
# system's app
|
56
|
+
def open_in_file(body)
|
57
|
+
fork do
|
58
|
+
json = Tempfile.new(['json', '.json'])
|
59
|
+
json.write(body)
|
60
|
+
json.close
|
61
|
+
open_in_app(json)
|
62
|
+
end
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
metadata
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ricojson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Briano
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-05-16 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: clap
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '1'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - "
|
23
|
+
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
25
|
+
version: '1'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: minitest
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +41,30 @@ dependencies:
|
|
42
41
|
name: rubocop
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
|
-
- - "
|
44
|
+
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '1'
|
48
47
|
type: :development
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
|
-
- - "
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rake
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '13'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
53
66
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
67
|
+
version: '13'
|
55
68
|
description: Uses Ruby's JSON to parse and format json files, includes an option to
|
56
69
|
open them in the system's default application.
|
57
70
|
email: fernando@picandocodigo.net
|
@@ -64,9 +77,8 @@ files:
|
|
64
77
|
- lib/ricojson.rb
|
65
78
|
homepage: https://github.com/picandocodigo/ricojson
|
66
79
|
licenses:
|
67
|
-
- LGPL-3.0
|
80
|
+
- LGPL-3.0-or-later
|
68
81
|
metadata: {}
|
69
|
-
post_install_message:
|
70
82
|
rdoc_options: []
|
71
83
|
require_paths:
|
72
84
|
- lib
|
@@ -81,9 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
93
|
- !ruby/object:Gem::Version
|
82
94
|
version: '0'
|
83
95
|
requirements: []
|
84
|
-
|
85
|
-
rubygems_version: 2.7.6
|
86
|
-
signing_key:
|
96
|
+
rubygems_version: 3.6.3
|
87
97
|
specification_version: 4
|
88
98
|
summary: A gem to prettify JSON files and (optionally) open them in default app
|
89
99
|
test_files: []
|