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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ricojson.rb +52 -54
  3. metadata +26 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d670436f33aa1e585fcd956383e1655b08e8d850196af283e537622a86e7b04f
4
- data.tar.gz: d381be30d03552d93131066653ebf816d8cea8e81be760c8c6c86f4aee7255fc
3
+ metadata.gz: daf902da688595a645f37c40decebcac2fab0bcf2c10da87d7dae4e7e8004c6c
4
+ data.tar.gz: 5261c53f1f4b1bd0a1ce503b4a4c9eb01e5c1f5f201c9508438948e77c14a261
5
5
  SHA512:
6
- metadata.gz: 5cb6dbd15f633de707c25905f12c6cebd7a4be986677dd3b861c19f1affa5341b4eadf3a5c6caaee8a2f3fb87569fc2f96e64eeff4dd4ae62643ccd4d14cf413
7
- data.tar.gz: a9b8354dec07890d5a23f943cdbeacc97e67dea0488b95fd9a8880290af7f1527183afeba0b4f941c548532c72aa1f1c4a063778c7e8e7f1e9c403ad3306ed6d
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
- # Define open method for GNU/Linux or Mac OS X platforms
9
- if RUBY_PLATFORM =~ /linux/
10
- def self.open(json)
11
- `xdg-open #{json.path}`
12
- end
13
- elsif RUBY_PLATFORM =~ /macos|darwin/
14
- def self.open(json)
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
- # Method for reading a file as an input
20
- #
21
- # Example:
22
- # $ ricojson -f comics.json
23
- #
24
- # Arguments:
25
- # filename: Name of the input file
26
- # open: Open the file in the default app/text editor for ,json
27
- # files (optional)
28
- #
29
- # == Returns:
30
- # JSON Rico y Suave
31
- def self.read_file(filename, open = false)
32
- read_string(File.read(filename), open)
33
- end
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
- # Method for reading a String as an input
36
- #
37
- # Example:
38
- # $ cat comics.json | ricojson
39
- #
40
- # Arguments:
41
- # json_string: Incoming String (could be piped from curl, cat,
42
- # echo, etc)
43
- # open: Open the file in the default app/text editor for ,json
44
- # files (optional)
45
- #
46
- # == Returns:
47
- # JSON Rico y Suave
48
- def self.read_string(json_string, open = false)
49
- body = JSON.pretty_generate(JSON.parse(json_string))
50
- if open
51
- open_in_file(body)
52
- else
53
- puts body
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
- # Used to open the prettified JSON in a text editor or other
58
- # system's app
59
- def self.open_in_file(body)
60
- fork do
61
- json = Tempfile.new(['json', '.json'])
62
- json.write(body)
63
- json.close
64
- open(json)
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.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: 2018-10-15 00:00:00.000000000 Z
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: '0'
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: '0'
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: '0'
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: '0'
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
- rubyforge_project:
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: []