parsejs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +5 -0
- data/README.markdown +85 -0
- data/Rakefile +15 -0
- data/lib/parsejs.rb +14 -0
- data/lib/parsejs/ast.rb +84 -0
- data/lib/parsejs/docs.rb +237 -0
- data/lib/parsejs/grammar.kpeg +575 -0
- data/lib/parsejs/grammar.kpeg.rb +9460 -0
- data/lib/parsejs/scope.rb +183 -0
- data/lib/parsejs/stringifier.rb +450 -0
- data/lib/parsejs/version.rb +3 -0
- data/lib/parsejs/visitor.rb +257 -0
- data/parsejs.gemspec +24 -0
- data/spec/fixtures/jquery-1.6.js +8982 -0
- data/spec/fixtures/jquery-1.7.js +9289 -0
- data/spec/fixtures/jquery-ajax.js +1000 -0
- data/spec/fixtures/jquery-attributes.js +650 -0
- data/spec/fixtures/jquery-traversing.js +330 -0
- data/spec/fixtures/metamorph.js +324 -0
- data/spec/fixtures/sizzle.js +1442 -0
- data/spec/fixtures/sproutcore-core.js +195 -0
- data/spec/fixtures/sproutcore-each-proxy.js +218 -0
- data/spec/fixtures/sproutcore-native-array.js +139 -0
- data/spec/fixtures/sproutcore.js +14319 -0
- data/spec/scope_spec.rb +111 -0
- data/spec/stringify_spec.rb +587 -0
- data/test.rb +76 -0
- metadata +145 -0
data/test.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "lattescript"
|
4
|
+
require "benchmark"
|
5
|
+
|
6
|
+
require "ruby-prof"
|
7
|
+
|
8
|
+
file = <<-FOO
|
9
|
+
/**
|
10
|
+
some docs
|
11
|
+
*/
|
12
|
+
App.Foo = SC.View.extend({
|
13
|
+
/**
|
14
|
+
some docs
|
15
|
+
*/
|
16
|
+
hi: function() {
|
17
|
+
|
18
|
+
}
|
19
|
+
});
|
20
|
+
FOO
|
21
|
+
|
22
|
+
parser = LatteScript::Parser.new(file)
|
23
|
+
parser.parse
|
24
|
+
ast = parser.result
|
25
|
+
new_string = LatteScript::Stringifier.to_string(ast) do |stringifier|
|
26
|
+
stringifier.include_comments = true
|
27
|
+
end
|
28
|
+
|
29
|
+
puts new_string
|
30
|
+
|
31
|
+
__END__
|
32
|
+
|
33
|
+
#result = RubyProf.profile do
|
34
|
+
|
35
|
+
Dir[File.expand_path("~/Code/cool_stuff/sproutcore20/packages/**/lib/**/*.js")].each do |file|
|
36
|
+
#Dir[File.expand_path("~/Code/cool_stuff/jquery/src/**/*.js")].each do |file|
|
37
|
+
#Dir["/Users/wycats/Code/cool_stuff/jquery/src/queue.js"].each do |file|
|
38
|
+
next if file =~ /jquery-|packages\/handlebars|packages\/metamorph/
|
39
|
+
#next if file =~ /intro|outro|sizzle\/(speed|test)|sizzle-jquery/
|
40
|
+
string = File.read(file)
|
41
|
+
|
42
|
+
puts "#{file}: "
|
43
|
+
puts
|
44
|
+
|
45
|
+
result = Benchmark.measure {
|
46
|
+
LatteScript::Parser.new(string).parse
|
47
|
+
}
|
48
|
+
|
49
|
+
#puts "#{string.size} bytes in #{result.total.round(2)}s = #{(string.size / result.total).round}bps"
|
50
|
+
end
|
51
|
+
#end
|
52
|
+
|
53
|
+
#printer = RubyProf::CallTreePrinter.new(result)
|
54
|
+
#printer.print(File.open("call.grind", "w"))
|
55
|
+
|
56
|
+
__END__
|
57
|
+
|
58
|
+
string = File.read("spec/fixtures/jquery.js")
|
59
|
+
|
60
|
+
#require "ruby-prof"
|
61
|
+
|
62
|
+
ast = nil
|
63
|
+
|
64
|
+
#result = RubyProf.profile do
|
65
|
+
parser = LatteScript::Parser.new(string)
|
66
|
+
ast = parser.parse
|
67
|
+
#end
|
68
|
+
|
69
|
+
#printer = RubyProf::FlatPrinter.new(result)
|
70
|
+
#printer.print(STDOUT)
|
71
|
+
#printer.print(File.open("profile.html", "w"))
|
72
|
+
|
73
|
+
#new_string = LatteScript::Stringifier.to_string(ast) do |stringifier|
|
74
|
+
#stringifier.include_comments = true
|
75
|
+
#end
|
76
|
+
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: parsejs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yehuda Katz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kpeg
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: uglifier
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ParseJS is a JavaScript parser written using KPeg
|
84
|
+
email:
|
85
|
+
- wycats@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.markdown
|
95
|
+
- Rakefile
|
96
|
+
- lib/parsejs.rb
|
97
|
+
- lib/parsejs/ast.rb
|
98
|
+
- lib/parsejs/docs.rb
|
99
|
+
- lib/parsejs/grammar.kpeg
|
100
|
+
- lib/parsejs/grammar.kpeg.rb
|
101
|
+
- lib/parsejs/scope.rb
|
102
|
+
- lib/parsejs/stringifier.rb
|
103
|
+
- lib/parsejs/version.rb
|
104
|
+
- lib/parsejs/visitor.rb
|
105
|
+
- parsejs.gemspec
|
106
|
+
- spec/fixtures/jquery-1.6.js
|
107
|
+
- spec/fixtures/jquery-1.7.js
|
108
|
+
- spec/fixtures/jquery-ajax.js
|
109
|
+
- spec/fixtures/jquery-attributes.js
|
110
|
+
- spec/fixtures/jquery-traversing.js
|
111
|
+
- spec/fixtures/metamorph.js
|
112
|
+
- spec/fixtures/sizzle.js
|
113
|
+
- spec/fixtures/sproutcore-core.js
|
114
|
+
- spec/fixtures/sproutcore-each-proxy.js
|
115
|
+
- spec/fixtures/sproutcore-native-array.js
|
116
|
+
- spec/fixtures/sproutcore.js
|
117
|
+
- spec/scope_spec.rb
|
118
|
+
- spec/stringify_spec.rb
|
119
|
+
- test.rb
|
120
|
+
homepage: ''
|
121
|
+
licenses: []
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.4.5
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: ParseJS parses JavaScript into a Ruby AST, suitable for preprocessing and
|
143
|
+
other purposes. It also has work-in-progress support for extracting documentation
|
144
|
+
from JavaScript
|
145
|
+
test_files: []
|