webidl 0.0.3 → 0.0.4

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -7,20 +7,40 @@ module WebIDL
7
7
  @visitor = visitor
8
8
  end
9
9
 
10
- def generate(str)
10
+ def generate(input)
11
+ ast_defs = case input
12
+ when String
13
+ parse(input)
14
+ when Array
15
+ input.each do |e|
16
+ unless e.kind_of? WebIDL::Ast::Node
17
+ raise TypeError, "input Array elements must be of WebIDL::Ast::Node (got #{e.class})"
18
+ end
19
+ end
20
+
21
+ input
22
+ when WebIDL::Ast::Node
23
+ [input]
24
+ else
25
+ raise TypeError, "unexpected input #{input.class}"
26
+ end
27
+
28
+ strings = ast_defs.map { |definition| ruby2ruby.process definition.accept(visitor) }.compact
29
+ strings.join("\n\n")
30
+ end
31
+
32
+ private
33
+
34
+ def parse(str)
11
35
  parse_tree = parser.parse(str)
12
36
 
13
37
  if parse_tree.nil?
14
38
  raise ParseError, parser.failure_reason
15
39
  end
16
40
 
17
- ast_defs = parse_tree.build
18
- strings = ast_defs.map { |definition| ruby2ruby.process definition.accept(visitor) }.compact
19
- strings.join("\n\n")
41
+ parse_tree.build
20
42
  end
21
43
 
22
- private
23
-
24
44
  def ruby2ruby
25
45
  @ruby2ruby ||= Ruby2Ruby.new
26
46
  end
@@ -89,7 +89,7 @@ RUBY
89
89
  actual = generate(fixture("module_with_implements_statement.idl"))
90
90
  actual.should == expected
91
91
  end
92
-
92
+
93
93
  it "generates code for no-name setters, getters, creators, stringifier and deleters" do
94
94
  expected = <<-RUBY
95
95
  module Foo
@@ -110,8 +110,16 @@ module Foo
110
110
  end
111
111
  end
112
112
  RUBY
113
-
113
+
114
114
  actual = generate(fixture("interface_with_specials.idl"))
115
115
  actual.should == expected.strip
116
116
  end
117
+
118
+ it "accepts an array of AST nodes or a single AST node as input" do
119
+ ast_nodes = parse(fixture("module_with_implements_statement.idl")).build
120
+
121
+
122
+ lambda { generate(ast_nodes.first) }.should_not raise_error
123
+ lambda { generate(ast_nodes) }.should_not raise_error
124
+ end
117
125
  end
