shubox 0.9

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.
Files changed (58) hide show
  1. data/History.txt +57 -0
  2. data/MIT-LICENSE +22 -0
  3. data/Manifest.txt +57 -0
  4. data/PostInstall.txt +6 -0
  5. data/README.rdoc +128 -0
  6. data/Rakefile +61 -0
  7. data/app_generators/clojure/USAGE +15 -0
  8. data/app_generators/clojure/clojure_generator.rb +46 -0
  9. data/app_generators/clojure/templates/README.rdoc +29 -0
  10. data/app_generators/clojure/templates/bin/repl.sh +3 -0
  11. data/app_generators/clojure/templates/bin/runtests.sh +3 -0
  12. data/app_generators/clojure/templates/lib/clojure-contrib.jar +0 -0
  13. data/app_generators/clojure/templates/lib/clojure.jar +0 -0
  14. data/app_generators/clojure/templates/lib/jline-0.9.94.jar +0 -0
  15. data/app_generators/clojure/templates/project.iml +19 -0
  16. data/app_generators/clojure/templates/project.ipr +261 -0
  17. data/app_generators/clojure/templates/src/repl.clj +3 -0
  18. data/app_generators/clojure/templates/test/core/about_clojure_testing.clj +21 -0
  19. data/app_generators/clojure/templates/test/core/about_forms.clj +22 -0
  20. data/app_generators/clojure/templates/test/tests.clj +11 -0
  21. data/app_generators/java/USAGE +14 -0
  22. data/app_generators/java/java_generator.rb +39 -0
  23. data/app_generators/java/templates/Greeting.java +24 -0
  24. data/app_generators/java/templates/GreetingTest.java +18 -0
  25. data/app_generators/java/templates/build.xml +55 -0
  26. data/app_generators/java/templates/lib/hamcrest-core.jar +0 -0
  27. data/app_generators/java/templates/lib/junit.jar +0 -0
  28. data/app_generators/java/templates/project.iml +22 -0
  29. data/app_generators/java/templates/project.ipr +259 -0
  30. data/app_generators/ruby/USAGE +12 -0
  31. data/app_generators/ruby/ruby_generator.rb +37 -0
  32. data/app_generators/ruby/templates/file.txt +3 -0
  33. data/app_generators/ruby/templates/rakefile.rb +9 -0
  34. data/app_generators/ruby/templates/right_triangle.rb +18 -0
  35. data/app_generators/ruby/templates/shubox.rb +6 -0
  36. data/app_generators/ruby/templates/test_helper.rb +9 -0
  37. data/app_generators/ruby/templates/test_io.rb +15 -0
  38. data/app_generators/ruby/templates/test_right_triangle.rb +21 -0
  39. data/bin/shubox +24 -0
  40. data/cleaner_generators/test_unit_cleaner/USAGE +7 -0
  41. data/cleaner_generators/test_unit_cleaner/lib/test_unit_cleaner.rb +93 -0
  42. data/cleaner_generators/test_unit_cleaner/templates/clean_test_unit +12 -0
  43. data/cleaner_generators/test_unit_cleaner/templates/filter_test_unit +13 -0
  44. data/cleaner_generators/test_unit_cleaner/test_unit_cleaner_generator.rb +27 -0
  45. data/lib/languages.rb +20 -0
  46. data/lib/shubox.rb +11 -0
  47. data/lib/shubox_app_generator.rb +40 -0
  48. data/script/console +10 -0
  49. data/script/destroy +14 -0
  50. data/script/generate +14 -0
  51. data/test/cleaners/test_test_unit_cleaner.rb +111 -0
  52. data/test/generators/test_clojure_generator.rb +44 -0
  53. data/test/generators/test_java_generator.rb +37 -0
  54. data/test/generators/test_ruby_generator.rb +34 -0
  55. data/test/lib/test_languages.rb +38 -0
  56. data/test/test_generator_helper.rb +72 -0
  57. data/test/test_helper.rb +4 -0
  58. metadata +144 -0
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module relativePaths="true" type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ <orderEntry type="module-library">
12
+ <library>
13
+ <CLASSES>
14
+ <root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.5.jar!/" />
15
+ </CLASSES>
16
+ <JAVADOC />
17
+ <SOURCES />
18
+ </library>
19
+ </orderEntry>
20
+ </component>
21
+ </module>
22
+
@@ -0,0 +1,259 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project relativePaths="false" version="4">
3
+ <component name="AntConfiguration">
4
+ <defaultAnt bundledAnt="true" />
5
+ <buildFile url="file://$PROJECT_DIR$/build/build.xml">
6
+ <additionalClassPath />
7
+ <antReference projectDefault="true" />
8
+ <customJdkName value="" />
9
+ <maximumHeapSize value="128" />
10
+ <maximumStackSize value="32" />
11
+ <properties />
12
+ </buildFile>
13
+ </component>
14
+ <component name="BuildJarProjectSettings">
15
+ <option name="BUILD_JARS_ON_MAKE" value="false" />
16
+ </component>
17
+ <component name="CodeStyleSettingsManager">
18
+ <option name="PER_PROJECT_SETTINGS" />
19
+ <option name="USE_PER_PROJECT_SETTINGS" value="false" />
20
+ </component>
21
+ <component name="CompilerConfiguration">
22
+ <option name="DEFAULT_COMPILER" value="Javac" />
23
+ <option name="DEPLOY_AFTER_MAKE" value="0" />
24
+ <resourceExtensions>
25
+ <entry name=".+\.(properties|xml|html|dtd|tld)" />
26
+ <entry name=".+\.(gif|png|jpeg|jpg)" />
27
+ </resourceExtensions>
28
+ <wildcardResourcePatterns>
29
+ <entry name="?*.properties" />
30
+ <entry name="?*.xml" />
31
+ <entry name="?*.gif" />
32
+ <entry name="?*.png" />
33
+ <entry name="?*.jpeg" />
34
+ <entry name="?*.jpg" />
35
+ <entry name="?*.html" />
36
+ <entry name="?*.dtd" />
37
+ <entry name="?*.tld" />
38
+ <entry name="?*.ftl" />
39
+ </wildcardResourcePatterns>
40
+ </component>
41
+ <component name="CopyrightManager" default="">
42
+ <module2copyright />
43
+ </component>
44
+ <component name="DependencyValidationManager">
45
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
46
+ </component>
47
+ <component name="EclipseCompilerSettings">
48
+ <option name="DEBUGGING_INFO" value="true" />
49
+ <option name="GENERATE_NO_WARNINGS" value="true" />
50
+ <option name="DEPRECATION" value="false" />
51
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
52
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
53
+ </component>
54
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
55
+ <component name="IdProvider" IDEtalkID="CD12B10C71E44033B2F52F90C08DEF9E" />
56
+ <component name="InspectionProjectProfileManager">
57
+ <option name="PROJECT_PROFILE" value="Project Default" />
58
+ <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
59
+ <scopes />
60
+ <profiles>
61
+ <profile version="1.0" is_locked="false">
62
+ <option name="myName" value="Project Default" />
63
+ <option name="myLocal" value="false" />
64
+ </profile>
65
+ </profiles>
66
+ <list size="0" />
67
+ </component>
68
+ <component name="JavacSettings">
69
+ <option name="DEBUGGING_INFO" value="true" />
70
+ <option name="GENERATE_NO_WARNINGS" value="false" />
71
+ <option name="DEPRECATION" value="true" />
72
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
73
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
74
+ </component>
75
+ <component name="JavadocGenerationManager">
76
+ <option name="OUTPUT_DIRECTORY" />
77
+ <option name="OPTION_SCOPE" value="protected" />
78
+ <option name="OPTION_HIERARCHY" value="true" />
79
+ <option name="OPTION_NAVIGATOR" value="true" />
80
+ <option name="OPTION_INDEX" value="true" />
81
+ <option name="OPTION_SEPARATE_INDEX" value="true" />
82
+ <option name="OPTION_DOCUMENT_TAG_USE" value="false" />
83
+ <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
84
+ <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
85
+ <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
86
+ <option name="OPTION_DEPRECATED_LIST" value="true" />
87
+ <option name="OTHER_OPTIONS" value="" />
88
+ <option name="HEAP_SIZE" />
89
+ <option name="LOCALE" />
90
+ <option name="OPEN_IN_BROWSER" value="true" />
91
+ </component>
92
+ <component name="JikesSettings">
93
+ <option name="JIKES_PATH" value="" />
94
+ <option name="DEBUGGING_INFO" value="true" />
95
+ <option name="DEPRECATION" value="true" />
96
+ <option name="GENERATE_NO_WARNINGS" value="false" />
97
+ <option name="IS_EMACS_ERRORS_MODE" value="true" />
98
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
99
+ </component>
100
+ <component name="Palette2">
101
+ <group name="Swing">
102
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
103
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
104
+ </item>
105
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
106
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
107
+ </item>
108
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
109
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
110
+ </item>
111
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
112
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
113
+ </item>
114
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
115
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
116
+ <initial-values>
117
+ <property name="text" value="Button" />
118
+ </initial-values>
119
+ </item>
120
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
121
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
122
+ <initial-values>
123
+ <property name="text" value="RadioButton" />
124
+ </initial-values>
125
+ </item>
126
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
127
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
128
+ <initial-values>
129
+ <property name="text" value="CheckBox" />
130
+ </initial-values>
131
+ </item>
132
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
133
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
134
+ <initial-values>
135
+ <property name="text" value="Label" />
136
+ </initial-values>
137
+ </item>
138
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
139
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
140
+ <preferred-size width="150" height="-1" />
141
+ </default-constraints>
142
+ </item>
143
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
144
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
145
+ <preferred-size width="150" height="-1" />
146
+ </default-constraints>
147
+ </item>
148
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
149
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
150
+ <preferred-size width="150" height="-1" />
151
+ </default-constraints>
152
+ </item>
153
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
154
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
155
+ <preferred-size width="150" height="50" />
156
+ </default-constraints>
157
+ </item>
158
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
159
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
160
+ <preferred-size width="150" height="50" />
161
+ </default-constraints>
162
+ </item>
163
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
164
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
165
+ <preferred-size width="150" height="50" />
166
+ </default-constraints>
167
+ </item>
168
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
169
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
170
+ </item>
171
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
172
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
173
+ <preferred-size width="150" height="50" />
174
+ </default-constraints>
175
+ </item>
176
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
177
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
178
+ <preferred-size width="150" height="50" />
179
+ </default-constraints>
180
+ </item>
181
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
182
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
183
+ <preferred-size width="150" height="50" />
184
+ </default-constraints>
185
+ </item>
186
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
187
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
188
+ <preferred-size width="200" height="200" />
189
+ </default-constraints>
190
+ </item>
191
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
192
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
193
+ <preferred-size width="200" height="200" />
194
+ </default-constraints>
195
+ </item>
196
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
197
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
198
+ </item>
199
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
200
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
201
+ </item>
202
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
203
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
204
+ </item>
205
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
206
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
207
+ </item>
208
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
209
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
210
+ <preferred-size width="-1" height="20" />
211
+ </default-constraints>
212
+ </item>
213
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
214
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
215
+ </item>
216
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
217
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
218
+ </item>
219
+ </group>
220
+ </component>
221
+ <component name="ProjectDetails">
222
+ <option name="projectName" value="<%= name %>" />
223
+ </component>
224
+ <component name="ProjectFileVersion" converted="true" />
225
+ <component name="ProjectKey">
226
+ <option name="state" value="project://<%= destination_root %>/<%= name %>.ipr" />
227
+ </component>
228
+ <component name="ProjectModuleManager">
229
+ <modules>
230
+ <module fileurl="file://$PROJECT_DIR$/<%= name %>.iml" filepath="$PROJECT_DIR$/<%= name %>.iml" />
231
+ </modules>
232
+ </component>
233
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
234
+ <output url="file://$PROJECT_DIR$/out" />
235
+ </component>
236
+ <component name="ResourceManagerContainer">
237
+ <option name="myResourceBundles">
238
+ <value>
239
+ <list size="0" />
240
+ </value>
241
+ </option>
242
+ </component>
243
+ <component name="RmicSettings">
244
+ <option name="IS_EANABLED" value="false" />
245
+ <option name="DEBUGGING_INFO" value="true" />
246
+ <option name="GENERATE_NO_WARNINGS" value="false" />
247
+ <option name="GENERATE_IIOP_STUBS" value="false" />
248
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
249
+ </component>
250
+ <component name="SvnBranchConfigurationManager">
251
+ <option name="myVersion" value="124" />
252
+ <option name="mySupportsUserInfoFilter" value="true" />
253
+ </component>
254
+ <component name="VcsDirectoryMappings">
255
+ <mapping directory="" vcs="Git" />
256
+ </component>
257
+ <component name="WebServicesPlugin" addRequiredLibraries="true" />
258
+ </project>
259
+
@@ -0,0 +1,12 @@
1
+ Description:
2
+
3
+ shubox lowers the barrier to entry for test-driven learning by providing a basic infrastructure in which
4
+ to start coding: A directory structure, some classes and unit tests to get started, a Rakefile to run
5
+ all tests, and cleaners to delete test implementations and facilitate repetition.
6
+
7
+ Usage:
8
+
9
+ $ shubox /tmp/learn_ruby
10
+ $ cd /tmp/learn_ruby
11
+ $ rake
12
+
@@ -0,0 +1,37 @@
1
+ require 'shubox_app_generator'
2
+ require 'shubox'
3
+
4
+ class RubyGenerator < ShuboxAppGenerator
5
+
6
+ def manifest
7
+ record do |m|
8
+ # Ensure appropriate folder(s) exists
9
+ m.directory ''
10
+ BASEDIRS.each { |path| m.directory path }
11
+
12
+ m.file "rakefile.rb", "rakefile.rb"
13
+ m.directory "lib/samples"
14
+ m.file "right_triangle.rb", "lib/samples/right_triangle.rb"
15
+ m.file "shubox.rb", "lib/shubox.rb"
16
+ m.directory "test/samples"
17
+ m.directory "test/data"
18
+ m.file "test_right_triangle.rb", "test/samples/test_right_triangle.rb"
19
+ m.file "test_io.rb", "test/test_io.rb"
20
+ m.file "file.txt", "test/data/file.txt"
21
+ m.file "test_helper.rb", "test/test_helper.rb"
22
+
23
+ m.dependency "install_rubigen_scripts", [destination_root, "rubygems", "cleaner"],
24
+ :shebang => options[:shebang], :collision => :force
25
+
26
+ m.dependency "test_unit_cleaner", [], :destination => destination_root, :collision => :force
27
+ end
28
+ end
29
+
30
+ protected
31
+ # Installation skeleton.
32
+ BASEDIRS = %w(
33
+ lib
34
+ script
35
+ test
36
+ )
37
+ end
@@ -0,0 +1,3 @@
1
+ Salam, azizam!
2
+
3
+ Welcome to Shubox.
@@ -0,0 +1,9 @@
1
+ require 'rake/testtask'
2
+
3
+ task :default => :test
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/**/test*.rb']
8
+ t.verbose = true
9
+ end
@@ -0,0 +1,18 @@
1
+ # Encapsulates the geometry of a 3-sided polygon with a right angle.
2
+ # http://mathworld.wolfram.com/RightTriangle.html
3
+ class RightTriangle
4
+
5
+ def initialize(base, height)
6
+ @a, @b = base, height
7
+ @c = hypotenuse
8
+ end
9
+
10
+ def hypotenuse
11
+ Math.sqrt((@a**2) + (@b**2))
12
+ end
13
+
14
+ def area
15
+ 0.5 * @a * @b
16
+ end
17
+
18
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module Shubox
5
+
6
+ end
@@ -0,0 +1,9 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/shubox'
4
+
5
+ module Constants
6
+ if (!defined? TEST_DATA_DIR)
7
+ TEST_DATA_DIR = File.join(File.expand_path(File.dirname(__FILE__)), "data")
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ # Pro tip: Keeping an inline bookmark to the rdocs for the class under study
4
+ # makes it easy to continue your learning later.
5
+
6
+ # Exploring the methods of the IO class: http://www.ruby-doc.org/core/classes/IO.html
7
+ class TestIO < Test::Unit::TestCase
8
+
9
+ # See String Match for =~ syntax: http://www.ruby-doc.org/core/classes/String.html#M000792
10
+ def test_readlines_reads_files_as_array
11
+ contents = IO.readlines(File.join(Constants::TEST_DATA_DIR, "file.txt"))
12
+ assert(contents[0] =~ /Salam/)
13
+ end
14
+
15
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'samples/right_triangle'
3
+
4
+ # An example of testing a class in the lib folder.
5
+ class TestRightTriangle < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @small = RightTriangle.new(3, 4)
9
+ @big = RightTriangle.new(120, 160)
10
+ end
11
+
12
+ def test_hypotenuse
13
+ assert_equal(5, @small.hypotenuse)
14
+ assert_equal(200, @big.hypotenuse)
15
+ end
16
+
17
+ def test_area
18
+ assert_equal(6, @small.area)
19
+ end
20
+
21
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+ require File.dirname(__FILE__) + "/../lib/shubox"
6
+ require File.dirname(__FILE__) + "/../lib/languages"
7
+
8
+ if %w(-v --version).include? ARGV.first
9
+ puts "#{File.basename($0)} #{Shubox::VERSION}"
10
+ exit(0)
11
+ end
12
+
13
+ require 'rubigen/scripts/generate'
14
+
15
+ # require "pp"
16
+ RubiGen::Base.use_application_sources! :rubygems
17
+ RubiGen::Base.prepend_sources(*[
18
+ RubiGen::PathSource.new(:shubox, File.join(File.dirname(__FILE__), "..", "app_generators")),
19
+ RubiGen::PathSource.new(:shubox, File.join(File.dirname(__FILE__), "..", "cleaner_generators"))
20
+ ])
21
+ # pp RubiGen::Base.sources
22
+
23
+
24
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => Languages.parse(ARGV))