rbparser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/rbparser.rb +97 -0
- data.tar.gz.sig +3 -0
- metadata +87 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0b8e767611058d830b6776b2464980e8c5dcd8d4
|
4
|
+
data.tar.gz: 6dfcf976bf8e0ef3b18c43ce05348df49c220065
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7dff35a591b5b13e7d6eafc47e1ec8dd9be51535ef7d51b4d89045398581c4f5e83c1115abf81390ae8e96789027874904e3706d635192b50da19789d27fb7e5
|
7
|
+
data.tar.gz: 72c455cbdf9e6ae83fd51bc1e88b7d617097e8d7d145bbc62bbd609614ba1a95f594c1d6f2f2fe224945a4c542a027270634489ea4c929da758aea0c0974a1e0
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/lib/rbparser.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: rbparser.rb
|
4
|
+
|
5
|
+
require 'app-routes'
|
6
|
+
|
7
|
+
|
8
|
+
class RbParser
|
9
|
+
include AppRoutes
|
10
|
+
|
11
|
+
attr_reader :to_a
|
12
|
+
|
13
|
+
def initialize(s)
|
14
|
+
|
15
|
+
super()
|
16
|
+
params = {}
|
17
|
+
expressions(@params)
|
18
|
+
|
19
|
+
@to_a = scan_lines s
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def expressions(params)
|
25
|
+
|
26
|
+
parse /if (.*) then/ do |condtn|
|
27
|
+
[:if, condtn]
|
28
|
+
end
|
29
|
+
|
30
|
+
parse /class\s+(\w+)/ do |clssnme|
|
31
|
+
[:class, clssnme]
|
32
|
+
end
|
33
|
+
|
34
|
+
parse /end/ do
|
35
|
+
[:end]
|
36
|
+
end
|
37
|
+
|
38
|
+
parse /def\s+(\w+)\s*\((?:\)|([^\)]+\)))/ do |mthdnme, argslst|
|
39
|
+
[:def, mthdnme, argslst]
|
40
|
+
end
|
41
|
+
|
42
|
+
get /(\w+)\(([^\)]+)\)/ do |mthdnme, argslst|
|
43
|
+
[:method, mthdnme, argslst]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
alias parse get
|
49
|
+
alias scan_line run_route
|
50
|
+
|
51
|
+
|
52
|
+
def scan_lines(s)
|
53
|
+
|
54
|
+
a = s.lines.inject([]) do |r,line|
|
55
|
+
|
56
|
+
line.strip.length > 0 ? r << scan_line(line) : r
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
treeize a
|
61
|
+
end
|
62
|
+
|
63
|
+
def treeize(a)
|
64
|
+
|
65
|
+
r = []
|
66
|
+
|
67
|
+
while a.length > 0 do
|
68
|
+
|
69
|
+
id, *remaining = stmnt = a.shift
|
70
|
+
|
71
|
+
case id
|
72
|
+
when :class
|
73
|
+
|
74
|
+
r << [:class]
|
75
|
+
r.last.concat treeize(a)
|
76
|
+
|
77
|
+
when :def
|
78
|
+
|
79
|
+
r << [:def]
|
80
|
+
r.last.concat treeize(a)
|
81
|
+
|
82
|
+
when :method
|
83
|
+
|
84
|
+
r << [:method_call]
|
85
|
+
|
86
|
+
when :end
|
87
|
+
|
88
|
+
return r
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
r
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rbparser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |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kZiuaYAhYAw3CUE7HHDqOHnCDI7Fc57T0Z8AXHg9CvU+XAc5gjqylPSWGKKptWRr
|
28
|
+
Fu5pKeXmMLSrIspg84mxkbVjtUV2dDU+5Qd3DHSzA2zJtRYhVPo+RG1IgW9sogTX
|
29
|
+
Jn10v9SqOdYu1tGmnZqZ9arxVUonjbPhytdfVfy5YoJA8FlR8HoSf1wB3hVVoyDH
|
30
|
+
lsgyF3v+RSD1TvpZ8F3B/3hoVCw2C50Q3LHMG17DxyQ0fevr35dkcBcJQfhrLEo+
|
31
|
+
bn8sY5nNmIeo6aho7rGLPijEVe0netDWcCk6UheO4MFo4vZhNnqmDV1a+paQo2ly
|
32
|
+
f6cJwtvsakLI8A==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2015-07-05 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: app-routes
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.1'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.1.18
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.1'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.1.18
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/rbparser.rb
|
63
|
+
homepage: https://github.com/jrobertson/rbparser
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.6
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Experimental gem to parse Ruby code
|
87
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|