inspect 0.0.0

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/inspect +18 -0
  3. data/lib/inspect.rb +37 -0
  4. metadata +74 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ff4e64da12e0a5222b38a6e94853a6e3579e2e3e
4
+ data.tar.gz: ee776f70fafbff4c32b1a2e06230fd049ade4fa5
5
+ SHA512:
6
+ metadata.gz: bf1fd3e97dce5f2a34c29603a6ca47cf81bb034c65cb2b8abfa922ea48a48587893e92794c1b15de68ee117e8542f7f8cc070dbc88aa880f724ace3ac6f98c42
7
+ data.tar.gz: 0488fc090ebef91d4701940b5ec75b6f2a1aecac83778948970bf74993b6c89f28521b0943575eba71a5efec7c5c9c4e4685b6c57c960eefecc1600ab7836e47
data/bin/inspect ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require 'inspect'
3
+
4
+ data = read_data
5
+ x = parse_data(ARGV.shift, data)
6
+ if x.nil?
7
+ puts 'ERROR: Could not parse data.'
8
+ puts 'ERROR: Try explicit formating, e.g. cat file | inspect json'
9
+ puts "ERROR: Here is the first line: #{data.lines.first}"
10
+ exit 1
11
+ end
12
+ puts 'x is ready.'
13
+
14
+ require 'readline'
15
+ require 'pry'
16
+
17
+ Readline.input = IO.new(IO.sysopen("/dev/tty", "r+"))
18
+ binding.pry(quiet: true)
data/lib/inspect.rb ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ require 'json'
3
+ require 'csv'
4
+ require 'nokogiri'
5
+ def parse_data(format, data)
6
+ if format.nil?
7
+ if data.match /^\s*</
8
+ x = parse('html', data)
9
+ else
10
+ x = parse('json', data)
11
+ x = parse('csv', data) if x.nil?
12
+ x = parse('tsv', data) if x.nil?
13
+ end
14
+ else
15
+ x = parse(format, data)
16
+ end
17
+ x
18
+ end
19
+
20
+ def read_data
21
+ puts "Reading from STDIN..."
22
+ ARGF.read
23
+ end
24
+
25
+ def parse(format, data)
26
+ case format
27
+ when 'json'
28
+ JSON.parse(data)
29
+ when 'tsv'
30
+ CSV.parse(data, col_sep: "\t")
31
+ when 'csv'
32
+ CSV.parse(data)
33
+ when 'html'
34
+ Nokogiri::HTML(data)
35
+ end
36
+ rescue JSON::ParserError, CSV::MalformedCSVError
37
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inspect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sina Siadat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ description: Drop into a powerful REPL to inspect your Json, CSV, and HTML files.
42
+ email: siadat+gem@gmail.com
43
+ executables:
44
+ - inspect
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/inspect
49
+ - lib/inspect.rb
50
+ homepage: https://github.com/siadat/inspect
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.5.1
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: REPL for Json, CSV, and HTML.
74
+ test_files: []