data/webidl.gemspec ADDED
@@ -0,0 +1,134 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{webidl}
8
+ s.version = "0.0.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jari Bakken"]
12
+ s.date = %q{2010-08-19}
13
+ s.default_executable = %q{webidl2ruby}
14
+ s.description = %q{Built on Treetop, this gem will parse an interface declaration in WebIDL and generate ruby code}
15
+ s.email = %q{jari.bakken@gmail.com}
16
+ s.executables = ["webidl2ruby"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/webidl2ruby",
29
+ "examples/html5.rb",
30
+ "lib/webidl.rb",
31
+ "lib/webidl/ast/argument.rb",
32
+ "lib/webidl/ast/attribute.rb",
33
+ "lib/webidl/ast/const.rb",
34
+ "lib/webidl/ast/exception.rb",
35
+ "lib/webidl/ast/extended_attribute.rb",
36
+ "lib/webidl/ast/field.rb",
37
+ "lib/webidl/ast/implements_statement.rb",
38
+ "lib/webidl/ast/interface.rb",
39
+ "lib/webidl/ast/module.rb",
40
+ "lib/webidl/ast/node.rb",
41
+ "lib/webidl/ast/operation.rb",
42
+ "lib/webidl/ast/scoped_name.rb",
43
+ "lib/webidl/ast/type.rb",
44
+ "lib/webidl/ast/typedef.rb",
45
+ "lib/webidl/extensions/string.rb",
46
+ "lib/webidl/extensions/syntax_node.rb",
47
+ "lib/webidl/generator.rb",
48
+ "lib/webidl/generator/ruby_sexp_visitor.rb",
49
+ "lib/webidl/parse_tree/absolute_scoped_name.rb",
50
+ "lib/webidl/parse_tree/argument.rb",
51
+ "lib/webidl/parse_tree/argument_list.rb",
52
+ "lib/webidl/parse_tree/attribute.rb",
53
+ "lib/webidl/parse_tree/const.rb",
54
+ "lib/webidl/parse_tree/definitions.rb",
55
+ "lib/webidl/parse_tree/exception.rb",
56
+ "lib/webidl/parse_tree/exception_field.rb",
57
+ "lib/webidl/parse_tree/extended_attributes.rb",
58
+ "lib/webidl/parse_tree/implements_statement.rb",
59
+ "lib/webidl/parse_tree/interface.rb",
60
+ "lib/webidl/parse_tree/interface_inheritance.rb",
61
+ "lib/webidl/parse_tree/interface_members.rb",
62
+ "lib/webidl/parse_tree/module.rb",
63
+ "lib/webidl/parse_tree/nullable_type.rb",
64
+ "lib/webidl/parse_tree/operation.rb",
65
+ "lib/webidl/parse_tree/relative_scoped_name.rb",
66
+ "lib/webidl/parse_tree/scoped_name_list.rb",
67
+ "lib/webidl/parse_tree/specials.rb",
68
+ "lib/webidl/parse_tree/stringifier_attribute_or_operation.rb",
69
+ "lib/webidl/parse_tree/type.rb",
70
+ "lib/webidl/parse_tree/typedef.rb",
71
+ "lib/webidl/parser/debug_helper.rb",
72
+ "lib/webidl/parser/idl.rb",
73
+ "lib/webidl/parser/idl.treetop",
74
+ "spec/ast_spec.rb",
75
+ "spec/fixtures/empty_interface.idl",
76
+ "spec/fixtures/empty_module.idl",
77
+ "spec/fixtures/framework.idl",
78
+ "spec/fixtures/html5.idl",
79
+ "spec/fixtures/interface_with_array_member.idl",
80
+ "spec/fixtures/interface_with_attribute.idl",
81
+ "spec/fixtures/interface_with_inheritance.idl",
82
+ "spec/fixtures/interface_with_members.idl",
83
+ "spec/fixtures/interface_with_specials.idl",
84
+ "spec/fixtures/interface_with_stringifiers.idl",
85
+ "spec/fixtures/module_with_exception.idl",
86
+ "spec/fixtures/module_with_implements_statement.idl",
87
+ "spec/fixtures/module_with_typedef.idl",
88
+ "spec/fixtures/module_with_xattr_ident.idl",
89
+ "spec/fixtures/module_with_xattr_named_args.idl",
90
+ "spec/fixtures/module_with_xattr_no_arg.idl",
91
+ "spec/fixtures/module_with_xattr_scoped.idl",
92
+ "spec/fixtures/module_with_xattr_two_args.idl",
93
+ "spec/fixtures/nested.idl",
94
+ "spec/fixtures/websocket.idl",
95
+ "spec/generator_spec.rb",
96
+ "spec/parser_spec.rb",
97
+ "spec/spec.opts",
98
+ "spec/spec_helper.rb",
99
+ "support/webidl-spec-2010-08-05.html",
100
+ "webidl.gemspec"
101
+ ]
102
+ s.homepage = %q{http://github.com/jarib/webidl}
103
+ s.rdoc_options = ["--charset=UTF-8"]
104
+ s.require_paths = ["lib"]
105
+ s.rubygems_version = %q{1.3.7}
106
+ s.summary = %q{WebIDL parser/generator for ruby}
107
+ s.test_files = [
108
+ "spec/ast_spec.rb",
109
+ "spec/generator_spec.rb",
110
+ "spec/parser_spec.rb",
111
+ "spec/spec_helper.rb",
112
+ "examples/html5.rb"
113
+ ]
114
+
115
+ if s.respond_to? :specification_version then
116
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
117
+ s.specification_version = 3
118
+
119
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
120
+ s.add_runtime_dependency(%q<treetop>, [">= 0"])
121
+ s.add_runtime_dependency(%q<ruby2ruby>, [">= 0"])
122
+ s.add_development_dependency(%q<rspec>, [">= 0"])
123
+ else
124
+ s.add_dependency(%q<treetop>, [">= 0"])
125
+ s.add_dependency(%q<ruby2ruby>, [">= 0"])
126
+ s.add_dependency(%q<rspec>, [">= 0"])
127
+ end
128
+ else
129
+ s.add_dependency(%q<treetop>, [">= 0"])
130
+ s.add_dependency(%q<ruby2ruby>, [">= 0"])
131
+ s.add_dependency(%q<rspec>, [">= 0"])
132
+ end
133
+ end
134
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webidl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jari Bakken
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-06 00:00:00 +02:00
18
+ date: 2010-08-19 00:00:00 +02:00
19
19
  default_executable: webidl2ruby
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -148,6 +148,7 @@ files:
148
148
  - spec/spec.opts
149
149
  - spec/spec_helper.rb
150
150
  - support/webidl-spec-2010-08-05.html
151
+ - webidl.gemspec
151
152
  has_rdoc: true
152
153
  homepage: http://github.com/jarib/webidl
153
154
  licenses: []
@@ -183,8 +184,8 @@ signing_key:
183
184
  specification_version: 3
184
185
  summary: WebIDL parser/generator for ruby
185
186
  test_files:
186
- - spec/parser_spec.rb
187
187
  - spec/ast_spec.rb
188
188
  - spec/generator_spec.rb
189
+ - spec/parser_spec.rb
189
190
  - spec/spec_helper.rb
190
191
  - examples/html5.rb