arst 0.0.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.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ arst (0.0.1)
5
+ active_support (~> 3.0.0)
6
+ parslet (~> 1.5.0)
7
+ version (~> 1.0.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ active_support (3.0.0)
13
+ activesupport (= 3.0.0)
14
+ activesupport (3.0.0)
15
+ awesome_print (1.1.0)
16
+ blankslate (2.1.2.4)
17
+ climate_control (0.0.3)
18
+ activesupport (>= 3.0)
19
+ cocaine (0.5.1)
20
+ climate_control (>= 0.0.3, < 1.0)
21
+ coderay (1.0.9)
22
+ formatador (0.2.4)
23
+ guard (1.7.0)
24
+ formatador (>= 0.2.4)
25
+ listen (>= 0.6.0)
26
+ lumberjack (>= 1.0.2)
27
+ pry (>= 0.9.10)
28
+ thor (>= 0.14.6)
29
+ guard-bundler (1.0.0)
30
+ bundler (~> 1.0)
31
+ guard (~> 1.1)
32
+ guard-shell (0.5.1)
33
+ guard (>= 1.1.0)
34
+ listen (0.7.3)
35
+ lumberjack (1.0.3)
36
+ method_source (0.8.1)
37
+ parslet (1.5.0)
38
+ blankslate (~> 2.0)
39
+ pry (0.9.12)
40
+ coderay (~> 1.0.5)
41
+ method_source (~> 0.8)
42
+ slop (~> 3.4)
43
+ rake (10.0.4)
44
+ rb-fsevent (0.9.3)
45
+ slop (3.4.4)
46
+ thor (0.18.1)
47
+ version (1.0.0)
48
+
49
+ PLATFORMS
50
+ ruby
51
+ x86-mingw32
52
+
53
+ DEPENDENCIES
54
+ arst!
55
+ awesome_print (~> 1.1.0)
56
+ cocaine (~> 0.5.0)
57
+ guard-bundler (~> 1.0.0)
58
+ guard-shell (~> 0.5.0)
59
+ rake (~> 10.0.0)
60
+ rb-fsevent (~> 0.9.0)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Ryan Scott Lewis <ryan@rynet.us>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,104 @@
1
+ # ARST
2
+
3
+ Abstract Ruby Syntax Tree (ARST) is a high-level language syntax denoting the object domain of a Ruby project.
4
+
5
+ ARST can be used to generate:
6
+
7
+ * Pure Ruby
8
+ * C Ruby extensions
9
+ * Test::Unit, MiniTest::Unit, MiniTest::Spec, or RSpec tests
10
+ * GraphViz graphs
11
+ * Custom output
12
+
13
+ ARST files can also be generated from existing projects which allows:
14
+
15
+ * Bootstrapping C Ruby extensions
16
+ * Bootstrapping Test::Unit, MiniTest::Unit, MiniTest::Spec, or RSpec tests
17
+ * Generating GraphViz graphs
18
+
19
+ Integrations:
20
+
21
+ * [Rake](https://github.com/RyanScottLewis/rake-arst)
22
+ * [Thor](https://github.com/RyanScottLewis/thor-arst)
23
+ * [Guard](https://github.com/RyanScottLewis/guard-arst)
24
+
25
+ Generators:
26
+
27
+ * ARST::Generator::Ruby (baked into this gem)
28
+ * ARST::Generator::CRuby (baked into this gem)
29
+ * [ARST::Generator::JRuby](https://github.com/RyanScottLewis/arst-generator-jruby)
30
+ * [ARST::Generator::Test::Unit](https://github.com/RyanScottLewis/arst-generator-test-unit)
31
+ * [ARST::Generator::MiniTest::Unit](https://github.com/RyanScottLewis/arst-generator-minitest-unit)
32
+ * [ARST::Generator::MiniTest::Spec](https://github.com/RyanScottLewis/arst-generator-minitest-spec)
33
+ * [ARST::Generator::RSpec](https://github.com/RyanScottLewis/arst-generator-rspec)
34
+ * [ARST::Generator::Graphviz](https://github.com/RyanScottLewis/arst-generator-graphviz)
35
+
36
+ ## Install
37
+
38
+ ### Bundler: `gem 'arst'` in `group :development`
39
+
40
+ ### RubyGems: `gem install arst`
41
+
42
+ ## Syntax
43
+
44
+ ### Ruby
45
+
46
+ ARST syntax implements most keywords and declarations of the Ruby language's syntax.
47
+
48
+ This means that most syntax highlighters for Ruby will also work for ARST.
49
+
50
+ **Valid Ruby syntax within ARST:**
51
+
52
+ * `module ModuleName`
53
+ * `class ClassName < SuperClassName`
54
+ * `include ModuleName`
55
+ * `extend ModuleName`
56
+ * `def instance_method(arg1, *other_args)` (and anything else accepted method arguments in Ruby's syntax)
57
+ * `def self.class_method(arg1, opts={})` (and anything else accepted method arguments in Ruby's syntax)
58
+
59
+ ### Indentation
60
+
61
+ ARST is an indentation-sensitive syntax meaning that the following are **not** equivalent:
62
+
63
+ <table width="100%"><tr><td>
64
+ ```rb
65
+ module Foo
66
+ module Bar
67
+ ```
68
+ </td><td>
69
+ ```rb
70
+ module Foo
71
+ module Bar
72
+ ```
73
+ </td></tr><table>
74
+
75
+ When interpreting the ARST syntax, the parser accepts any number of identical sequential whitespace characters
76
+ at the starst of a line as an "indentation step".
77
+ Valid whitespace characters are the space (` `) and tab (`\t`) characters.
78
+
79
+ Once the first indentation step is found while parsing, all subsequent indentation steps must contain the same
80
+ amount of whitespace characters as the first step:
81
+
82
+ <table width="100%"><tr><td>
83
+ **Valid**
84
+ ```rb
85
+ module Foo
86
+ module Bar
87
+ module Baz
88
+ ```
89
+ </td><td>
90
+ **Invalid**
91
+ ```rb
92
+ module Foo
93
+ module Bar
94
+ module Baz
95
+ ```
96
+ </td></tr><table>
97
+
98
+ ## Usage
99
+
100
+ ## Copyright
101
+
102
+ Copyright © 2013 Ryan Scott Lewis <ryan@rynet.us>.
103
+
104
+ The MIT License (MIT) - See LICENSE for further details.
@@ -0,0 +1,14 @@
1
+ require 'pathname'
2
+ require 'rake/version_task'
3
+ require 'rubygems/package_task'
4
+
5
+ gemspec = Pathname.glob( Pathname.new(__FILE__).join('..', '*.gemspec') ).first
6
+ $spec = Gem::Specification.load( gemspec.to_s )
7
+
8
+ Gem::PackageTask.new($spec) do |task|
9
+ task.need_zip = false
10
+ end
11
+
12
+ Rake::VersionTask.new do |task|
13
+ task.with_git_tag = true
14
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,33 @@
1
+ require 'pathname'
2
+
3
+ Gem::Specification.new do |s|
4
+
5
+ # Variables
6
+ s.author = 'Ryan Scott Lewis'
7
+ s.email = 'ryan@rynet.us'
8
+ s.summary = 'Abstract Ruby Syntax Tree (ARST) is a high-level language syntax denoting the object domain of a Ruby project.'
9
+ s.license = 'MIT'
10
+
11
+ # Dependencies
12
+ s.add_dependency 'active_support', '~> 3.0.0'
13
+ s.add_dependency 'parslet', '~> 1.5.0'
14
+ s.add_dependency 'version', '~> 1.0.0'
15
+ # s.add_dependency 'polyglot', '~> 0.3.0'
16
+ s.add_development_dependency 'awesome_print', '~> 1.1.0'
17
+ s.add_development_dependency 'cocaine', '~> 0.5.0'
18
+ s.add_development_dependency 'guard-bundler', '~> 1.0.0'
19
+ s.add_development_dependency 'guard-shell', '~> 0.5.0'
20
+ s.add_development_dependency 'rake', '~> 10.0.0'
21
+ s.add_development_dependency 'rb-fsevent', '~> 0.9.0'
22
+
23
+
24
+ # Pragmatically set variables
25
+ s.homepage = "http://github.com/RyanScottLewis/#{s.name}"
26
+ s.version = Pathname.glob('VERSION*').first.read rescue '0.0.0'
27
+ s.description = s.summary
28
+ s.name = Pathname.new(__FILE__).basename('.gemspec').to_s
29
+ s.require_paths = ['lib']
30
+ s.files = Dir['{{Rake,Gem}file{.lock,},README*,VERSION,LICENSE,*.gemspec,lib/morris-rails{.rb,**/*.rb},spec/**/*.rb,app/**/*.*}']
31
+ s.test_files = Dir['{examples,spec,test}/**/*']
32
+
33
+ end
@@ -0,0 +1,84 @@
1
+ require 'parslet'
2
+
3
+ # class IndentationSensitiveParser < Parslet::Parser
4
+ #
5
+ # rule(:indent) { str(' ') }
6
+ # rule(:newline) { str("\n") }
7
+ # rule(:identifier) { match['A-Za-z0-9'].repeat.as(:identifier) }
8
+ #
9
+ # rule(:node) { identifier >> newline >> (indent >> identifier >> newline.maybe).repeat.as(:children) }
10
+ #
11
+ # rule(:document) { node.repeat }
12
+ #
13
+ # root :document
14
+ #
15
+ # end
16
+
17
+ # class IndentationSensitiveParser < Parslet::Parser
18
+ #
19
+ # def initialize
20
+ # @indentation_size
21
+ # end
22
+ #
23
+ # rule(:space) { str(' ') }
24
+ # rule(:indent) { str(' ') }
25
+ # rule(:newline) { str("\n") }
26
+ # rule(:identifier) { match['A-Za-z0-9'].repeat.as(:identifier) }
27
+ #
28
+ # rule(:node) { identifier >> newline >> (indent >> identifier >> newline.maybe).repeat.as(:children) }
29
+ #
30
+ # rule(:document) { node.repeat }
31
+ #
32
+ # root :document
33
+ #
34
+ # end
35
+
36
+ class IndentationSensitiveParser < Parslet::Parser
37
+
38
+ def indent(depth)
39
+ str(' ' * depth)
40
+ end
41
+
42
+ rule(:newline) { str("\n") }
43
+
44
+ rule(:identifier) { match['A-Za-z0-9'].repeat(1).as(:identifier) }
45
+
46
+ def node(depth)
47
+ indent(depth) >> identifier >> newline.maybe >>
48
+ (
49
+ dynamic { |soutce, context| node(depth+1).repeat(0) }
50
+ ).as(:children)
51
+ end
52
+
53
+ rule(:document) { node(0).repeat }
54
+
55
+ root :document
56
+ end
57
+
58
+ require 'ap'
59
+ require 'pp'
60
+
61
+ begin
62
+ input = DATA.read
63
+
64
+ puts '', '----- input ----------------------------------------------------------------------', ''
65
+ ap input
66
+
67
+ tree = IndentationSensitiveParser.new.parse(input)
68
+
69
+ puts '', '----- tree -----------------------------------------------------------------------', ''
70
+ pp tree
71
+
72
+ rescue IndentationSensitiveParser::ParseFailed => failure
73
+ puts '', '----- error ----------------------------------------------------------------------', ''
74
+ puts failure.cause.ascii_tree
75
+ end
76
+
77
+ __END__
78
+ level0child0
79
+ level0child1
80
+ level1child0
81
+ level1child1
82
+ level2child0
83
+ level1child2
84
+ level0child3
@@ -0,0 +1,31 @@
1
+ require 'arst'
2
+
3
+ require 'ap'
4
+ require 'pp'
5
+
6
+ begin
7
+ input = DATA.read
8
+
9
+ puts '', '----- input ----------------------------------------------------------------------', ''
10
+ ap input
11
+
12
+ tree = ARST.parse(input)
13
+
14
+ puts '', '----- tree -----------------------------------------------------------------------', ''
15
+ ap tree
16
+
17
+ rescue ARST::Parser::ParseFailed => failure
18
+ puts '', '----- error ----------------------------------------------------------------------', ''
19
+ puts failure.cause.ascii_tree
20
+ end
21
+
22
+ __END__
23
+ module Test
24
+ class Bar
25
+ module Foo
26
+ module Baz
27
+ module Qux
28
+ module NoWai
29
+ module UserSystem
30
+ class User
31
+ class Admin < User
metadata ADDED
@@ -0,0 +1,208 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arst
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Scott Lewis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: active_support
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: parslet
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.5.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: version
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: awesome_print
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.1.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.1.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: cocaine
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.5.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.5.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: guard-bundler
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.0.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: guard-shell
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.5.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.5.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: rake
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 10.0.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 10.0.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: rb-fsevent
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 0.9.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.9.0
158
+ description: Abstract Ruby Syntax Tree (ARST) is a high-level language syntax denoting
159
+ the object domain of a Ruby project.
160
+ email: ryan@rynet.us
161
+ executables: []
162
+ extensions: []
163
+ extra_rdoc_files: []
164
+ files:
165
+ - Rakefile
166
+ - Gemfile.lock
167
+ - Gemfile
168
+ - README.md
169
+ - VERSION
170
+ - LICENSE
171
+ - arst.gemspec
172
+ - examples/indentation_sensitive.rb
173
+ - examples/simple.rb
174
+ homepage: http://github.com/RyanScottLewis/
175
+ licenses:
176
+ - MIT
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ segments:
188
+ - 0
189
+ hash: 1607695465800406566
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ segments:
197
+ - 0
198
+ hash: 1607695465800406566
199
+ requirements: []
200
+ rubyforge_project:
201
+ rubygems_version: 1.8.25
202
+ signing_key:
203
+ specification_version: 3
204
+ summary: Abstract Ruby Syntax Tree (ARST) is a high-level language syntax denoting
205
+ the object domain of a Ruby project.
206
+ test_files:
207
+ - examples/indentation_sensitive.rb
208
+ - examples/simple.rb