ricojson 0.1.0 → 0.1.1

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 (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/ricojson +0 -1
  3. data/lib/ricojson.rb +30 -0
  4. metadata +19 -28
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d670436f33aa1e585fcd956383e1655b08e8d850196af283e537622a86e7b04f
4
+ data.tar.gz: d381be30d03552d93131066653ebf816d8cea8e81be760c8c6c86f4aee7255fc
5
+ SHA512:
6
+ metadata.gz: 5cb6dbd15f633de707c25905f12c6cebd7a4be986677dd3b861c19f1affa5341b4eadf3a5c6caaee8a2f3fb87569fc2f96e64eeff4dd4ae62643ccd4d14cf413
7
+ data.tar.gz: a9b8354dec07890d5a23f943cdbeacc97e67dea0488b95fd9a8880290af7f1527183afeba0b4f941c548532c72aa1f1c4a063778c7e8e7f1e9c403ad3306ed6d
@@ -25,7 +25,6 @@ Flags:
25
25
  -h Prints this message.
26
26
  EOS
27
27
 
28
-
29
28
  Clap.run ARGV,
30
29
  '-f' => lambda { |file| input_file = file },
31
30
  '-o' => lambda { open_result = true },
@@ -2,7 +2,10 @@
2
2
  require 'json'
3
3
  require 'tempfile'
4
4
 
5
+ # Main RicoJSON functionality
5
6
  module RicoJSON
7
+
8
+ # Define open method for GNU/Linux or Mac OS X platforms
6
9
  if RUBY_PLATFORM =~ /linux/
7
10
  def self.open(json)
8
11
  `xdg-open #{json.path}`
@@ -13,10 +16,35 @@ module RicoJSON
13
16
  end
14
17
  end
15
18
 
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
16
31
  def self.read_file(filename, open = false)
17
32
  read_string(File.read(filename), open)
18
33
  end
19
34
 
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
20
48
  def self.read_string(json_string, open = false)
21
49
  body = JSON.pretty_generate(JSON.parse(json_string))
22
50
  if open
@@ -26,6 +54,8 @@ module RicoJSON
26
54
  end
27
55
  end
28
56
 
57
+ # Used to open the prettified JSON in a text editor or other
58
+ # system's app
29
59
  def self.open_in_file(body)
30
60
  fork do
31
61
  json = Tempfile.new(['json', '.json'])
metadata CHANGED
@@ -1,64 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ricojson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fernando Briano
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2018-10-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: clap
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: minitest
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '5.3'
33
+ version: '5'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '5.3'
40
+ version: '5'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rubocop
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '0.19'
47
+ version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
- version: '0.19'
54
+ version: '0'
62
55
  description: Uses Ruby's JSON to parse and format json files, includes an option to
63
56
  open them in the system's default application.
64
57
  email: fernando@picandocodigo.net
@@ -67,32 +60,30 @@ executables:
67
60
  extensions: []
68
61
  extra_rdoc_files: []
69
62
  files:
70
- - lib/ricojson.rb
71
63
  - bin/ricojson
72
- homepage: https://github.com/picandocodigo/json-pretty
64
+ - lib/ricojson.rb
65
+ homepage: https://github.com/picandocodigo/ricojson
73
66
  licenses:
74
67
  - LGPL-3.0
68
+ metadata: {}
75
69
  post_install_message:
76
70
  rdoc_options: []
77
71
  require_paths:
78
72
  - lib
79
73
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
74
  requirements:
82
- - - ! '>='
75
+ - - ">="
83
76
  - !ruby/object:Gem::Version
84
77
  version: '0'
85
78
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
79
  requirements:
88
- - - ! '>='
80
+ - - ">="
89
81
  - !ruby/object:Gem::Version
90
82
  version: '0'
91
83
  requirements: []
92
84
  rubyforge_project:
93
- rubygems_version: 1.8.23
85
+ rubygems_version: 2.7.6
94
86
  signing_key:
95
- specification_version: 3
87
+ specification_version: 4
96
88
  summary: A gem to prettify JSON files and (optionally) open them in default app
97
89
  test_files: []
98
- has_rdoc: