jsonom 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/jsonom +4 -0
- data/lib/jsonom/argument_parser.rb +17 -0
- data/lib/jsonom/executioner.rb +30 -0
- data/lib/jsonom/json_parser.rb +36 -0
- data/lib/jsonom/object.rb +3 -0
- data/lib/jsonom.rb +4 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f2e5d5d46376d0bf472f376436346733af6643f5
|
4
|
+
data.tar.gz: 5d8b8b51370edc2ea4562e8fc3a2e427bd90b7a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9bcbea1e61d9886ce667555e88ed936bc48ceb610956f10193ab988b76f4afe202b6ccd62308f885f25b6426528c0347d8d361e6e2a480c5bfef193cfe6c5b50
|
7
|
+
data.tar.gz: c2b28f848ec0f2396d7890abd8e2cd72000e74502b8300f7f74026505a39e008e3e859e64459f48808ef2ad1329f00f75a128c4fafcff32b9e4539734916a4a3
|
data/bin/jsonom
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module JSONom
|
2
|
+
class ArgumentParser
|
3
|
+
def self.parse_arguments(argument_array = [])
|
4
|
+
commands = []
|
5
|
+
|
6
|
+
if(argument_array.length == 0)
|
7
|
+
commands = ["help"]
|
8
|
+
elsif(argument_array.length == 1)
|
9
|
+
commands = ["set_file...", argument_array[0], "debug_file"]
|
10
|
+
elsif(argument_array.length == 2)
|
11
|
+
commands = ["set_file...", argument_array[0], "get_property...", argument_array[1], "debug_property"]
|
12
|
+
end
|
13
|
+
|
14
|
+
return commands
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module JSONom
|
2
|
+
class Executioner
|
3
|
+
attr_reader :args
|
4
|
+
attr_accessor :commands
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
@args = args
|
8
|
+
@commands = ArgumentParser.parse_arguments(@args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.execute(*args)
|
12
|
+
new(*args).execute
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
opfile = nil
|
17
|
+
opprop = nil
|
18
|
+
|
19
|
+
@commands.each_with_index do |command, index|
|
20
|
+
if(command == "set_file...")
|
21
|
+
opfile = @commands[index + 1]
|
22
|
+
elsif(command == "get_property...")
|
23
|
+
opprop = @commands[index + 1]
|
24
|
+
elsif(command =~ /\Adebug\_/)
|
25
|
+
JSONParser.debug(opfile, opprop)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module JSONom
|
4
|
+
class JSONParser
|
5
|
+
def self.debug(filename = nil, propertyname = nil)
|
6
|
+
if(filename == nil)
|
7
|
+
return
|
8
|
+
end
|
9
|
+
|
10
|
+
file_lines = []
|
11
|
+
|
12
|
+
file = File.new(File.join(Dir.pwd, filename), "r")
|
13
|
+
while (line = file.gets)
|
14
|
+
file_lines << line
|
15
|
+
end
|
16
|
+
file.close
|
17
|
+
|
18
|
+
file_data = file_lines.join("\n")
|
19
|
+
|
20
|
+
file_struct = JSON.parse(file_data)
|
21
|
+
|
22
|
+
thing = file_struct
|
23
|
+
|
24
|
+
if(propertyname == nil)
|
25
|
+
else
|
26
|
+
propertynames = propertyname.split(".")
|
27
|
+
|
28
|
+
propertynames.each_with_index do |property|
|
29
|
+
thing = thing[property]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
puts JSON.dump(thing)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/jsonom.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jsonom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kristofer Rye
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.1'
|
41
|
+
description: A tool for opening a JSON file and reading out a given property.
|
42
|
+
email: kristofer.rye@gmail.com
|
43
|
+
executables:
|
44
|
+
- jsonom
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- bin/jsonom
|
49
|
+
- lib/jsonom.rb
|
50
|
+
- lib/jsonom/argument_parser.rb
|
51
|
+
- lib/jsonom/executioner.rb
|
52
|
+
- lib/jsonom/json_parser.rb
|
53
|
+
- lib/jsonom/object.rb
|
54
|
+
homepage: https://github.com/four04/jsonom
|
55
|
+
licenses:
|
56
|
+
- GPL-3.0
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.9.3
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.2.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: A console-based JSON field detector.
|
78
|
+
test_files: []
|