Permalink
Browse files

implementing generic code for dsl

  • Loading branch information...
1 parent 2d997f9 commit 79751353888b9e71e6a80af6b8a5fd2be776baf6 @shvets committed Oct 4, 2010
Showing with 166 additions and 64 deletions.
  1. +111 −48 .idea/workspace.xml
  2. +51 −11 behavioral/visitor1.rb
  3. +0 −1 behavioral/visitor2.rb
  4. +3 −3 enterprise/dsl1.rb
  5. +1 −1 enterprise/{dsl3.rb → dsl12.rb}
View
159 .idea/workspace.xml
@@ -2,11 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="a2ae4535-1641-4e8c-914c-5dc8aedf7cb6" name="Default" comment="">
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
+ <change type="MOVED" beforePath="$PROJECT_DIR$/enterprise/dsl3.rb" afterPath="$PROJECT_DIR$/enterprise/dsl12.rb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/behavioral/visitor1.rb" afterPath="$PROJECT_DIR$/behavioral/visitor1.rb" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/behavioral/visitor2.rb" afterPath="$PROJECT_DIR$/behavioral/visitor2.rb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/enterprise/dsl1.rb" afterPath="$PROJECT_DIR$/enterprise/dsl1.rb" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/enterprise/dsl3.rb" afterPath="$PROJECT_DIR$/enterprise/dsl3.rb" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/design_patterns_in_ruby.iml" afterPath="$PROJECT_DIR$/.idea/design_patterns_in_ruby.iml" />
</list>
<ignored path="design_patterns_in_ruby.iws" />
<ignored path=".idea/workspace.xml" />
@@ -18,7 +18,7 @@
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CoverageDataManager">
- <SUITE FILE_PATH="coverage/design_patterns_in_ruby$dsl3.rcov" NAME="dsl3 Coverage Results" MODIFIED="1282078497597" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/enterprise" />
+ <SUITE FILE_PATH="coverage/design_patterns_in_ruby$dsl3.rcov" NAME="dsl3 Coverage Results" MODIFIED="1282138081399" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/enterprise" />
</component>
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
@@ -30,31 +30,30 @@
<component name="FavoritesManager">
<favorites_list name="design_patterns_in_ruby" />
</component>
- <component name="FileColors" enabled="true" enabledForTabs="true" highlightNonProjectFiles="true" />
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="dsl3.rb" pinned="false" current="true" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/enterprise/dsl3.rb">
+ <file leaf-file-name="dsl12.rb" pinned="false" current="true" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/enterprise/dsl12.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="197" column="25" selection-start="3657" selection-end="3657" vertical-scroll-proportion="0.2795031">
+ <state line="145" column="24" selection-start="2734" selection-end="2741" vertical-scroll-proportion="0.36713287">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="dsl1.rb" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/enterprise/dsl1.rb">
+ <file leaf-file-name="visitor1.rb" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/behavioral/visitor1.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="107" column="48" selection-start="1788" selection-end="1788" vertical-scroll-proportion="0.0">
+ <state line="23" column="14" selection-start="522" selection-end="529" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="dsl2.rb" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/enterprise/dsl2.rb">
+ <file leaf-file-name="dsl1.rb" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/enterprise/dsl1.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="12" column="11" selection-start="215" selection-end="215" vertical-scroll-proportion="0.0">
+ <state line="0" column="42" selection-start="9" selection-end="9" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -92,16 +91,19 @@
<option name="UPDATE_CHANGES_POLICY" value="STASH" />
</component>
<component name="HighlightingSettingsPerFile">
- <setting file="file://$PROJECT_DIR$/enterprise/dsl3.rb" root0="FORCE_HIGHLIGHTING" />
+ <setting file="file://$PROJECT_DIR$/enterprise/dsl12.rb" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="IdeDocumentHistory">
<option name="changedFiles">
<list>
<option value="$PROJECT_DIR$/enterprise/test.rb" />
- <option value="$PROJECT_DIR$/enterprise/dsl1.rb" />
<option value="$PROJECT_DIR$/behavioral/test.rb" />
<option value="$PROJECT_DIR$/enterprise/dsl4.rb" />
<option value="$PROJECT_DIR$/enterprise/dsl3.rb" />
+ <option value="$PROJECT_DIR$/enterprise/dsl12.rb" />
+ <option value="$PROJECT_DIR$/behavioral/visitor2.rb" />
+ <option value="$PROJECT_DIR$/behavioral/visitor1.rb" />
+ <option value="$PROJECT_DIR$/enterprise/dsl1.rb" />
</list>
</option>
</component>
@@ -131,8 +133,8 @@
<sortByType />
</navigator>
<panes>
- <pane id="Favorites" />
<pane id="Scope" />
+ <pane id="Favorites" />
<pane id="ProjectPane">
<subPane>
<PATH>
@@ -197,62 +199,95 @@
<property name="recentsLimit" value="5" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder0" value="0" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth2" value="189" />
- <property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth3" value="983" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth3" value="979" />
+ <property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth3" value="983" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth2" value="186" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth1" value="202" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder2" value="2" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder3" value="3" />
- <property name="options.searchVisible" value="true" />
<property name="options.splitter.details.proportions" value="0.2" />
+ <property name="options.searchVisible" value="true" />
</component>
- <component name="RunManager" selected="Ruby.dsl3">
- <configuration default="false" name="dsl3" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
+ <component name="RunManager" selected="Ruby.dsl12">
+ <configuration default="false" name="dsl4" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
<module name="design_patterns_in_ruby" />
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$PROJECT_DIR$/enterprise" />
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
<envs />
- <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="true" track_test_folders="true" runner="rcov" />
- <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/enterprise/dsl3.rb" />
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov" />
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/enterprise/dsl4.rb" />
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
<RunnerSettings RunnerId="RubyDebugRunner" />
<RunnerSettings RunnerId="RubyRunner" />
<ConfigurationWrapper RunnerId="RubyDebugRunner" />
<ConfigurationWrapper RunnerId="RubyRunner" />
<method />
</configuration>
- <configuration default="false" name="test" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
+ <configuration default="false" name="visitor1" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
<module name="design_patterns_in_ruby" />
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$PROJECT_DIR$/behavioral" />
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
<envs />
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov" />
- <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/behavioral/test.rb" />
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/behavioral/visitor1.rb" />
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
<RunnerSettings RunnerId="RubyRunner" />
<ConfigurationWrapper RunnerId="RubyRunner" />
<method />
</configuration>
- <configuration default="false" name="dsl4" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
+ <configuration default="false" name="dsl1" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
<module name="design_patterns_in_ruby" />
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$PROJECT_DIR$/enterprise" />
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
<envs />
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov" />
- <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/enterprise/dsl4.rb" />
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/enterprise/dsl1.rb" />
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
+ <RunnerSettings RunnerId="RubyRunner" />
+ <ConfigurationWrapper RunnerId="RubyRunner" />
+ <method />
+ </configuration>
+ <configuration default="false" name="dsl2" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
+ <module name="design_patterns_in_ruby" />
+ <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
+ <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$PROJECT_DIR$/enterprise" />
+ <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
+ <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
+ <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
+ <envs />
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov" />
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/enterprise/dsl2.rb" />
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
+ <RunnerSettings RunnerId="RubyRunner" />
+ <ConfigurationWrapper RunnerId="RubyRunner" />
+ <method />
+ </configuration>
+ <configuration default="false" name="dsl12" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
+ <module name="design_patterns_in_ruby" />
+ <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)" />
+ <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$PROJECT_DIR$/enterprise" />
+ <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
+ <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
+ <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
+ <envs />
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov" />
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/enterprise/dsl12.rb" />
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
- <RunnerSettings RunnerId="RubyDebugRunner" />
<RunnerSettings RunnerId="RubyRunner" />
- <ConfigurationWrapper RunnerId="RubyDebugRunner" />
<ConfigurationWrapper RunnerId="RubyRunner" />
<method />
</configuration>
@@ -264,6 +299,7 @@
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
<envs />
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov" />
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="" />
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
@@ -278,6 +314,7 @@
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
<envs />
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov" />
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
@@ -288,10 +325,12 @@
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
<method />
</configuration>
- <list size="3">
- <item index="0" class="java.lang.String" itemvalue="Ruby.dsl3" />
- <item index="1" class="java.lang.String" itemvalue="Ruby.test" />
- <item index="2" class="java.lang.String" itemvalue="Ruby.dsl4" />
+ <list size="5">
+ <item index="0" class="java.lang.String" itemvalue="Ruby.dsl4" />
+ <item index="1" class="java.lang.String" itemvalue="Ruby.visitor1" />
+ <item index="2" class="java.lang.String" itemvalue="Ruby.dsl1" />
+ <item index="3" class="java.lang.String" itemvalue="Ruby.dsl2" />
+ <item index="4" class="java.lang.String" itemvalue="Ruby.dsl12" />
</list>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
@@ -321,22 +360,22 @@
<servers />
</component>
<component name="ToolWindowManager">
- <frame x="62" y="22" width="1599" height="1012" extended-state="0" />
- <editor active="true" />
+ <frame x="45" y="22" width="1635" height="1028" extended-state="0" />
+ <editor active="false" />
<layout>
- <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="Changes" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32869378" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32976446" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3295238" sideWeight="0.7331155" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3289882" sideWeight="0.6713062" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.5294118" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.26688454" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.26552463" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.20152505" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3296837" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32897604" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
@@ -354,8 +393,9 @@
<option name="CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND" value="true" />
<option name="ENABLE_BACKGROUND_PROCESSES" value="true" />
<option name="CHANGED_ON_SERVER_INTERVAL" value="5" />
+ <option name="SHOW_ONLY_CHANGED_IN_SELECTION_DIFF" value="true" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
- <option name="LAST_COMMIT_MESSAGE" />
+ <option name="LAST_COMMIT_MESSAGE" value="implementing generic code for dsl" />
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="true" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
@@ -368,6 +408,7 @@
<option name="UPDATE_GROUP_BY_CHANGELIST" value="false" />
<option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
<option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
+ <MESSAGE value="implementing generic code for dsl" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@@ -376,32 +417,54 @@
<url>file://$PROJECT_DIR$/enterprise/dsl4.rb</url>
<line>263</line>
</line-breakpoint>
+ <line-breakpoint enabled="true" type="ruby-line">
+ <url>file://$PROJECT_DIR$/../../ui-r16/src/app/models/banner_mapping.rb</url>
+ <line>16</line>
+ </line-breakpoint>
+ <line-breakpoint enabled="true" type="ruby-line">
+ <url>file://$PROJECT_DIR$/../../ui-r16/src/vendor/plugins/triton/app/helpers/triton/display_banner_helper.rb</url>
+ <line>12</line>
+ </line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
- <entry file="file://$PROJECT_DIR$/enterprise/dsl2.rb">
+ <entry file="file://$APPLICATION_HOME_DIR$/rubystubs18/object.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="12" column="11" selection-start="215" selection-end="215" vertical-scroll-proportion="0.0" />
+ <state line="22" column="6" selection-start="900" selection-end="900" vertical-scroll-proportion="0.33229813" />
</provider>
</entry>
- <entry file="file://$APPLICATION_HOME_DIR$/rubystubs18/object.rb">
+ <entry file="file://$PROJECT_DIR$/enterprise/dsl2.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="22" column="6" selection-start="900" selection-end="900" vertical-scroll-proportion="0.33229813">
+ <state line="4" column="43" selection-start="64" selection-end="64" vertical-scroll-proportion="0.09741248">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/enterprise/dsl1.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="107" column="48" selection-start="1788" selection-end="1788" vertical-scroll-proportion="0.0">
+ <state line="0" column="42" selection-start="9" selection-end="9" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/behavioral/visitor2.rb">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="35" column="0" selection-start="508" selection-end="508" vertical-scroll-proportion="-0.31506848">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/behavioral/visitor1.rb">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="23" column="14" selection-start="522" selection-end="529" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/enterprise/dsl3.rb">
+ <entry file="file://$PROJECT_DIR$/enterprise/dsl12.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="197" column="25" selection-start="3657" selection-end="3657" vertical-scroll-proportion="0.2795031">
+ <state line="145" column="24" selection-start="2734" selection-end="2741" vertical-scroll-proportion="0.36713287">
<folding />
</state>
</provider>
View
62 behavioral/visitor1.rb
@@ -6,18 +6,26 @@
# 1. visitable and visitor interfaces
+
+def underscore(camel_cased_word)
+ camel_cased_word.to_s.gsub(/::/, '/').
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
+ tr("-", "_").
+ downcase
+end
+
module Visitable
def accept(visitor)
visitor.visit(self)
end
end
-class Visitor
+module Visitor
def visit(visitable)
end
end
-
# 2. type implementation with visitable behavior
# basic parts
@@ -49,8 +57,10 @@ def initialize
]
end
+ alias original_accept accept
+
def accept(visitor)
- visitor.visit(self)
+ original_accept visitor
# takes care of components
@visitable1.accept(visitor)
@@ -62,30 +72,60 @@ def accept(visitor)
# 3. visitor implementations
+class MyCompoundVisitor1
+ include Visitor
+
+ def visit(visitable)
+ method_name = "visit_#{underscore(visitable.class.name)}"
+
+ send method_name.to_sym, visitable
+ end
+
+ def visit_my_visitable1 visitable
+ puts "visitor: visiting my visitable 11"
+ end
+
+ def visit_my_visitable2 visitable
+ puts "visitor: visiting my visible 12"
+ end
+
+ def visit_my_visitable3 visitable
+ puts "visitor: visiting my visitable 13"
+ end
+
+ def visit_my_compound_visitable visitable
+ puts "visitor: visiting my compound visitable 1"
+ end
+end
+
# 4. test
# creating complex visitable
visitable = MyCompoundVisitable.new
+visitor1 = MyCompoundVisitor1.new
+
+visitable.accept(visitor1)
+
# creating visitor dynamically
-class MyVisitor < Visitor
+class MyCompoundVisitor2
+ include Visitor
def visit visitable
if(visitable.kind_of? MyVisitable1)
- puts "visitor: visiting my visitable 1"
+ puts "visitor: visiting my visitable 21"
elsif(visitable.kind_of? MyVisitable2)
- puts "visitor: visiting my visible 2"
+ puts "visitor: visiting my visible 22"
elsif(visitable.kind_of? MyVisitable3)
- puts "visitor: visiting my visitable 3"
+ puts "visitor: visiting my visitable 23"
elsif(visitable.kind_of? MyCompoundVisitable)
- puts "visitor: visiting my compound visitable"
+ puts "visitor: visiting my compound visitable 2"
end
end
end
-visitor = MyVisitor.new
-
-visitable.accept(visitor)
+visitor2 = MyCompoundVisitor2.new
+visitable.accept(visitor2)
View
1 behavioral/visitor2.rb
@@ -34,7 +34,6 @@ class MyVisitable3
include Visitable
end
-
# compound
class MyCompoundVisitable
View
6 enterprise/dsl1.rb
@@ -1,8 +1,8 @@
# dsl1.rb
-# Domain Specific Languagge (DSL) is simple set of commands for serving a specific domain.
+# Domain Specific Language (DSL) is simple set of commands for serving a specific domain.
# It could be implemented on object or class level. With object level we've got DSL scripts, with
-# the class level - metaprogramming statements
+# the class level - meta-programming statements
# This implementation uses object level.
@@ -129,7 +129,7 @@ def tree(name, &block)
tree = Tree.new(name)
tree.instance_eval(&block)
- return tree
+ tree
end
end
View
2 enterprise/dsl3.rb → enterprise/dsl12.rb
@@ -1,4 +1,4 @@
-# dsl3.rb
+# dsl12.rb
# This is another implementation of DSL with the help of DSL build.

0 comments on commit 7975135

Please sign in to comment.