laser 0.7.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/LICENSE +661 -0
- data/README.md +158 -0
- data/Rakefile +104 -0
- data/VERSION +1 -0
- data/bin/laser +7 -0
- data/design_docs/goals.md +57 -0
- data/design_docs/object_regex.md +426 -0
- data/design_docs/type_annotations.md +80 -0
- data/ext/laser/BasicBlock.cpp +572 -0
- data/ext/laser/BasicBlock.h +118 -0
- data/ext/laser/extconf.rb +3 -0
- data/features/laser.feature +25 -0
- data/features/step_definitions/laser_steps.rb +39 -0
- data/features/support/env.rb +14 -0
- data/features/support/testdata/1_input +1 -0
- data/features/support/testdata/1_output +1 -0
- data/features/support/testdata/2_input +4 -0
- data/features/support/testdata/2_output +4 -0
- data/features/support/testdata/3_input +8 -0
- data/features/support/testdata/3_output +11 -0
- data/features/support/testdata/4_input +5 -0
- data/features/support/testdata/4_output +5 -0
- data/features/support/testdata/5_input +13 -0
- data/laser.gemspec +382 -0
- data/lib/laser.rb +98 -0
- data/lib/laser/analysis/annotations.rb +95 -0
- data/lib/laser/analysis/annotations/annotation_config.yaml +3 -0
- data/lib/laser/analysis/annotations/comment_attachment_annotation.rb +66 -0
- data/lib/laser/analysis/annotations/node_pointers_annotation.rb +36 -0
- data/lib/laser/analysis/annotations/runtime_annotation.rb +55 -0
- data/lib/laser/analysis/argument_expansion.rb +132 -0
- data/lib/laser/analysis/arity.rb +34 -0
- data/lib/laser/analysis/bindings.rb +144 -0
- data/lib/laser/analysis/bootstrap/bootstrap.rb +298 -0
- data/lib/laser/analysis/bootstrap/laser_class.rb +106 -0
- data/lib/laser/analysis/bootstrap/laser_method.rb +255 -0
- data/lib/laser/analysis/bootstrap/laser_module.rb +403 -0
- data/lib/laser/analysis/bootstrap/laser_module_copy.rb +74 -0
- data/lib/laser/analysis/bootstrap/laser_object.rb +69 -0
- data/lib/laser/analysis/bootstrap/laser_proc.rb +150 -0
- data/lib/laser/analysis/bootstrap/laser_singleton_class.rb +44 -0
- data/lib/laser/analysis/comments.rb +35 -0
- data/lib/laser/analysis/control_flow.rb +28 -0
- data/lib/laser/analysis/control_flow/alias_analysis.rb +31 -0
- data/lib/laser/analysis/control_flow/basic_block.rb +105 -0
- data/lib/laser/analysis/control_flow/cfg_builder.rb +2505 -0
- data/lib/laser/analysis/control_flow/cfg_instruction.rb +190 -0
- data/lib/laser/analysis/control_flow/constant_propagation.rb +742 -0
- data/lib/laser/analysis/control_flow/control_flow_graph.rb +370 -0
- data/lib/laser/analysis/control_flow/lifetime_analysis.rb +91 -0
- data/lib/laser/analysis/control_flow/method_call_search.rb +26 -0
- data/lib/laser/analysis/control_flow/raise_properties.rb +25 -0
- data/lib/laser/analysis/control_flow/simulation.rb +385 -0
- data/lib/laser/analysis/control_flow/static_single_assignment.rb +185 -0
- data/lib/laser/analysis/control_flow/unreachability_analysis.rb +57 -0
- data/lib/laser/analysis/control_flow/unused_variables.rb +91 -0
- data/lib/laser/analysis/control_flow/yield_properties.rb +103 -0
- data/lib/laser/analysis/errors.rb +131 -0
- data/lib/laser/analysis/laser_utils.rb +18 -0
- data/lib/laser/analysis/lexical_analysis.rb +172 -0
- data/lib/laser/analysis/method_call.rb +68 -0
- data/lib/laser/analysis/protocol_registry.rb +30 -0
- data/lib/laser/analysis/scope.rb +118 -0
- data/lib/laser/analysis/sexp.rb +159 -0
- data/lib/laser/analysis/sexp_analysis.rb +40 -0
- data/lib/laser/analysis/sexp_extensions/constant_extraction.rb +115 -0
- data/lib/laser/analysis/sexp_extensions/source_location.rb +164 -0
- data/lib/laser/analysis/sexp_extensions/type_inference.rb +47 -0
- data/lib/laser/analysis/signature.rb +76 -0
- data/lib/laser/analysis/special_methods/send.rb +67 -0
- data/lib/laser/analysis/unused_methods.rb +21 -0
- data/lib/laser/analysis/visitor.rb +141 -0
- data/lib/laser/annotation_parser/annotations.treetop +126 -0
- data/lib/laser/annotation_parser/annotations_parser.rb +748 -0
- data/lib/laser/annotation_parser/class_annotations.treetop +82 -0
- data/lib/laser/annotation_parser/class_annotations_parser.rb +654 -0
- data/lib/laser/annotation_parser/overload.treetop +24 -0
- data/lib/laser/annotation_parser/overload_parser.rb +167 -0
- data/lib/laser/annotation_parser/parsers.rb +6 -0
- data/lib/laser/annotation_parser/structural.treetop +37 -0
- data/lib/laser/annotation_parser/structural_parser.rb +406 -0
- data/lib/laser/annotation_parser/useful_parsers.treetop +47 -0
- data/lib/laser/annotation_parser/useful_parsers_parser.rb +674 -0
- data/lib/laser/rake/task.rb +46 -0
- data/lib/laser/runner.rb +189 -0
- data/lib/laser/scanner.rb +169 -0
- data/lib/laser/standard_library/_thread.rb +110 -0
- data/lib/laser/standard_library/abbrev.rb +103 -0
- data/lib/laser/standard_library/array.rb +418 -0
- data/lib/laser/standard_library/base64.rb +91 -0
- data/lib/laser/standard_library/basic_object.rb +55 -0
- data/lib/laser/standard_library/benchmark.rb +556 -0
- data/lib/laser/standard_library/bignum.rb +185 -0
- data/lib/laser/standard_library/cgi.rb +275 -0
- data/lib/laser/standard_library/cgi/cookie.rb +147 -0
- data/lib/laser/standard_library/cgi/core.rb +791 -0
- data/lib/laser/standard_library/cgi/html.rb +1021 -0
- data/lib/laser/standard_library/cgi/session.rb +537 -0
- data/lib/laser/standard_library/cgi/session/pstore.rb +111 -0
- data/lib/laser/standard_library/cgi/util.rb +188 -0
- data/lib/laser/standard_library/class_definitions.rb +333 -0
- data/lib/laser/standard_library/comparable.rb +125 -0
- data/lib/laser/standard_library/complex.rb +162 -0
- data/lib/laser/standard_library/enumerable.rb +178 -0
- data/lib/laser/standard_library/exceptions.rb +135 -0
- data/lib/laser/standard_library/fixnum.rb +188 -0
- data/lib/laser/standard_library/float.rb +180 -0
- data/lib/laser/standard_library/hash.rb +237 -0
- data/lib/laser/standard_library/integer.rb +123 -0
- data/lib/laser/standard_library/laser_magic.rb +7 -0
- data/lib/laser/standard_library/nil_false_true.rb +113 -0
- data/lib/laser/standard_library/numbers.rb +192 -0
- data/lib/laser/standard_library/proc.rb +31 -0
- data/lib/laser/standard_library/set.rb +1348 -0
- data/lib/laser/standard_library/string.rb +666 -0
- data/lib/laser/standard_library/stringio.rb +2 -0
- data/lib/laser/standard_library/symbol.rb +125 -0
- data/lib/laser/standard_library/tsort.rb +242 -0
- data/lib/laser/support/acts_as_struct.rb +66 -0
- data/lib/laser/support/frequency.rb +55 -0
- data/lib/laser/support/inheritable_attributes.rb +145 -0
- data/lib/laser/support/module_extensions.rb +94 -0
- data/lib/laser/support/placeholder_object.rb +13 -0
- data/lib/laser/third_party/rgl/adjacency.rb +221 -0
- data/lib/laser/third_party/rgl/base.rb +228 -0
- data/lib/laser/third_party/rgl/bidirectional.rb +39 -0
- data/lib/laser/third_party/rgl/condensation.rb +47 -0
- data/lib/laser/third_party/rgl/connected_components.rb +138 -0
- data/lib/laser/third_party/rgl/control_flow.rb +170 -0
- data/lib/laser/third_party/rgl/depth_first_spanning_tree.rb +37 -0
- data/lib/laser/third_party/rgl/dominators.rb +124 -0
- data/lib/laser/third_party/rgl/dot.rb +93 -0
- data/lib/laser/third_party/rgl/graphxml.rb +51 -0
- data/lib/laser/third_party/rgl/implicit.rb +174 -0
- data/lib/laser/third_party/rgl/mutable.rb +117 -0
- data/lib/laser/third_party/rgl/rdot.rb +445 -0
- data/lib/laser/third_party/rgl/topsort.rb +72 -0
- data/lib/laser/third_party/rgl/transitivity.rb +180 -0
- data/lib/laser/third_party/rgl/traversal.rb +348 -0
- data/lib/laser/types/types.rb +433 -0
- data/lib/laser/version.rb +14 -0
- data/lib/laser/warning.rb +149 -0
- data/lib/laser/warning_sets/default.yml +13 -0
- data/lib/laser/warnings/assignment_in_condition.rb +20 -0
- data/lib/laser/warnings/comment_spacing.rb +31 -0
- data/lib/laser/warnings/extra_blank_lines.rb +30 -0
- data/lib/laser/warnings/extra_whitespace.rb +16 -0
- data/lib/laser/warnings/hash_symbol_18_warning.rb +63 -0
- data/lib/laser/warnings/hash_symbol_19_warning.rb +29 -0
- data/lib/laser/warnings/line_length.rb +115 -0
- data/lib/laser/warnings/misaligned_unindentation.rb +17 -0
- data/lib/laser/warnings/operator_spacing.rb +68 -0
- data/lib/laser/warnings/parens_on_declaration.rb +30 -0
- data/lib/laser/warnings/rescue_exception.rb +42 -0
- data/lib/laser/warnings/semicolon.rb +25 -0
- data/lib/laser/warnings/sexp_errors.rb +24 -0
- data/lib/laser/warnings/uncalled_method_warning.rb +7 -0
- data/lib/laser/warnings/useless_double_quotes.rb +38 -0
- data/spec/analysis_specs/annotations_spec.rb +47 -0
- data/spec/analysis_specs/annotations_specs/comment_attachment_spec.rb +68 -0
- data/spec/analysis_specs/annotations_specs/node_pointers_annotation_spec.rb +90 -0
- data/spec/analysis_specs/annotations_specs/runtime_annotation_spec.rb +135 -0
- data/spec/analysis_specs/annotations_specs/spec_helper.rb +33 -0
- data/spec/analysis_specs/argument_expansion_spec.rb +113 -0
- data/spec/analysis_specs/bindings_spec.rb +36 -0
- data/spec/analysis_specs/comment_spec.rb +93 -0
- data/spec/analysis_specs/control_flow_specs/cfg_instruction_spec.rb +111 -0
- data/spec/analysis_specs/control_flow_specs/constant_propagation_spec.rb +560 -0
- data/spec/analysis_specs/control_flow_specs/control_flow_graph_spec.rb +5 -0
- data/spec/analysis_specs/control_flow_specs/raise_properties_spec.rb +310 -0
- data/spec/analysis_specs/control_flow_specs/raise_type_inference_spec.rb +301 -0
- data/spec/analysis_specs/control_flow_specs/return_type_inference_spec.rb +431 -0
- data/spec/analysis_specs/control_flow_specs/simulation_spec.rb +158 -0
- data/spec/analysis_specs/control_flow_specs/spec_helper.rb +110 -0
- data/spec/analysis_specs/control_flow_specs/tuple_misuse_inference_spec.rb +125 -0
- data/spec/analysis_specs/control_flow_specs/unreachability_analysis_spec.rb +76 -0
- data/spec/analysis_specs/control_flow_specs/unused_variable_spec.rb +99 -0
- data/spec/analysis_specs/control_flow_specs/yield_properties_spec.rb +372 -0
- data/spec/analysis_specs/error_spec.rb +30 -0
- data/spec/analysis_specs/laser_class_spec.rb +322 -0
- data/spec/analysis_specs/lexical_analysis_spec.rb +184 -0
- data/spec/analysis_specs/protocol_registry_spec.rb +63 -0
- data/spec/analysis_specs/scope_annotation_spec.rb +1013 -0
- data/spec/analysis_specs/scope_spec.rb +126 -0
- data/spec/analysis_specs/sexp_analysis_spec.rb +30 -0
- data/spec/analysis_specs/sexp_extension_specs/constant_extraction_spec.rb +309 -0
- data/spec/analysis_specs/sexp_extension_specs/source_location_spec.rb +231 -0
- data/spec/analysis_specs/sexp_extension_specs/spec_helper.rb +1 -0
- data/spec/analysis_specs/sexp_extension_specs/type_inference_spec.rb +252 -0
- data/spec/analysis_specs/sexp_spec.rb +167 -0
- data/spec/analysis_specs/spec_helper.rb +27 -0
- data/spec/analysis_specs/unused_methods_spec.rb +65 -0
- data/spec/analysis_specs/visitor_spec.rb +64 -0
- data/spec/annotation_parser_specs/annotations_parser_spec.rb +89 -0
- data/spec/annotation_parser_specs/class_annotation_parser_spec.rb +120 -0
- data/spec/annotation_parser_specs/overload_parser_spec.rb +39 -0
- data/spec/annotation_parser_specs/parsers_spec.rb +14 -0
- data/spec/annotation_parser_specs/spec_helper.rb +1 -0
- data/spec/annotation_parser_specs/structural_parser_spec.rb +67 -0
- data/spec/laser_spec.rb +14 -0
- data/spec/rake_specs/spec_helper.rb +1 -0
- data/spec/rake_specs/task_spec.rb +67 -0
- data/spec/runner_spec.rb +207 -0
- data/spec/scanner_spec.rb +75 -0
- data/spec/spec_helper.rb +121 -0
- data/spec/standard_library/exceptions_spec.rb +19 -0
- data/spec/standard_library/globals_spec.rb +14 -0
- data/spec/standard_library/set_spec.rb +31 -0
- data/spec/standard_library/spec_helper.rb +1 -0
- data/spec/standard_library/standard_library_spec.rb +302 -0
- data/spec/support_specs/acts_as_struct_spec.rb +94 -0
- data/spec/support_specs/frequency_spec.rb +23 -0
- data/spec/support_specs/module_extensions_spec.rb +117 -0
- data/spec/support_specs/spec_helper.rb +1 -0
- data/spec/type_specs/spec_helper.rb +1 -0
- data/spec/type_specs/types_spec.rb +133 -0
- data/spec/warning_spec.rb +95 -0
- data/spec/warning_specs/assignment_in_condition_spec.rb +68 -0
- data/spec/warning_specs/comment_spacing_spec.rb +65 -0
- data/spec/warning_specs/extra_blank_lines_spec.rb +70 -0
- data/spec/warning_specs/extra_whitespace_spec.rb +33 -0
- data/spec/warning_specs/hash_symbol_18_warning_spec.rb +89 -0
- data/spec/warning_specs/hash_symbol_19_warning_spec.rb +63 -0
- data/spec/warning_specs/line_length_spec.rb +173 -0
- data/spec/warning_specs/misaligned_unindentation_spec.rb +35 -0
- data/spec/warning_specs/operator_spacing_spec.rb +104 -0
- data/spec/warning_specs/parens_on_declaration_spec.rb +57 -0
- data/spec/warning_specs/rescue_exception_spec.rb +105 -0
- data/spec/warning_specs/semicolon_spec.rb +58 -0
- data/spec/warning_specs/spec_helper.rb +1 -0
- data/spec/warning_specs/useless_double_quotes_spec.rb +74 -0
- data/status_reports/2010/12/2010-12-14.md +163 -0
- data/status_reports/2010/12/2010-12-23.md +298 -0
- data/status_reports/2010/12/2010-12-24.md +6 -0
- data/test/third_party_tests/rgl_tests/TestComponents.rb +65 -0
- data/test/third_party_tests/rgl_tests/TestCycles.rb +61 -0
- data/test/third_party_tests/rgl_tests/TestDirectedGraph.rb +125 -0
- data/test/third_party_tests/rgl_tests/TestDot.rb +18 -0
- data/test/third_party_tests/rgl_tests/TestEdge.rb +34 -0
- data/test/third_party_tests/rgl_tests/TestGraph.rb +71 -0
- data/test/third_party_tests/rgl_tests/TestGraphXML.rb +57 -0
- data/test/third_party_tests/rgl_tests/TestImplicit.rb +52 -0
- data/test/third_party_tests/rgl_tests/TestRdot.rb +863 -0
- data/test/third_party_tests/rgl_tests/TestTransitivity.rb +129 -0
- data/test/third_party_tests/rgl_tests/TestTraversal.rb +220 -0
- data/test/third_party_tests/rgl_tests/TestUnDirectedGraph.rb +102 -0
- data/test/third_party_tests/rgl_tests/examples/north/Graph.log +128 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.0.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.1.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.11.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.12.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.13.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.14.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.15.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.16.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.17.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.19.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.2.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.20.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.22.graphml +43 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.24.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.25.graphml +45 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.27.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.28.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.29.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.3.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.30.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.31.graphml +42 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.34.graphml +42 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.37.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.38.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.39.graphml +36 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.4.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.40.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.41.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.42.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.45.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.46.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.5.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.50.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.56.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.57.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.58.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.6.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.60.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.61.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.62.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.68.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.69.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.7.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.70.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.71.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.72.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.74.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.75.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.78.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.79.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.8.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.80.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.82.graphml +35 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.83.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.85.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.86.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.88.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.89.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.9.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.90.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.91.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.92.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.93.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.94.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.12.8.graphml +40 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.14.9.graphml +36 -0
- data/test/third_party_tests/rgl_tests/test_helper.rb +7 -0
- data/test/third_party_tests/test_inheritable_attributes.rb +187 -0
- metadata +470 -0
@@ -0,0 +1,185 @@
|
|
1
|
+
class Bignum < Integer
|
2
|
+
# pure: true
|
3
|
+
# builtin: true
|
4
|
+
# returns: Fixnum= | Bignum=
|
5
|
+
def %(num)
|
6
|
+
end
|
7
|
+
# pure: true
|
8
|
+
# builtin: true
|
9
|
+
# returns: Fixnum= | Bignum=
|
10
|
+
def &(num)
|
11
|
+
end
|
12
|
+
# pure: true
|
13
|
+
# builtin: true
|
14
|
+
# overload: (Float) -> Float=
|
15
|
+
# overload: (Fixnum) -> Fixnum= | Bignum=
|
16
|
+
# overload: (Bignum) -> Fixnum= | Bignum=
|
17
|
+
# raises: never
|
18
|
+
def *(num)
|
19
|
+
end
|
20
|
+
# pure: true
|
21
|
+
# builtin: true
|
22
|
+
def **(num)
|
23
|
+
end
|
24
|
+
# pure: true
|
25
|
+
# builtin: true
|
26
|
+
def +(num)
|
27
|
+
end
|
28
|
+
# pure: true
|
29
|
+
# builtin: true
|
30
|
+
def -(num)
|
31
|
+
end
|
32
|
+
# pure: true
|
33
|
+
# builtin: true
|
34
|
+
# returns: Fixnum= | Bignum=
|
35
|
+
# raises: never
|
36
|
+
def -@
|
37
|
+
end
|
38
|
+
# pure: true
|
39
|
+
# builtin: true
|
40
|
+
def /(num)
|
41
|
+
end
|
42
|
+
# pure: true
|
43
|
+
# builtin: true
|
44
|
+
# returns: Boolean
|
45
|
+
# num: Numeric
|
46
|
+
# raises: never
|
47
|
+
def <(num)
|
48
|
+
end
|
49
|
+
# pure: true
|
50
|
+
# builtin: true
|
51
|
+
# returns: Fixnum= | Bignum=
|
52
|
+
def <<(amt)
|
53
|
+
end
|
54
|
+
# pure: true
|
55
|
+
# builtin: true
|
56
|
+
# returns: Boolean
|
57
|
+
def <=(num)
|
58
|
+
end
|
59
|
+
# pure: true
|
60
|
+
# builtin: true
|
61
|
+
# returns: NilClass | Fixnum
|
62
|
+
def <=>(num)
|
63
|
+
end
|
64
|
+
# pure: true
|
65
|
+
# builtin: true
|
66
|
+
# returns: Boolean
|
67
|
+
def ==(num)
|
68
|
+
end
|
69
|
+
# pure: true
|
70
|
+
# builtin: true
|
71
|
+
# returns: Boolean
|
72
|
+
def ===(num)
|
73
|
+
end
|
74
|
+
# pure: true
|
75
|
+
# builtin: true
|
76
|
+
# returns: Boolean
|
77
|
+
# num: Numeric
|
78
|
+
# raises: never
|
79
|
+
def >(num)
|
80
|
+
end
|
81
|
+
# pure: true
|
82
|
+
# builtin: true
|
83
|
+
# returns: Boolean
|
84
|
+
def >=(num)
|
85
|
+
end
|
86
|
+
# pure: true
|
87
|
+
# builtin: true
|
88
|
+
# returns: Fixnum= | Bignum=
|
89
|
+
def >>(num)
|
90
|
+
end
|
91
|
+
# pure: true
|
92
|
+
# builtin: true
|
93
|
+
# returns: Fixnum= | Bignum=
|
94
|
+
def [](bit)
|
95
|
+
end
|
96
|
+
# pure: true
|
97
|
+
# builtin: true
|
98
|
+
# returns: Fixnum= | Bignum=
|
99
|
+
def ^(num)
|
100
|
+
end
|
101
|
+
# pure: true
|
102
|
+
# builtin: true
|
103
|
+
# returns: Fixnum= | Bignum=
|
104
|
+
# raises: never
|
105
|
+
def abs
|
106
|
+
end
|
107
|
+
# pure: true
|
108
|
+
# builtin: true
|
109
|
+
def coerce(numeric)
|
110
|
+
end
|
111
|
+
# pure: true
|
112
|
+
# builtin: true
|
113
|
+
# returns: Fixnum= | Bignum=
|
114
|
+
def div(other)
|
115
|
+
end
|
116
|
+
# pure: true
|
117
|
+
# builtin: true
|
118
|
+
def divmod(other)
|
119
|
+
end
|
120
|
+
# pure: true
|
121
|
+
# builtin: true
|
122
|
+
# returns: Boolean
|
123
|
+
def eql?(other)
|
124
|
+
end
|
125
|
+
# pure: true
|
126
|
+
# builtin: true
|
127
|
+
# returns: Boolean
|
128
|
+
# raises: never
|
129
|
+
def even?
|
130
|
+
end
|
131
|
+
# pure: true
|
132
|
+
# builtin: true
|
133
|
+
def fdiv(num)
|
134
|
+
end
|
135
|
+
# pure: true
|
136
|
+
# builtin: true
|
137
|
+
# returns: Fixnum= | Bignum=
|
138
|
+
# raises: never
|
139
|
+
def magnitude
|
140
|
+
end
|
141
|
+
# pure: true
|
142
|
+
# builtin: true
|
143
|
+
# returns: Fixnum= | Bignum=
|
144
|
+
def modulo(num)
|
145
|
+
end
|
146
|
+
# pure: true
|
147
|
+
# builtin: true
|
148
|
+
# returns: Boolean
|
149
|
+
# raises: never
|
150
|
+
def odd?
|
151
|
+
end
|
152
|
+
# pure: true
|
153
|
+
# builtin: true
|
154
|
+
def remainder(other)
|
155
|
+
end
|
156
|
+
# pure: true
|
157
|
+
# builtin: true
|
158
|
+
# returns: Fixnum= | Bignum=
|
159
|
+
# raises: never
|
160
|
+
def size
|
161
|
+
end
|
162
|
+
# pure: true
|
163
|
+
# builtin: true
|
164
|
+
# returns: Float
|
165
|
+
# raises: never
|
166
|
+
def to_f
|
167
|
+
end
|
168
|
+
# pure: true
|
169
|
+
# builtin: true
|
170
|
+
# returns: String
|
171
|
+
# raises: never
|
172
|
+
def to_s
|
173
|
+
end
|
174
|
+
# pure: true
|
175
|
+
# builtin: true
|
176
|
+
# returns: Fixnum= | Bignum=
|
177
|
+
def |(num)
|
178
|
+
end
|
179
|
+
# pure: true
|
180
|
+
# builtin: true
|
181
|
+
# returns: Fixnum= | Bignum=
|
182
|
+
# raises: never
|
183
|
+
def ~
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,275 @@
|
|
1
|
+
#
|
2
|
+
# cgi.rb - cgi support library
|
3
|
+
#
|
4
|
+
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
|
5
|
+
#
|
6
|
+
# Copyright (C) 2000 Information-technology Promotion Agency, Japan
|
7
|
+
#
|
8
|
+
# Author: Wakou Aoyama <wakou@ruby-lang.org>
|
9
|
+
#
|
10
|
+
# Documentation: Wakou Aoyama (RDoc'd and embellished by William Webber)
|
11
|
+
#
|
12
|
+
# == Overview
|
13
|
+
#
|
14
|
+
# The Common Gateway Interface (CGI) is a simple protocol
|
15
|
+
# for passing an HTTP request from a web server to a
|
16
|
+
# standalone program, and returning the output to the web
|
17
|
+
# browser. Basically, a CGI program is called with the
|
18
|
+
# parameters of the request passed in either in the
|
19
|
+
# environment (GET) or via $stdin (POST), and everything
|
20
|
+
# it prints to $stdout is returned to the client.
|
21
|
+
#
|
22
|
+
# This file holds the +CGI+ class. This class provides
|
23
|
+
# functionality for retrieving HTTP request parameters,
|
24
|
+
# managing cookies, and generating HTML output. See the
|
25
|
+
# class documentation for more details and examples of use.
|
26
|
+
#
|
27
|
+
# The file cgi/session.rb provides session management
|
28
|
+
# functionality; see that file for more details.
|
29
|
+
#
|
30
|
+
# See http://www.w3.org/CGI/ for more information on the CGI
|
31
|
+
# protocol.
|
32
|
+
|
33
|
+
raise "Please, use ruby 1.9.0 or later." if RUBY_VERSION < "1.9.0"
|
34
|
+
|
35
|
+
# CGI class. See documentation for the file cgi.rb for an overview
|
36
|
+
# of the CGI protocol.
|
37
|
+
#
|
38
|
+
# == Introduction
|
39
|
+
#
|
40
|
+
# CGI is a large class, providing several categories of methods, many of which
|
41
|
+
# are mixed in from other modules. Some of the documentation is in this class,
|
42
|
+
# some in the modules CGI::QueryExtension and CGI::HtmlExtension. See
|
43
|
+
# CGI::Cookie for specific information on handling cookies, and cgi/session.rb
|
44
|
+
# (CGI::Session) for information on sessions.
|
45
|
+
#
|
46
|
+
# For queries, CGI provides methods to get at environmental variables,
|
47
|
+
# parameters, cookies, and multipart request data. For responses, CGI provides
|
48
|
+
# methods for writing output and generating HTML.
|
49
|
+
#
|
50
|
+
# Read on for more details. Examples are provided at the bottom.
|
51
|
+
#
|
52
|
+
# == Queries
|
53
|
+
#
|
54
|
+
# The CGI class dynamically mixes in parameter and cookie-parsing
|
55
|
+
# functionality, environmental variable access, and support for
|
56
|
+
# parsing multipart requests (including uploaded files) from the
|
57
|
+
# CGI::QueryExtension module.
|
58
|
+
#
|
59
|
+
# === Environmental Variables
|
60
|
+
#
|
61
|
+
# The standard CGI environmental variables are available as read-only
|
62
|
+
# attributes of a CGI object. The following is a list of these variables:
|
63
|
+
#
|
64
|
+
#
|
65
|
+
# AUTH_TYPE HTTP_HOST REMOTE_IDENT
|
66
|
+
# CONTENT_LENGTH HTTP_NEGOTIATE REMOTE_USER
|
67
|
+
# CONTENT_TYPE HTTP_PRAGMA REQUEST_METHOD
|
68
|
+
# GATEWAY_INTERFACE HTTP_REFERER SCRIPT_NAME
|
69
|
+
# HTTP_ACCEPT HTTP_USER_AGENT SERVER_NAME
|
70
|
+
# HTTP_ACCEPT_CHARSET PATH_INFO SERVER_PORT
|
71
|
+
# HTTP_ACCEPT_ENCODING PATH_TRANSLATED SERVER_PROTOCOL
|
72
|
+
# HTTP_ACCEPT_LANGUAGE QUERY_STRING SERVER_SOFTWARE
|
73
|
+
# HTTP_CACHE_CONTROL REMOTE_ADDR
|
74
|
+
# HTTP_FROM REMOTE_HOST
|
75
|
+
#
|
76
|
+
#
|
77
|
+
# For each of these variables, there is a corresponding attribute with the
|
78
|
+
# same name, except all lower case and without a preceding HTTP_.
|
79
|
+
# +content_length+ and +server_port+ are integers; the rest are strings.
|
80
|
+
#
|
81
|
+
# === Parameters
|
82
|
+
#
|
83
|
+
# The method #params() returns a hash of all parameters in the request as
|
84
|
+
# name/value-list pairs, where the value-list is an Array of one or more
|
85
|
+
# values. The CGI object itself also behaves as a hash of parameter names
|
86
|
+
# to values, but only returns a single value (as a String) for each
|
87
|
+
# parameter name.
|
88
|
+
#
|
89
|
+
# For instance, suppose the request contains the parameter
|
90
|
+
# "favourite_colours" with the multiple values "blue" and "green". The
|
91
|
+
# following behaviour would occur:
|
92
|
+
#
|
93
|
+
# cgi.params["favourite_colours"] # => ["blue", "green"]
|
94
|
+
# cgi["favourite_colours"] # => "blue"
|
95
|
+
#
|
96
|
+
# If a parameter does not exist, the former method will return an empty
|
97
|
+
# array, the latter an empty string. The simplest way to test for existence
|
98
|
+
# of a parameter is by the #has_key? method.
|
99
|
+
#
|
100
|
+
# === Cookies
|
101
|
+
#
|
102
|
+
# HTTP Cookies are automatically parsed from the request. They are available
|
103
|
+
# from the #cookies() accessor, which returns a hash from cookie name to
|
104
|
+
# CGI::Cookie object.
|
105
|
+
#
|
106
|
+
# === Multipart requests
|
107
|
+
#
|
108
|
+
# If a request's method is POST and its content type is multipart/form-data,
|
109
|
+
# then it may contain uploaded files. These are stored by the QueryExtension
|
110
|
+
# module in the parameters of the request. The parameter name is the name
|
111
|
+
# attribute of the file input field, as usual. However, the value is not
|
112
|
+
# a string, but an IO object, either an IOString for small files, or a
|
113
|
+
# Tempfile for larger ones. This object also has the additional singleton
|
114
|
+
# methods:
|
115
|
+
#
|
116
|
+
# #local_path():: the path of the uploaded file on the local filesystem
|
117
|
+
# #original_filename():: the name of the file on the client computer
|
118
|
+
# #content_type():: the content type of the file
|
119
|
+
#
|
120
|
+
# == Responses
|
121
|
+
#
|
122
|
+
# The CGI class provides methods for sending header and content output to
|
123
|
+
# the HTTP client, and mixes in methods for programmatic HTML generation
|
124
|
+
# from CGI::HtmlExtension and CGI::TagMaker modules. The precise version of HTML
|
125
|
+
# to use for HTML generation is specified at object creation time.
|
126
|
+
#
|
127
|
+
# === Writing output
|
128
|
+
#
|
129
|
+
# The simplest way to send output to the HTTP client is using the #out() method.
|
130
|
+
# This takes the HTTP headers as a hash parameter, and the body content
|
131
|
+
# via a block. The headers can be generated as a string using the #header()
|
132
|
+
# method. The output stream can be written directly to using the #print()
|
133
|
+
# method.
|
134
|
+
#
|
135
|
+
# === Generating HTML
|
136
|
+
#
|
137
|
+
# Each HTML element has a corresponding method for generating that
|
138
|
+
# element as a String. The name of this method is the same as that
|
139
|
+
# of the element, all lowercase. The attributes of the element are
|
140
|
+
# passed in as a hash, and the body as a no-argument block that evaluates
|
141
|
+
# to a String. The HTML generation module knows which elements are
|
142
|
+
# always empty, and silently drops any passed-in body. It also knows
|
143
|
+
# which elements require matching closing tags and which don't. However,
|
144
|
+
# it does not know what attributes are legal for which elements.
|
145
|
+
#
|
146
|
+
# There are also some additional HTML generation methods mixed in from
|
147
|
+
# the CGI::HtmlExtension module. These include individual methods for the
|
148
|
+
# different types of form inputs, and methods for elements that commonly
|
149
|
+
# take particular attributes where the attributes can be directly specified
|
150
|
+
# as arguments, rather than via a hash.
|
151
|
+
#
|
152
|
+
# == Examples of use
|
153
|
+
#
|
154
|
+
# === Get form values
|
155
|
+
#
|
156
|
+
# require "cgi"
|
157
|
+
# cgi = CGI.new
|
158
|
+
# value = cgi['field_name'] # <== value string for 'field_name'
|
159
|
+
# # if not 'field_name' included, then return "".
|
160
|
+
# fields = cgi.keys # <== array of field names
|
161
|
+
#
|
162
|
+
# # returns true if form has 'field_name'
|
163
|
+
# cgi.has_key?('field_name')
|
164
|
+
# cgi.has_key?('field_name')
|
165
|
+
# cgi.include?('field_name')
|
166
|
+
#
|
167
|
+
# CAUTION! cgi['field_name'] returned an Array with the old
|
168
|
+
# cgi.rb(included in ruby 1.6)
|
169
|
+
#
|
170
|
+
# === Get form values as hash
|
171
|
+
#
|
172
|
+
# require "cgi"
|
173
|
+
# cgi = CGI.new
|
174
|
+
# params = cgi.params
|
175
|
+
#
|
176
|
+
# cgi.params is a hash.
|
177
|
+
#
|
178
|
+
# cgi.params['new_field_name'] = ["value"] # add new param
|
179
|
+
# cgi.params['field_name'] = ["new_value"] # change value
|
180
|
+
# cgi.params.delete('field_name') # delete param
|
181
|
+
# cgi.params.clear # delete all params
|
182
|
+
#
|
183
|
+
#
|
184
|
+
# === Save form values to file
|
185
|
+
#
|
186
|
+
# require "pstore"
|
187
|
+
# db = PStore.new("query.db")
|
188
|
+
# db.transaction do
|
189
|
+
# db["params"] = cgi.params
|
190
|
+
# end
|
191
|
+
#
|
192
|
+
#
|
193
|
+
# === Restore form values from file
|
194
|
+
#
|
195
|
+
# require "pstore"
|
196
|
+
# db = PStore.new("query.db")
|
197
|
+
# db.transaction do
|
198
|
+
# cgi.params = db["params"]
|
199
|
+
# end
|
200
|
+
#
|
201
|
+
#
|
202
|
+
# === Get multipart form values
|
203
|
+
#
|
204
|
+
# require "cgi"
|
205
|
+
# cgi = CGI.new
|
206
|
+
# value = cgi['field_name'] # <== value string for 'field_name'
|
207
|
+
# value.read # <== body of value
|
208
|
+
# value.local_path # <== path to local file of value
|
209
|
+
# value.original_filename # <== original filename of value
|
210
|
+
# value.content_type # <== content_type of value
|
211
|
+
#
|
212
|
+
# and value has StringIO or Tempfile class methods.
|
213
|
+
#
|
214
|
+
# === Get cookie values
|
215
|
+
#
|
216
|
+
# require "cgi"
|
217
|
+
# cgi = CGI.new
|
218
|
+
# values = cgi.cookies['name'] # <== array of 'name'
|
219
|
+
# # if not 'name' included, then return [].
|
220
|
+
# names = cgi.cookies.keys # <== array of cookie names
|
221
|
+
#
|
222
|
+
# and cgi.cookies is a hash.
|
223
|
+
#
|
224
|
+
# === Get cookie objects
|
225
|
+
#
|
226
|
+
# require "cgi"
|
227
|
+
# cgi = CGI.new
|
228
|
+
# for name, cookie in cgi.cookies
|
229
|
+
# cookie.expires = Time.now + 30
|
230
|
+
# end
|
231
|
+
# cgi.out("cookie" => cgi.cookies) {"string"}
|
232
|
+
#
|
233
|
+
# cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
|
234
|
+
#
|
235
|
+
# require "cgi"
|
236
|
+
# cgi = CGI.new
|
237
|
+
# cgi.cookies['name'].expires = Time.now + 30
|
238
|
+
# cgi.out("cookie" => cgi.cookies['name']) {"string"}
|
239
|
+
#
|
240
|
+
# === Print http header and html string to $DEFAULT_OUTPUT ($>)
|
241
|
+
#
|
242
|
+
# require "cgi"
|
243
|
+
# cgi = CGI.new("html3") # add HTML generation methods
|
244
|
+
# cgi.out() do
|
245
|
+
# cgi.html() do
|
246
|
+
# cgi.head{ cgi.title{"TITLE"} } +
|
247
|
+
# cgi.body() do
|
248
|
+
# cgi.form() do
|
249
|
+
# cgi.textarea("get_text") +
|
250
|
+
# cgi.br +
|
251
|
+
# cgi.submit
|
252
|
+
# end +
|
253
|
+
# cgi.pre() do
|
254
|
+
# CGI::escapeHTML(
|
255
|
+
# "params: " + cgi.params.inspect + "\n" +
|
256
|
+
# "cookies: " + cgi.cookies.inspect + "\n" +
|
257
|
+
# ENV.collect() do |key, value|
|
258
|
+
# key + " --> " + value + "\n"
|
259
|
+
# end.join("")
|
260
|
+
# )
|
261
|
+
# end
|
262
|
+
# end
|
263
|
+
# end
|
264
|
+
# end
|
265
|
+
#
|
266
|
+
# # add HTML generation methods
|
267
|
+
# CGI.new("html3") # html3.2
|
268
|
+
# CGI.new("html4") # html4.01 (Strict)
|
269
|
+
# CGI.new("html4Tr") # html4.01 Transitional
|
270
|
+
# CGI.new("html4Fr") # html4.01 Frameset
|
271
|
+
#
|
272
|
+
require 'cgi/core'
|
273
|
+
require 'cgi/cookie'
|
274
|
+
require 'cgi/util'
|
275
|
+
CGI.autoload(:HtmlExtension, 'cgi/html')
|