huff 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24913de693b67cb7069ef79267aea33cc91b0d7a
4
+ data.tar.gz: 1b3e99c1680f1f376112b2e300c2c5cc4b11e1ad
5
+ SHA512:
6
+ metadata.gz: c959197d176dcf317fd58e1c65ef5faffcbf781d14ab3818d17ad597e5c3d3ae6dc2352f308fa111b57a58e10b55394eca5b4800aefdae74c88c60b596e59ddf
7
+ data.tar.gz: 0c7befa2954eba0d02df1ecc68ffeb50f1531d82bd2017b5491f757bc4620c2f4505ebd542ef4c631a7975b961913fcf6dcfab4fb0ebd0c5698caf53ceb1124c
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ sample
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ huff
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build huff-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install huff-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push huff-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
data/.idea/huff.iml ADDED
@@ -0,0 +1,57 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Ruby Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager">
13
+ <content url="file://$MODULE_DIR$" />
14
+ <orderEntry type="jdk" jdkName="RVM: ruby-2.1.2 [huff]" jdkType="RUBY_SDK" />
15
+ <orderEntry type="sourceFolder" forTests="false" />
16
+ <orderEntry type="module-library">
17
+ <library name="huff (v0.0.1, /home/dev/workspace/ruby/huff) [path][gem]">
18
+ <CLASSES>
19
+ <root url="file://$MODULE_DIR$/lib" />
20
+ <root url="file://$MODULE_DIR$/tmp" />
21
+ <root url="file://$MODULE_DIR$/.idea" />
22
+ <root url="file://$MODULE_DIR$/sample" />
23
+ </CLASSES>
24
+ <SOURCES>
25
+ <root url="file://$MODULE_DIR$/lib" />
26
+ <root url="file://$MODULE_DIR$/tmp" />
27
+ <root url="file://$MODULE_DIR$/.idea" />
28
+ <root url="file://$MODULE_DIR$/sample" />
29
+ </SOURCES>
30
+ </library>
31
+ </orderEntry>
32
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.5.0, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="celluloid (v0.15.2, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.0, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.9.3, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="formatador (v0.2.5, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="guard (v2.6.1, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="guard-rspec (v4.2.10, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="listen (v2.7.9, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="lumberjack (v1.0.9, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="method_source (v0.8.2, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="pry (v0.10.0, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.2.2, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.9.4, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.9.5, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.0.0, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.0.2, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.0.2, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.0.2, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.0.2, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="slop (v3.5.0, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="timers (v1.1.0, RVM: ruby-2.1.2 [huff]) [gem]" level="application" />
55
+ </component>
56
+ </module>
57
+
@@ -0,0 +1,12 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0" is_locked="false">
3
+ <option name="myName" value="Project Default" />
4
+ <option name="myLocal" value="false" />
5
+ <inspection_tool class="RubyLiteralArrayInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
6
+ <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
7
+ <option name="processCode" value="true" />
8
+ <option name="processLiterals" value="true" />
9
+ <option name="processComments" value="true" />
10
+ </inspection_tool>
11
+ </profile>
12
+ </component>
@@ -0,0 +1,7 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="PROJECT_PROFILE" value="Project Default" />
4
+ <option name="USE_PROJECT_PROFILE" value="true" />
5
+ <version value="1.0" />
6
+ </settings>
7
+ </component>
data/.idea/misc.xml ADDED
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectDictionaryState">
4
+ <dictionary name="dev" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p484 [entrevista-online]" project-jdk-type="RUBY_SDK" />
7
+ <component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false" SSL_PROTOCOLS="all">
8
+ <option name="USER" value="" />
9
+ <option name="PASSWORD" value="" />
10
+ <option name="mySSHConnectionTimeout" value="30000" />
11
+ <option name="mySSHReadTimeout" value="30000" />
12
+ <option name="LAST_MERGED_REVISION" />
13
+ <option name="MERGE_DRY_RUN" value="false" />
14
+ <option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
15
+ <option name="UPDATE_LOCK_ON_DEMAND" value="false" />
16
+ <option name="IGNORE_SPACES_IN_MERGE" value="false" />
17
+ <option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
18
+ <option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
19
+ <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
20
+ <option name="FORCE_UPDATE" value="false" />
21
+ <option name="IGNORE_EXTERNALS" value="false" />
22
+ <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
23
+ </component>
24
+ </project>
25
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/huff.iml" filepath="$PROJECT_DIR$/.idea/huff.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
@@ -0,0 +1,477 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="96567430-0205-40d6-9c2f-e203dffc5504" name="Default" comment="">
5
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/huff.gemspec" afterPath="$PROJECT_DIR$/huff.gemspec" />
6
+ </list>
7
+ <ignored path="huff.iws" />
8
+ <ignored path=".idea/workspace.xml" />
9
+ <option name="TRACKING_ENABLED" value="true" />
10
+ <option name="SHOW_DIALOG" value="false" />
11
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
12
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
13
+ <option name="LAST_RESOLUTION" value="IGNORE" />
14
+ </component>
15
+ <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
16
+ <component name="CreatePatchCommitExecutor">
17
+ <option name="PATCH_PATH" value="" />
18
+ </component>
19
+ <component name="DaemonCodeAnalyzer">
20
+ <disable_hints />
21
+ </component>
22
+ <component name="FavoritesManager">
23
+ <favorites_list name="huff" />
24
+ </component>
25
+ <component name="FileEditorManager">
26
+ <leaf>
27
+ <file leaf-file-name="encoding_tree_builder.rb" pinned="false" current="false" current-in-tab="false">
28
+ <entry file="file://$PROJECT_DIR$/lib/huff/encoding_tree_builder.rb">
29
+ <provider selected="true" editor-type-id="text-editor">
30
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="900">
31
+ <caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
32
+ <folding />
33
+ </state>
34
+ </provider>
35
+ </entry>
36
+ </file>
37
+ <file leaf-file-name="version.rb" pinned="false" current="false" current-in-tab="false">
38
+ <entry file="file://$PROJECT_DIR$/lib/huff/version.rb">
39
+ <provider selected="true" editor-type-id="text-editor">
40
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="162">
41
+ <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
42
+ <folding />
43
+ </state>
44
+ </provider>
45
+ </entry>
46
+ </file>
47
+ <file leaf-file-name="huff.gemspec" pinned="false" current="true" current-in-tab="true">
48
+ <entry file="file://$PROJECT_DIR$/huff.gemspec">
49
+ <provider selected="true" editor-type-id="text-editor">
50
+ <state vertical-scroll-proportion="0.23718888" vertical-offset="0" max-vertical-offset="683">
51
+ <caret line="9" column="55" selection-start-line="9" selection-start-column="52" selection-end-line="9" selection-end-column="52" />
52
+ <folding />
53
+ </state>
54
+ </provider>
55
+ </entry>
56
+ </file>
57
+ </leaf>
58
+ </component>
59
+ <component name="FindManager">
60
+ <FindUsagesManager>
61
+ <setting name="OPEN_NEW_TAB" value="true" />
62
+ </FindUsagesManager>
63
+ </component>
64
+ <component name="Git.Settings">
65
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
66
+ </component>
67
+ <component name="IdeDocumentHistory">
68
+ <option name="changedFiles">
69
+ <list>
70
+ <option value="$PROJECT_DIR$/spec/lib/huff/frequency_meter_spec.rb" />
71
+ <option value="$PROJECT_DIR$/spec/lib/huff/tree_builder_spec.rb" />
72
+ <option value="$PROJECT_DIR$/lib/huff/tree_builder.rb" />
73
+ <option value="$PROJECT_DIR$/spec/lib/huff/encoding_tree_builder_spec.rb" />
74
+ <option value="$PROJECT_DIR$/lib/huff/encoding_tree_builder.rb" />
75
+ <option value="$PROJECT_DIR$/lib/huff/encoding_table_builder.rb" />
76
+ <option value="$PROJECT_DIR$/spec/lib/huff/encoding_table_builder_spec.rb" />
77
+ <option value="$PROJECT_DIR$/lib/huff/encoder.rb" />
78
+ <option value="$PROJECT_DIR$/spec/lib/huff/encoder_spec.rb" />
79
+ <option value="$PROJECT_DIR$/lib/huff/decoder.rb" />
80
+ <option value="$PROJECT_DIR$/spec/lib/huff/decoder_spec.rb" />
81
+ <option value="$PROJECT_DIR$/lib/huff/frequency_meter.rb" />
82
+ <option value="$PROJECT_DIR$/lib/huff.rb" />
83
+ <option value="$PROJECT_DIR$/huff.gemspec" />
84
+ </list>
85
+ </option>
86
+ </component>
87
+ <component name="ProjectFrameBounds">
88
+ <option name="x" value="-1" />
89
+ <option name="y" value="-39" />
90
+ <option name="width" value="1368" />
91
+ <option name="height" value="808" />
92
+ </component>
93
+ <component name="ProjectInspectionProfilesVisibleTreeState">
94
+ <entry key="Project Default">
95
+ <profile-state>
96
+ <expanded-state>
97
+ <State>
98
+ <id />
99
+ </State>
100
+ <State>
101
+ <id>CSS</id>
102
+ </State>
103
+ <State>
104
+ <id>General</id>
105
+ </State>
106
+ <State>
107
+ <id>RELAX NG</id>
108
+ </State>
109
+ <State>
110
+ <id>Rails</id>
111
+ </State>
112
+ </expanded-state>
113
+ <selected-state>
114
+ <State>
115
+ <id>CoffeeScript</id>
116
+ </State>
117
+ </selected-state>
118
+ </profile-state>
119
+ </entry>
120
+ </component>
121
+ <component name="ProjectLevelVcsManager" settingsEditedManually="false">
122
+ <OptionsSetting value="true" id="Add" />
123
+ <OptionsSetting value="true" id="Remove" />
124
+ <OptionsSetting value="true" id="Checkout" />
125
+ <OptionsSetting value="true" id="Update" />
126
+ <OptionsSetting value="true" id="Status" />
127
+ <OptionsSetting value="true" id="Edit" />
128
+ <ConfirmationsSetting value="1" id="Add" />
129
+ <ConfirmationsSetting value="0" id="Remove" />
130
+ </component>
131
+ <component name="ProjectReloadState">
132
+ <option name="STATE" value="0" />
133
+ </component>
134
+ <component name="ProjectView">
135
+ <navigator currentView="ProjectPane" proportions="" version="1">
136
+ <flattenPackages />
137
+ <showMembers />
138
+ <showModules />
139
+ <showLibraryContents />
140
+ <hideEmptyPackages />
141
+ <abbreviatePackageNames />
142
+ <autoscrollToSource />
143
+ <autoscrollFromSource />
144
+ <sortByType />
145
+ </navigator>
146
+ <panes>
147
+ <pane id="ProjectPane">
148
+ <subPane>
149
+ <PATH>
150
+ <PATH_ELEMENT>
151
+ <option name="myItemId" value="huff" />
152
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
153
+ </PATH_ELEMENT>
154
+ </PATH>
155
+ <PATH>
156
+ <PATH_ELEMENT>
157
+ <option name="myItemId" value="huff" />
158
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
159
+ </PATH_ELEMENT>
160
+ <PATH_ELEMENT>
161
+ <option name="myItemId" value="huff" />
162
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
163
+ </PATH_ELEMENT>
164
+ </PATH>
165
+ <PATH>
166
+ <PATH_ELEMENT>
167
+ <option name="myItemId" value="huff" />
168
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
169
+ </PATH_ELEMENT>
170
+ <PATH_ELEMENT>
171
+ <option name="myItemId" value="huff" />
172
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
173
+ </PATH_ELEMENT>
174
+ <PATH_ELEMENT>
175
+ <option name="myItemId" value="spec" />
176
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
177
+ </PATH_ELEMENT>
178
+ </PATH>
179
+ <PATH>
180
+ <PATH_ELEMENT>
181
+ <option name="myItemId" value="huff" />
182
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
183
+ </PATH_ELEMENT>
184
+ <PATH_ELEMENT>
185
+ <option name="myItemId" value="huff" />
186
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
187
+ </PATH_ELEMENT>
188
+ <PATH_ELEMENT>
189
+ <option name="myItemId" value="spec" />
190
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
191
+ </PATH_ELEMENT>
192
+ <PATH_ELEMENT>
193
+ <option name="myItemId" value="lib" />
194
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
195
+ </PATH_ELEMENT>
196
+ <PATH_ELEMENT>
197
+ <option name="myItemId" value="huff" />
198
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
199
+ </PATH_ELEMENT>
200
+ </PATH>
201
+ <PATH>
202
+ <PATH_ELEMENT>
203
+ <option name="myItemId" value="huff" />
204
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
205
+ </PATH_ELEMENT>
206
+ <PATH_ELEMENT>
207
+ <option name="myItemId" value="huff" />
208
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
209
+ </PATH_ELEMENT>
210
+ <PATH_ELEMENT>
211
+ <option name="myItemId" value="lib" />
212
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
213
+ </PATH_ELEMENT>
214
+ </PATH>
215
+ <PATH>
216
+ <PATH_ELEMENT>
217
+ <option name="myItemId" value="huff" />
218
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
219
+ </PATH_ELEMENT>
220
+ <PATH_ELEMENT>
221
+ <option name="myItemId" value="huff" />
222
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
223
+ </PATH_ELEMENT>
224
+ <PATH_ELEMENT>
225
+ <option name="myItemId" value="lib" />
226
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
227
+ </PATH_ELEMENT>
228
+ <PATH_ELEMENT>
229
+ <option name="myItemId" value="huff" />
230
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
231
+ </PATH_ELEMENT>
232
+ </PATH>
233
+ </subPane>
234
+ </pane>
235
+ <pane id="Scope" />
236
+ </panes>
237
+ </component>
238
+ <component name="PropertiesComponent">
239
+ <property name="options.splitter.main.proportions" value="0.3" />
240
+ <property name="options.lastSelected" value="preferences.intentionPowerPack" />
241
+ <property name="options.splitter.details.proportions" value="0.27370948" />
242
+ <property name="options.searchVisible" value="true" />
243
+ <property name="FullScreen" value="true" />
244
+ </component>
245
+ <component name="RunManager">
246
+ <configuration default="true" type="RSpecRunConfigurationType" factoryName="RSpec">
247
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
248
+ <module name="" />
249
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
250
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
251
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
252
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
253
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
254
+ <envs />
255
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
256
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
257
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
258
+ <COVERAGE_PATTERN ENABLED="true">
259
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
260
+ </COVERAGE_PATTERN>
261
+ </EXTENSION>
262
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
263
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
264
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
265
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
266
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
267
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
268
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
269
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
270
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
271
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
272
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
273
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
274
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
275
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
276
+ <method />
277
+ </configuration>
278
+ <configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby">
279
+ <module name="" />
280
+ <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
281
+ <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="" />
282
+ <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
283
+ <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
284
+ <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
285
+ <envs />
286
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
287
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
288
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
289
+ <COVERAGE_PATTERN ENABLED="true">
290
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
291
+ </COVERAGE_PATTERN>
292
+ </EXTENSION>
293
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
294
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="" />
295
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
296
+ <method />
297
+ </configuration>
298
+ <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
299
+ <method />
300
+ </configuration>
301
+ <list size="0" />
302
+ </component>
303
+ <component name="ShelveChangesManager" show_recycled="false" />
304
+ <component name="ToolWindowManager">
305
+ <frame x="-1" y="-39" width="1368" height="808" extended-state="7" />
306
+ <editor active="true" />
307
+ <layout>
308
+ <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" />
309
+ <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" />
310
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32872927" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
311
+ <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
312
+ <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="false" content_ui="tabs" />
313
+ <window_info id="Project" active="false" anchor="left" auto_hide="true" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
314
+ <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
315
+ <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
316
+ <window_info id="Event Log" active="false" anchor="bottom" auto_hide="true" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3278237" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
317
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
318
+ <window_info id="Version Control" 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" />
319
+ <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" />
320
+ <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" />
321
+ <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" />
322
+ <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
323
+ <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" />
324
+ <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="combo" />
325
+ </layout>
326
+ </component>
327
+ <component name="Vcs.Log.UiProperties">
328
+ <option name="RECENTLY_FILTERED_USER_GROUPS">
329
+ <collection />
330
+ </option>
331
+ <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
332
+ <collection />
333
+ </option>
334
+ </component>
335
+ <component name="VcsContentAnnotationSettings">
336
+ <option name="myLimit" value="2678400000" />
337
+ </component>
338
+ <component name="VcsManagerConfiguration">
339
+ <option name="myTodoPanelSettings">
340
+ <TodoPanelSettings />
341
+ </option>
342
+ </component>
343
+ <component name="XDebuggerManager">
344
+ <breakpoint-manager />
345
+ </component>
346
+ <component name="editorHistoryManager">
347
+ <entry file="file://$PROJECT_DIR$/spec/lib/huff/frequency_meter_spec.rb">
348
+ <provider selected="true" editor-type-id="text-editor">
349
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="270">
350
+ <caret line="6" column="11" selection-start-line="6" selection-start-column="11" selection-end-line="6" selection-end-column="11" />
351
+ <folding />
352
+ </state>
353
+ </provider>
354
+ </entry>
355
+ <entry file="file://$PROJECT_DIR$/spec/lib/huff/encoding_tree_builder_spec.rb">
356
+ <provider selected="true" editor-type-id="text-editor">
357
+ <state vertical-scroll-proportion="0.0" vertical-offset="468" max-vertical-offset="612">
358
+ <caret line="26" column="48" selection-start-line="26" selection-start-column="48" selection-end-line="26" selection-end-column="48" />
359
+ <folding />
360
+ </state>
361
+ </provider>
362
+ </entry>
363
+ <entry file="file://$PROJECT_DIR$/lib/huff/frequency_meter.rb">
364
+ <provider selected="true" editor-type-id="text-editor">
365
+ <state vertical-scroll-proportion="0.0" vertical-offset="72" max-vertical-offset="378">
366
+ <caret line="4" column="4" selection-start-line="4" selection-start-column="4" selection-end-line="4" selection-end-column="4" />
367
+ <folding />
368
+ </state>
369
+ </provider>
370
+ </entry>
371
+ <entry file="file://$PROJECT_DIR$/spec/lib/huff/encoding_tree_builder_spec.rb">
372
+ <provider selected="true" editor-type-id="text-editor">
373
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="666">
374
+ <caret line="29" column="58" selection-start-line="26" selection-start-column="42" selection-end-line="29" selection-end-column="58" />
375
+ <folding />
376
+ </state>
377
+ </provider>
378
+ </entry>
379
+ <entry file="file://$PROJECT_DIR$/spec/lib/huff/encoder_spec.rb">
380
+ <provider selected="true" editor-type-id="text-editor">
381
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="468">
382
+ <caret line="18" column="66" selection-start-line="18" selection-start-column="57" selection-end-line="18" selection-end-column="66" />
383
+ <folding />
384
+ </state>
385
+ </provider>
386
+ </entry>
387
+ <entry file="file://$PROJECT_DIR$/spec/lib/huff/decoder_spec.rb">
388
+ <provider selected="true" editor-type-id="text-editor">
389
+ <state vertical-scroll-proportion="0.07906296" vertical-offset="0" max-vertical-offset="683">
390
+ <caret line="3" column="17" selection-start-line="3" selection-start-column="17" selection-end-line="3" selection-end-column="17" />
391
+ <folding />
392
+ </state>
393
+ </provider>
394
+ </entry>
395
+ <entry file="file://$PROJECT_DIR$/spec/lib/huff/encoding_table_builder_spec.rb">
396
+ <provider selected="true" editor-type-id="text-editor">
397
+ <state vertical-scroll-proportion="0.23718888" vertical-offset="0" max-vertical-offset="683">
398
+ <caret line="9" column="15" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" />
399
+ <folding />
400
+ </state>
401
+ </provider>
402
+ </entry>
403
+ <entry file="file://$PROJECT_DIR$/lib/huff/frequency_meter.rb">
404
+ <provider selected="true" editor-type-id="text-editor">
405
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="360">
406
+ <caret line="11" column="21" selection-start-line="11" selection-start-column="21" selection-end-line="11" selection-end-column="21" />
407
+ <folding />
408
+ </state>
409
+ </provider>
410
+ </entry>
411
+ <entry file="file://$PROJECT_DIR$/spec/lib/huff/frequency_meter_spec.rb">
412
+ <provider selected="true" editor-type-id="text-editor">
413
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="270">
414
+ <caret line="6" column="17" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
415
+ <folding />
416
+ </state>
417
+ </provider>
418
+ </entry>
419
+ <entry file="file://$PROJECT_DIR$/lib/huff/encoding_table_builder.rb">
420
+ <provider selected="true" editor-type-id="text-editor">
421
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="414">
422
+ <caret line="4" column="13" selection-start-line="4" selection-start-column="7" selection-end-line="4" selection-end-column="7" />
423
+ <folding />
424
+ </state>
425
+ </provider>
426
+ </entry>
427
+ <entry file="file://$PROJECT_DIR$/lib/huff/encoder.rb">
428
+ <provider selected="true" editor-type-id="text-editor">
429
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="396">
430
+ <caret line="11" column="38" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
431
+ <folding />
432
+ </state>
433
+ </provider>
434
+ </entry>
435
+ <entry file="file://$PROJECT_DIR$/lib/huff/decoder.rb">
436
+ <provider selected="true" editor-type-id="text-editor">
437
+ <state vertical-scroll-proportion="0.38793105" vertical-offset="0" max-vertical-offset="738">
438
+ <caret line="15" column="13" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
439
+ <folding />
440
+ </state>
441
+ </provider>
442
+ </entry>
443
+ <entry file="file://$PROJECT_DIR$/lib/huff.rb">
444
+ <provider selected="true" editor-type-id="text-editor">
445
+ <state vertical-scroll-proportion="0.15517241" vertical-offset="0" max-vertical-offset="696">
446
+ <caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" />
447
+ <folding />
448
+ </state>
449
+ </provider>
450
+ </entry>
451
+ <entry file="file://$PROJECT_DIR$/lib/huff/encoding_tree_builder.rb">
452
+ <provider selected="true" editor-type-id="text-editor">
453
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="900">
454
+ <caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
455
+ <folding />
456
+ </state>
457
+ </provider>
458
+ </entry>
459
+ <entry file="file://$PROJECT_DIR$/lib/huff/version.rb">
460
+ <provider selected="true" editor-type-id="text-editor">
461
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="696">
462
+ <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
463
+ <folding />
464
+ </state>
465
+ </provider>
466
+ </entry>
467
+ <entry file="file://$PROJECT_DIR$/huff.gemspec">
468
+ <provider selected="true" editor-type-id="text-editor">
469
+ <state vertical-scroll-proportion="0.23718888" vertical-offset="0" max-vertical-offset="683">
470
+ <caret line="9" column="55" selection-start-line="9" selection-start-column="52" selection-end-line="9" selection-end-column="52" />
471
+ <folding />
472
+ </state>
473
+ </provider>
474
+ </entry>
475
+ </component>
476
+ </project>
477
+
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ huff
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard :rspec, { all_on_start: true, keep: true, all_after_pass: true, run_all: { cmd: 'rspec -f progress' } } do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ watch('lib/huff.rb') { "spec" }
6
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ronie Uliana
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Huff
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'huff'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install huff
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/huff/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/huff.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'huff/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "huff"
8
+ spec.version = Huff::VERSION
9
+ spec.authors = ["Ronie Uliana"]
10
+ spec.email = ["ronie.uliana@vagas.com.br"]
11
+ spec.summary = %q{A string based UUID generator}
12
+ spec.description = %q{You need a UUID from some string. Maybe a URL shortner without a database, or some kind of ID passed as parameter. This gem uses Huffman Coding [http://en.wikipedia.org/wiki/Huffman_coding] and base 36 integers [http://en.wikipedia.org/wiki/Base_36] to create such ID.}
13
+ spec.homepage = "https://github.com/ruliana/huff"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "guard-rspec", "~> 4.0"
25
+ end
@@ -0,0 +1,36 @@
1
+ module Huff
2
+ class Decoder
3
+ def initialize(encoding_tree)
4
+ @encoding_tree = encoding_tree
5
+ end
6
+
7
+ def decode_string(text)
8
+ text_array = text.each_char.to_a
9
+ result = ''
10
+ until text_array.empty?
11
+ letter, text_array = decode(@encoding_tree, text_array)
12
+ result << letter
13
+ end
14
+ result
15
+ end
16
+
17
+ def decode_36(text)
18
+ decode_string(text.to_i(36).to_s(2))
19
+ end
20
+
21
+ private
22
+
23
+ def decode(tree, text)
24
+ return [tree, text] if tree.is_a? String
25
+ it, *rest = text
26
+ case it
27
+ when '0'
28
+ decode(tree.first, rest)
29
+ when '1'
30
+ decode(tree.last, rest)
31
+ else
32
+ throw "Expecting 0 or 1, got '#{it}'."
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ module Huff
2
+ class Encoder
3
+ def initialize(tree)
4
+ @table = EncodingTableBuilder.new(tree).table
5
+ end
6
+
7
+ def encode_string(text)
8
+ text.each_char.each_with_object('') do |char, result|
9
+ result << @table[char]
10
+ end
11
+ end
12
+
13
+ def encode_36(text)
14
+ encode_string(text).to_i(2).to_s(36).upcase
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Huff
2
+ class EncodingTableBuilder
3
+ def initialize(tree)
4
+ @tree = tree
5
+ end
6
+
7
+ def table
8
+ Hash[create_table(@tree, '')]
9
+ end
10
+
11
+ private
12
+
13
+ def create_table(node, code)
14
+ return [[node, code]] if node.is_a? String
15
+ create_table(node.first, code + '0') + create_table(node.last, code + '1')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ module Huff
2
+ class EncodingTreeBuilder
3
+ def initialize(frequencies)
4
+ @frequencies = frequencies
5
+ end
6
+
7
+ def tree
8
+ create_tree(@frequencies).first
9
+ end
10
+
11
+ def simplified_tree
12
+ simplify(tree)
13
+ end
14
+
15
+ private
16
+
17
+ def create_tree(freqs)
18
+ return freqs if freqs.size == 1
19
+ freqs = sort_frequency(freqs)
20
+
21
+ (f1, c1, *r1), (f2, c2, *r2), *rest = freqs
22
+ node = [f2 + f1, c2 + c1, [f2, c2, *r2], [f1, c1, *r1]]
23
+
24
+ create_tree([node] + rest)
25
+ end
26
+
27
+ def sort_frequency(freqs)
28
+ freqs.sort do |(f1, c1), (f2, c2)|
29
+ # We sort by size on tie to create
30
+ # the shallowest tree possible.
31
+ x = f1 <=> f2
32
+ x == 0 ? c2.size <=> c1.size : x
33
+ end
34
+ end
35
+
36
+ def simplify(freqs)
37
+ _, chars, b1, b2 = freqs
38
+ if b1
39
+ [simplify(b1), simplify(b2)]
40
+ else
41
+ chars
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,15 @@
1
+ module Huff
2
+ class FrequencyMeter
3
+ def initialize(text)
4
+ @text = text
5
+ end
6
+
7
+ def frequency
8
+ result = Hash.new { |h, k| h[k] = 0 }
9
+ @text.each_char.
10
+ each_with_object(result) { |char, hash| hash[char] += 1 }.
11
+ map { |c, f| [f, c] }.
12
+ sort { |(f1, _), (f2, _)| f1 <=> f2 }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Huff
2
+ VERSION = "0.0.1"
3
+ end
data/lib/huff.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Huff; end
2
+ require 'huff/version'
3
+ require 'huff/frequency_meter'
4
+ require 'huff/encoding_tree_builder'
5
+ require 'huff/encoding_table_builder'
6
+ require 'huff/encoder'
7
+ require 'huff/decoder'
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ include Huff
4
+ describe Decoder do
5
+ it 'decodes a string' do
6
+ encoding_tree = ['c', ['b', 'a']]
7
+ subject = Decoder.new(encoding_tree)
8
+ expect(subject.decode_string('11100')).to eq 'abc'
9
+ expect(subject.decode_36('S')).to eq 'abc'
10
+ end
11
+
12
+ it 'decodes a more complex string' do
13
+ encoding_tree = [['i', 's'],
14
+ [['r', 'p'],
15
+ [['e', ' '],
16
+ ['m', 'v']]]]
17
+ subject = Decoder.new(encoding_tree)
18
+ expect(subject.decode_string('1110000101000101001010011011000011111100100')).to eq 'mississipi river'
19
+ expect(subject.decode_36('2QRT5J4RO')).to eq 'mississipi river'
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ include Huff
4
+ describe Encoder do
5
+ it 'encode a string' do
6
+ encoding_tree = ['c', ['b', 'a']]
7
+ subject = Encoder.new(encoding_tree)
8
+ expect(subject.encode_string('abc')).to eq '11100'
9
+ expect(subject.encode_36('abc')).to eq 'S'
10
+ end
11
+
12
+ it 'encode a more complex string' do
13
+ encoding_tree = [['i', 's'],
14
+ [['r', 'p'],
15
+ [['e', ' '],
16
+ ['m', 'v']]]]
17
+ subject = Encoder.new(encoding_tree)
18
+ expect(subject.encode_string('mississipi river')).to eq '1110000101000101001010011011000011111100100'
19
+ expect(subject.encode_36('mississipi river')).to eq '2QRT5J4RO'
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ include Huff
4
+ describe EncodingTableBuilder do
5
+ it 'creates a encoding table from a encoding tree' do
6
+ enconding_tree = ['c', ['b', 'a']]
7
+ subject = EncodingTableBuilder.new(enconding_tree)
8
+ expect(subject.table).to eq({'c' => '0', 'b' => '10', 'a' => '11'})
9
+ end
10
+
11
+ it 'creates a encoding table from a more comples encoding tree' do
12
+ enconding_tree = [['i', 's'],
13
+ [['r', 'p'],
14
+ [['e', ' '],
15
+ ['m', 'v']]]]
16
+ subject = EncodingTableBuilder.new(enconding_tree)
17
+ expect(subject.table).to eq({'i' => '00',
18
+ 's' => '01',
19
+ 'r' => '100',
20
+ 'p' => '101',
21
+ 'e' => '1100',
22
+ ' ' => '1101',
23
+ 'm' => '1110',
24
+ 'v' => '1111'})
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ include Huff
4
+ describe EncodingTreeBuilder do
5
+ it 'build a Huffman tree from frequencies' do
6
+ frequencies = [[1, 'a'], [2, 'b'], [3, 'c']]
7
+ subject = EncodingTreeBuilder.new(frequencies)
8
+ expect(subject.tree).to eq [6, 'cba', [3, 'c'], [3, 'ba', [2, 'b'], [1, 'a']]]
9
+ end
10
+
11
+ it 'builds a simplified Huffman tree' do
12
+ frequencies = [[1, 'a'], [2, 'b'], [3, 'c']]
13
+ subject = EncodingTreeBuilder.new(frequencies)
14
+ expect(subject.simplified_tree).to eq ['c', ['b', 'a']]
15
+ end
16
+
17
+ it 'builds a simplified Huffman for more complex frequencies' do
18
+ frequencies = [[1, ' '],
19
+ [1, 'e'],
20
+ [1, 'v'],
21
+ [1, 'm'],
22
+ [2, 'r'],
23
+ [2, 'p'],
24
+ [4, 's'],
25
+ [5, 'i']]
26
+ subject = EncodingTreeBuilder.new(frequencies)
27
+ expect(subject.simplified_tree).to eq [['i', 's'],
28
+ [['r', 'p'],
29
+ [['e', ' '],
30
+ ['m', 'v']]]]
31
+ end
32
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+ include Huff
3
+
4
+ describe FrequencyMeter do
5
+ it 'count symbols' do
6
+ symbols = "aaábbb\n"
7
+ subject = FrequencyMeter.new(symbols)
8
+ expect(subject.frequency).to eq [[1, "\n"], [1, 'á'], [2, 'a'], [3, 'b']]
9
+ end
10
+ end
@@ -0,0 +1 @@
1
+ require 'huff'
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: huff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ronie Uliana
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ description: You need a UUID from some string. Maybe a URL shortner without a database,
70
+ or some kind of ID passed as parameter. This gem uses Huffman Coding [http://en.wikipedia.org/wiki/Huffman_coding]
71
+ and base 36 integers [http://en.wikipedia.org/wiki/Base_36] to create such ID.
72
+ email:
73
+ - ronie.uliana@vagas.com.br
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".idea/.name"
80
+ - ".idea/.rakeTasks"
81
+ - ".idea/encodings.xml"
82
+ - ".idea/huff.iml"
83
+ - ".idea/inspectionProfiles/Project_Default.xml"
84
+ - ".idea/inspectionProfiles/profiles_settings.xml"
85
+ - ".idea/misc.xml"
86
+ - ".idea/modules.xml"
87
+ - ".idea/scopes/scope_settings.xml"
88
+ - ".idea/vcs.xml"
89
+ - ".idea/workspace.xml"
90
+ - ".ruby-gemset"
91
+ - ".ruby-version"
92
+ - Gemfile
93
+ - Guardfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - huff.gemspec
98
+ - lib/huff.rb
99
+ - lib/huff/decoder.rb
100
+ - lib/huff/encoder.rb
101
+ - lib/huff/encoding_table_builder.rb
102
+ - lib/huff/encoding_tree_builder.rb
103
+ - lib/huff/frequency_meter.rb
104
+ - lib/huff/version.rb
105
+ - spec/lib/huff/decoder_spec.rb
106
+ - spec/lib/huff/encoder_spec.rb
107
+ - spec/lib/huff/encoding_table_builder_spec.rb
108
+ - spec/lib/huff/encoding_tree_builder_spec.rb
109
+ - spec/lib/huff/frequency_meter_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: https://github.com/ruliana/huff
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.2.2
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: A string based UUID generator
135
+ test_files:
136
+ - spec/lib/huff/decoder_spec.rb
137
+ - spec/lib/huff/encoder_spec.rb
138
+ - spec/lib/huff/encoding_table_builder_spec.rb
139
+ - spec/lib/huff/encoding_tree_builder_spec.rb
140
+ - spec/lib/huff/frequency_meter_spec.rb
141
+ - spec/spec_helper.rb