ush 0.1.0b

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: 87f450c593db285ac178731188bba6d1dbb4cb3d
4
+ data.tar.gz: 0f177c7604f2495d2822ee0ff567a92355eef2ef
5
+ SHA512:
6
+ metadata.gz: c8f910a59e5ffaff40ab5a902c64d56bdac6a5f72989ccf98497e652a9b1ebadd0b0ef31b748b6465a32380a6007cdceea6a178bdb9ccf318239ccadd70ef1e0
7
+ data.tar.gz: e2f32a5be382cdbc79ba994537c12ffe389e954cce240861136c8102d4bdd8075f4eff66186ca48ee70c87ff173c85113aa251ba9ee5bfef80015cfc194d487f
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.db
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.3.3-p222" project-jdk-type="RUBY_SDK" />
7
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
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/ush.iml" filepath="$PROJECT_DIR$/.idea/ush.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/ush.iml ADDED
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$" />
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.6, ruby-2.3.3-p222) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.0, ruby-2.3.3-p222) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, ruby-2.3.3-p222) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="mustermann (v1.0.1, ruby-2.3.3-p222) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="rack (v2.0.3, ruby-2.3.3-p222) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="rack-protection (v2.0.0, ruby-2.3.3-p222) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, ruby-2.3.3-p222) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.7.0, ruby-2.3.3-p222) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.7.0, ruby-2.3.3-p222) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.7.0, ruby-2.3.3-p222) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.7.0, ruby-2.3.3-p222) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.7.0, ruby-2.3.3-p222) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="sinatra (v2.0.0, ruby-2.3.3-p222) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="sqlite3 (v1.3.13, ruby-2.3.3-p222) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="tilt (v2.0.8, ruby-2.3.3-p222) [gem]" level="application" />
25
+ </component>
26
+ </module>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
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>
@@ -0,0 +1,505 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="b962ab8f-9904-4319-8bbc-270a7fef8e53" name="Default" comment="">
5
+ <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/lib/ush/app.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/ush/app.rb" afterDir="false" />
7
+ <change beforePath="$PROJECT_DIR$/lib/ush/db/sqlite.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/ush/db/sqlite.rb" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/lib/ush/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/ush/version.rb" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/spec/spec_helper.rb" beforeDir="false" afterPath="$PROJECT_DIR$/spec/spec_helper.rb" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/ush.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/ush.gemspec" afterDir="false" />
11
+ </list>
12
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
13
+ <option name="TRACKING_ENABLED" value="true" />
14
+ <option name="SHOW_DIALOG" value="false" />
15
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
16
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
17
+ <option name="LAST_RESOLUTION" value="IGNORE" />
18
+ </component>
19
+ <component name="CoverageDataManager">
20
+ <SUITE FILE_PATH="coverage/ush@release_remote___ush.rcov" NAME="release[remote]: ush Coverage Results" MODIFIED="1534134081365" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="ush" />
21
+ <SUITE FILE_PATH="coverage/ush@spec__ush.rcov" NAME="spec: ush Coverage Results" MODIFIED="1534133611706" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="ush" />
22
+ </component>
23
+ <component name="FileEditorManager">
24
+ <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
25
+ <file leaf-file-name="ush.rb" pinned="false" current-in-tab="false">
26
+ <entry file="file://$PROJECT_DIR$/lib/ush.rb">
27
+ <provider selected="true" editor-type-id="text-editor">
28
+ <state relative-caret-position="170">
29
+ <caret line="10" column="5" selection-start-line="10" selection-start-column="5" selection-end-line="10" selection-end-column="5" />
30
+ </state>
31
+ </provider>
32
+ </entry>
33
+ </file>
34
+ <file leaf-file-name="version.rb" pinned="false" current-in-tab="true">
35
+ <entry file="file://$PROJECT_DIR$/lib/ush/version.rb">
36
+ <provider selected="true" editor-type-id="text-editor">
37
+ <state relative-caret-position="51">
38
+ <caret line="3" lean-forward="true" selection-start-line="3" selection-end-line="3" />
39
+ </state>
40
+ </provider>
41
+ </entry>
42
+ </file>
43
+ <file leaf-file-name="app.rb" pinned="false" current-in-tab="false">
44
+ <entry file="file://$PROJECT_DIR$/lib/ush/app.rb">
45
+ <provider selected="true" editor-type-id="text-editor">
46
+ <state relative-caret-position="17">
47
+ <caret line="1" column="17" selection-start-line="1" selection-start-column="17" selection-end-line="1" selection-end-column="17" />
48
+ </state>
49
+ </provider>
50
+ </entry>
51
+ </file>
52
+ <file leaf-file-name="sqlite.rb" pinned="false" current-in-tab="false">
53
+ <entry file="file://$PROJECT_DIR$/lib/ush/db/sqlite.rb">
54
+ <provider selected="true" editor-type-id="text-editor">
55
+ <state relative-caret-position="131">
56
+ <caret line="13" column="39" selection-start-line="13" selection-start-column="39" selection-end-line="13" selection-end-column="39" />
57
+ </state>
58
+ </provider>
59
+ </entry>
60
+ </file>
61
+ <file leaf-file-name="ush" pinned="false" current-in-tab="false">
62
+ <entry file="file://$PROJECT_DIR$/exe/ush">
63
+ <provider selected="true" editor-type-id="text-editor">
64
+ <state relative-caret-position="102">
65
+ <caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
66
+ </state>
67
+ </provider>
68
+ </entry>
69
+ </file>
70
+ <file leaf-file-name="ush.gemspec" pinned="false" current-in-tab="false">
71
+ <entry file="file://$PROJECT_DIR$/ush.gemspec">
72
+ <provider selected="true" editor-type-id="text-editor">
73
+ <state relative-caret-position="374">
74
+ <caret line="22" column="38" selection-start-line="22" selection-start-column="38" selection-end-line="22" selection-end-column="38" />
75
+ </state>
76
+ </provider>
77
+ </entry>
78
+ </file>
79
+ <file leaf-file-name="README.md" pinned="false" current-in-tab="false">
80
+ <entry file="file://$PROJECT_DIR$/README.md">
81
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
82
+ <state split_layout="SPLIT">
83
+ <first_editor relative-caret-position="68">
84
+ <caret line="4" column="15" selection-start-line="4" selection-start-column="15" selection-end-line="4" selection-end-column="15" />
85
+ </first_editor>
86
+ <second_editor />
87
+ </state>
88
+ </provider>
89
+ </entry>
90
+ </file>
91
+ <file leaf-file-name="crypto.rb" pinned="false" current-in-tab="false">
92
+ <entry file="file://$PROJECT_DIR$/lib/ush/crypto.rb">
93
+ <provider selected="true" editor-type-id="text-editor">
94
+ <state relative-caret-position="102">
95
+ <caret line="6" column="3" selection-start-line="6" selection-start-column="3" selection-end-line="6" selection-end-column="3" />
96
+ </state>
97
+ </provider>
98
+ </entry>
99
+ </file>
100
+ <file leaf-file-name="spec_helper.rb" pinned="false" current-in-tab="false">
101
+ <entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
102
+ <provider selected="true" editor-type-id="text-editor">
103
+ <state relative-caret-position="85">
104
+ <caret line="5" column="59" selection-start-line="5" selection-start-column="59" selection-end-line="5" selection-end-column="59" />
105
+ </state>
106
+ </provider>
107
+ </entry>
108
+ </file>
109
+ <file leaf-file-name="ush_spec.rb" pinned="false" current-in-tab="false">
110
+ <entry file="file://$PROJECT_DIR$/spec/ush_spec.rb">
111
+ <provider selected="true" editor-type-id="text-editor">
112
+ <state relative-caret-position="136">
113
+ <caret line="8" column="5" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
114
+ </state>
115
+ </provider>
116
+ </entry>
117
+ </file>
118
+ </leaf>
119
+ </component>
120
+ <component name="FindInProjectRecents">
121
+ <findStrings>
122
+ <find>nex</find>
123
+ </findStrings>
124
+ </component>
125
+ <component name="Git.Settings">
126
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
127
+ </component>
128
+ <component name="IdeDocumentHistory">
129
+ <option name="CHANGED_PATHS">
130
+ <list>
131
+ <option value="$PROJECT_DIR$/lib/ush/db.rb" />
132
+ <option value="$PROJECT_DIR$/exe/ush" />
133
+ <option value="$PROJECT_DIR$/lib/ush/crypto.rb" />
134
+ <option value="$PROJECT_DIR$/lib/ush.rb" />
135
+ <option value="$PROJECT_DIR$/.gitignore" />
136
+ <option value="$PROJECT_DIR$/.rubocop.yml" />
137
+ <option value="$PROJECT_DIR$/spec/ush_spec.rb" />
138
+ <option value="$PROJECT_DIR$/README.md" />
139
+ <option value="$PROJECT_DIR$/lib/ush/version.rb" />
140
+ <option value="$PROJECT_DIR$/lib/ush/app.rb" />
141
+ <option value="$PROJECT_DIR$/lib/ush/db/sqlite.rb" />
142
+ <option value="$PROJECT_DIR$/spec/spec_helper.rb" />
143
+ <option value="$PROJECT_DIR$/ush.gemspec" />
144
+ </list>
145
+ </option>
146
+ </component>
147
+ <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
148
+ <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
149
+ <component name="JsGulpfileManager">
150
+ <detection-done>true</detection-done>
151
+ <sorting>DEFINITION_ORDER</sorting>
152
+ </component>
153
+ <component name="ProjectFrameBounds" extendedState="6">
154
+ <option name="x" value="42" />
155
+ <option name="y" value="-24" />
156
+ <option name="width" value="1400" />
157
+ <option name="height" value="1000" />
158
+ </component>
159
+ <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
160
+ <component name="ProjectView">
161
+ <navigator proportions="" version="1">
162
+ <foldersAlwaysOnTop value="true" />
163
+ </navigator>
164
+ <panes>
165
+ <pane id="Scope" />
166
+ <pane id="ProjectPane">
167
+ <subPane>
168
+ <expand>
169
+ <path>
170
+ <item name="ush" type="b2602c69:ProjectViewProjectNode" />
171
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
172
+ </path>
173
+ <path>
174
+ <item name="ush" type="b2602c69:ProjectViewProjectNode" />
175
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
176
+ <item name="db" type="462c0819:PsiDirectoryNode" />
177
+ </path>
178
+ <path>
179
+ <item name="ush" type="b2602c69:ProjectViewProjectNode" />
180
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
181
+ <item name="exe" type="462c0819:PsiDirectoryNode" />
182
+ </path>
183
+ <path>
184
+ <item name="ush" type="b2602c69:ProjectViewProjectNode" />
185
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
186
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
187
+ </path>
188
+ <path>
189
+ <item name="ush" type="b2602c69:ProjectViewProjectNode" />
190
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
191
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
192
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
193
+ </path>
194
+ <path>
195
+ <item name="ush" type="b2602c69:ProjectViewProjectNode" />
196
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
197
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
198
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
199
+ <item name="db" type="462c0819:PsiDirectoryNode" />
200
+ </path>
201
+ <path>
202
+ <item name="ush" type="b2602c69:ProjectViewProjectNode" />
203
+ <item name="ush" type="462c0819:PsiDirectoryNode" />
204
+ <item name="spec" type="462c0819:PsiDirectoryNode" />
205
+ </path>
206
+ </expand>
207
+ <select />
208
+ </subPane>
209
+ </pane>
210
+ </panes>
211
+ </component>
212
+ <component name="PropertiesComponent">
213
+ <property name="RakeTaksPopup.undocumentedIncluded" value="false" />
214
+ <property name="WebServerToolWindowFactoryState" value="false" />
215
+ <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
216
+ <property name="nodejs_npm_path_reset_for_default_project" value="true" />
217
+ </component>
218
+ <component name="RunDashboard">
219
+ <option name="ruleStates">
220
+ <list>
221
+ <RuleState>
222
+ <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
223
+ </RuleState>
224
+ <RuleState>
225
+ <option name="name" value="StatusDashboardGroupingRule" />
226
+ </RuleState>
227
+ </list>
228
+ </option>
229
+ </component>
230
+ <component name="RunManager" selected="Rake.release[remote]: ush">
231
+ <configuration name="release[remote]: ush" type="RakeRunConfigurationType" factoryName="Rake" temporary="true">
232
+ <module name="ush" />
233
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
234
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
235
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
236
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
237
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
238
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
239
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
240
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" />
241
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="release" />
242
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
243
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE="" />
244
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
245
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
246
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
247
+ </configuration>
248
+ <configuration name="spec: ush" type="RakeRunConfigurationType" factoryName="Rake" temporary="true">
249
+ <module name="ush" />
250
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
251
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
252
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
253
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
254
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
255
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
256
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
257
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" />
258
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="spec" />
259
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
260
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE=":rspec " />
261
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
262
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
263
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
264
+ </configuration>
265
+ <list>
266
+ <item itemvalue="Rake.spec: ush" />
267
+ <item itemvalue="Rake.release[remote]: ush" />
268
+ </list>
269
+ <recent_temporary>
270
+ <list>
271
+ <item itemvalue="Rake.release[remote]: ush" />
272
+ <item itemvalue="Rake.spec: ush" />
273
+ </list>
274
+ </recent_temporary>
275
+ </component>
276
+ <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" />
277
+ <component name="SvnConfiguration">
278
+ <configuration />
279
+ </component>
280
+ <component name="TaskManager">
281
+ <task active="true" id="Default" summary="Default task">
282
+ <changelist id="b962ab8f-9904-4319-8bbc-270a7fef8e53" name="Default" comment="" />
283
+ <created>1534022490743</created>
284
+ <option name="number" value="Default" />
285
+ <option name="presentableId" value="Default" />
286
+ <updated>1534022490743</updated>
287
+ <workItem from="1534022492481" duration="7969000" />
288
+ <workItem from="1534105537996" duration="14942000" />
289
+ </task>
290
+ <task id="LOCAL-00001" summary="Initial commit">
291
+ <created>1534133945083</created>
292
+ <option name="number" value="00001" />
293
+ <option name="presentableId" value="LOCAL-00001" />
294
+ <option name="project" value="LOCAL" />
295
+ <updated>1534133945083</updated>
296
+ </task>
297
+ <option name="localTasksCounter" value="2" />
298
+ <servers />
299
+ </component>
300
+ <component name="TestHistory">
301
+ <history-entry file="spec__ush - 2018.08.13 at 00h 10m 48s.xml">
302
+ <configuration name="spec: ush" configurationId="RakeRunConfigurationType" />
303
+ </history-entry>
304
+ <history-entry file="spec__ush - 2018.08.13 at 00h 11m 46s.xml">
305
+ <configuration name="spec: ush" configurationId="RakeRunConfigurationType" />
306
+ </history-entry>
307
+ <history-entry file="spec__ush - 2018.08.13 at 00h 13m 32s.xml">
308
+ <configuration name="spec: ush" configurationId="RakeRunConfigurationType" />
309
+ </history-entry>
310
+ </component>
311
+ <component name="TimeTrackingManager">
312
+ <option name="totallyTimeSpent" value="22911000" />
313
+ </component>
314
+ <component name="ToolWindowManager">
315
+ <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
316
+ <layout>
317
+ <window_info anchor="bottom" id="TODO" order="6" />
318
+ <window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
319
+ <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
320
+ <window_info anchor="bottom" id="Version Control" order="7" />
321
+ <window_info anchor="bottom" id="Run" order="2" weight="0.32928178" />
322
+ <window_info active="true" anchor="bottom" id="Terminal" order="7" visible="true" weight="0.3325967" />
323
+ <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.18690096" />
324
+ <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
325
+ <window_info anchor="right" id="Database" order="3" />
326
+ <window_info anchor="bottom" id="Find" order="1" weight="0.32928178" />
327
+ <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
328
+ <window_info id="Favorites" order="2" side_tool="true" />
329
+ <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
330
+ <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
331
+ <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
332
+ <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
333
+ <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
334
+ <window_info anchor="bottom" id="Message" order="0" />
335
+ <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
336
+ </layout>
337
+ </component>
338
+ <component name="TypeScriptGeneratedFilesManager">
339
+ <option name="version" value="1" />
340
+ </component>
341
+ <component name="VcsContentAnnotationSettings">
342
+ <option name="myLimit" value="2678400000" />
343
+ </component>
344
+ <component name="VcsManagerConfiguration">
345
+ <MESSAGE value="Initial commit" />
346
+ <option name="LAST_COMMIT_MESSAGE" value="Initial commit" />
347
+ </component>
348
+ <component name="editorHistoryManager">
349
+ <entry file="file://$PROJECT_DIR$/lib/ush.rb">
350
+ <provider selected="true" editor-type-id="text-editor">
351
+ <state relative-caret-position="119">
352
+ <caret line="7" column="10" selection-start-line="7" selection-start-column="10" selection-end-line="7" selection-end-column="10" />
353
+ </state>
354
+ </provider>
355
+ </entry>
356
+ <entry file="file://$PROJECT_DIR$/lib/ush/version.rb">
357
+ <provider selected="true" editor-type-id="text-editor">
358
+ <state relative-caret-position="17">
359
+ <caret line="1" column="19" selection-start-line="1" selection-start-column="19" selection-end-line="1" selection-end-column="19" />
360
+ </state>
361
+ </provider>
362
+ </entry>
363
+ <entry file="file://$PROJECT_DIR$/lib/ush/app.rb">
364
+ <provider selected="true" editor-type-id="text-editor">
365
+ <state relative-caret-position="221">
366
+ <caret line="13" column="45" selection-start-line="13" selection-start-column="45" selection-end-line="13" selection-end-column="45" />
367
+ </state>
368
+ </provider>
369
+ </entry>
370
+ <entry file="file://$PROJECT_DIR$/exe/ush">
371
+ <provider selected="true" editor-type-id="text-editor">
372
+ <state relative-caret-position="68">
373
+ <caret line="4" column="13" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="13" />
374
+ </state>
375
+ </provider>
376
+ </entry>
377
+ <entry file="file://$PROJECT_DIR$/ush.gemspec">
378
+ <provider selected="true" editor-type-id="text-editor">
379
+ <state relative-caret-position="34">
380
+ <caret line="2" column="55" lean-forward="true" selection-start-line="2" selection-start-column="55" selection-end-line="2" selection-end-column="55" />
381
+ </state>
382
+ </provider>
383
+ </entry>
384
+ <entry file="file://$PROJECT_DIR$/lib/ush/crypto.rb">
385
+ <provider selected="true" editor-type-id="text-editor">
386
+ <state relative-caret-position="51">
387
+ <caret line="3" column="3" selection-start-line="3" selection-start-column="3" selection-end-line="3" selection-end-column="3" />
388
+ </state>
389
+ </provider>
390
+ </entry>
391
+ <entry file="file://$PROJECT_DIR$/lib/ush/db/sqlite.rb">
392
+ <provider selected="true" editor-type-id="text-editor">
393
+ <state relative-caret-position="408">
394
+ <caret line="24" column="17" lean-forward="true" selection-start-line="24" selection-start-column="17" selection-end-line="24" selection-end-column="17" />
395
+ </state>
396
+ </provider>
397
+ </entry>
398
+ <entry file="file://$PROJECT_DIR$/lib/ush/db.rb" />
399
+ <entry file="file://$PROJECT_DIR$/CODE_OF_CONDUCT.md">
400
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
401
+ <state split_layout="SPLIT">
402
+ <first_editor />
403
+ <second_editor />
404
+ </state>
405
+ </provider>
406
+ </entry>
407
+ <entry file="file://$PROJECT_DIR$/db/.keep">
408
+ <provider selected="true" editor-type-id="text-editor" />
409
+ </entry>
410
+ <entry file="file://$PROJECT_DIR$/.travis.yml">
411
+ <provider selected="true" editor-type-id="text-editor">
412
+ <state>
413
+ <caret column="11" selection-start-column="11" selection-end-column="11" />
414
+ </state>
415
+ </provider>
416
+ </entry>
417
+ <entry file="file://$PROJECT_DIR$/.gitignore">
418
+ <provider selected="true" editor-type-id="text-editor">
419
+ <state relative-caret-position="136">
420
+ <caret line="8" column="4" selection-start-line="8" selection-start-column="4" selection-end-line="8" selection-end-column="4" />
421
+ </state>
422
+ </provider>
423
+ </entry>
424
+ <entry file="file://$PROJECT_DIR$/.rubocop.yml">
425
+ <provider selected="true" editor-type-id="text-editor">
426
+ <state relative-caret-position="17">
427
+ <caret line="1" column="10" selection-start-line="1" selection-start-column="10" selection-end-line="1" selection-end-column="10" />
428
+ </state>
429
+ </provider>
430
+ </entry>
431
+ <entry file="file://$PROJECT_DIR$/README.md">
432
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
433
+ <state split_layout="SPLIT">
434
+ <first_editor relative-caret-position="68">
435
+ <caret line="4" column="15" selection-start-line="4" selection-start-column="15" selection-end-line="4" selection-end-column="15" />
436
+ </first_editor>
437
+ <second_editor />
438
+ </state>
439
+ </provider>
440
+ </entry>
441
+ <entry file="file://$PROJECT_DIR$/lib/ush/app.rb">
442
+ <provider selected="true" editor-type-id="text-editor">
443
+ <state relative-caret-position="17">
444
+ <caret line="1" column="17" selection-start-line="1" selection-start-column="17" selection-end-line="1" selection-end-column="17" />
445
+ </state>
446
+ </provider>
447
+ </entry>
448
+ <entry file="file://$PROJECT_DIR$/lib/ush/crypto.rb">
449
+ <provider selected="true" editor-type-id="text-editor">
450
+ <state relative-caret-position="102">
451
+ <caret line="6" column="3" selection-start-line="6" selection-start-column="3" selection-end-line="6" selection-end-column="3" />
452
+ </state>
453
+ </provider>
454
+ </entry>
455
+ <entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
456
+ <provider selected="true" editor-type-id="text-editor">
457
+ <state relative-caret-position="85">
458
+ <caret line="5" column="59" selection-start-line="5" selection-start-column="59" selection-end-line="5" selection-end-column="59" />
459
+ </state>
460
+ </provider>
461
+ </entry>
462
+ <entry file="file://$PROJECT_DIR$/spec/ush_spec.rb">
463
+ <provider selected="true" editor-type-id="text-editor">
464
+ <state relative-caret-position="136">
465
+ <caret line="8" column="5" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
466
+ </state>
467
+ </provider>
468
+ </entry>
469
+ <entry file="file://$PROJECT_DIR$/exe/ush">
470
+ <provider selected="true" editor-type-id="text-editor">
471
+ <state relative-caret-position="102">
472
+ <caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
473
+ </state>
474
+ </provider>
475
+ </entry>
476
+ <entry file="file://$PROJECT_DIR$/lib/ush/db/sqlite.rb">
477
+ <provider selected="true" editor-type-id="text-editor">
478
+ <state relative-caret-position="131">
479
+ <caret line="13" column="39" selection-start-line="13" selection-start-column="39" selection-end-line="13" selection-end-column="39" />
480
+ </state>
481
+ </provider>
482
+ </entry>
483
+ <entry file="file://$PROJECT_DIR$/lib/ush.rb">
484
+ <provider selected="true" editor-type-id="text-editor">
485
+ <state relative-caret-position="170">
486
+ <caret line="10" column="5" selection-start-line="10" selection-start-column="5" selection-end-line="10" selection-end-column="5" />
487
+ </state>
488
+ </provider>
489
+ </entry>
490
+ <entry file="file://$PROJECT_DIR$/ush.gemspec">
491
+ <provider selected="true" editor-type-id="text-editor">
492
+ <state relative-caret-position="374">
493
+ <caret line="22" column="38" selection-start-line="22" selection-start-column="38" selection-end-line="22" selection-end-column="38" />
494
+ </state>
495
+ </provider>
496
+ </entry>
497
+ <entry file="file://$PROJECT_DIR$/lib/ush/version.rb">
498
+ <provider selected="true" editor-type-id="text-editor">
499
+ <state relative-caret-position="51">
500
+ <caret line="3" lean-forward="true" selection-start-line="3" selection-end-line="3" />
501
+ </state>
502
+ </provider>
503
+ </entry>
504
+ </component>
505
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Metrics/LineLength:
2
+ Max: 120
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at cbawsome77@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ush.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 thecarterb
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Ush
2
+
3
+ ush (**U**rl **SH**ortener) is a small service that will shorten urls in a snap.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ush'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ush
20
+
21
+ ## Usage
22
+
23
+ Install the gem and run `ush`. After that, your service should be running at `localhost:80`
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cbrnrd/ush. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the Ush project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cbrnrd/ush/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ush"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/db/.keep ADDED
File without changes
data/exe/ush ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require "ush"
6
+
7
+ Ush::App.run!
data/lib/ush/app.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'sinatra/base'
2
+ require 'ush/db/sqlite'
3
+ module Ush
4
+ # The sinatra app that runs ush
5
+ class App < Sinatra::Base
6
+ set :server, 'webrick'
7
+ set :environment, :production
8
+ set :port, 80
9
+ db = Ush::Sqlite.new
10
+
11
+ get '/' do
12
+ "Your 'ush' deployment seems to be working!"
13
+ end
14
+
15
+ get '/:code' do
16
+ escaped = Addressable::URI.escape(params[:code])
17
+ url = db.get_url_for_code(params[:code])
18
+ puts url
19
+ puts url.class
20
+ if url.instance_of? NilClass
21
+ status 404
22
+ "path `#{escaped}` does not exist"
23
+ else
24
+ redirect url
25
+ end
26
+ end
27
+
28
+ post '/' do
29
+ if params[:code].nil? && !params[:url].nil?
30
+ db.add_url(Ush::Adapter.parse_url(params[:url]), Ush::Adapter.shorten(params[:url]))
31
+ response.headers['Location'] = File.join(request.url, Ush::Adapter.shorten(params[:url]))
32
+ elsif params[:url].nil?
33
+ status 400
34
+ "'url' parameter is not set"
35
+ else
36
+
37
+ if db.code_exists?(params[:code]) # If there is already a url shortened
38
+ status 409
39
+ return Ush::DuplicateCodeError.message(params[:url], params[:code])
40
+ end
41
+ db.add_url(Ush::Adapter.parse_url(params[:url]), params[:code])
42
+ loc = File.join(request.url, params[:code])
43
+ response.headers['Location'] = loc
44
+ "Shortlink created at #{loc}"
45
+ end
46
+ end
47
+
48
+ # Strips nasty characters in the given string. Used for parsing shortcodes.
49
+ def simple_escape(s)
50
+ s = s.to_s
51
+ s.gsub! /<|>/, ''
52
+ s
53
+ end
54
+ end
55
+ end
data/lib/ush/crypto.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'securerandom'
2
+
3
+ # This function is not used, but should be used in the future
4
+ def random_hex(len=16)
5
+ raise NotImplementedError
6
+ SecureRandom.hex(len)
7
+ end
@@ -0,0 +1,52 @@
1
+ require 'sqlite3'
2
+ require 'fileutils'
3
+
4
+ module Ush
5
+ class Sqlite
6
+ # An accessor to the underlying Sqlite3::Database instance
7
+ attr_accessor :db
8
+
9
+ # Initializes the database connection and creates the table if it doesn't exist already
10
+ def initialize(file = File.expand_path(File.join(File.dirname(__FILE__), '../../../db/ush.sqlite.db')))
11
+ FileUtils.touch(file) unless File.exist?(file) # create the db if it doesnt already exist
12
+ puts "Database is being stored at #{file}"
13
+ @db = SQLite3::Database.new(file)
14
+ @db.execute 'CREATE TABLE IF NOT EXISTS pairings(url TEXT, code TEXT)'
15
+ end
16
+
17
+ # Adds a url and shortcode association to the database
18
+ def add_url(url, shortcode)
19
+ @db.execute "INSERT INTO pairings VALUES('#{url}', '#{shortcode}')"
20
+ return true
21
+ rescue SQLite3::Exception => e
22
+ puts 'Unable to add url:'
23
+ puts e
24
+ return false
25
+ end
26
+
27
+ # Gets the associated url for the given shortcode
28
+ def get_url_for_code(code)
29
+ statement = @db.prepare("SELECT * FROM pairings WHERE code='#{code}'")
30
+ rs = statement.execute
31
+ rs.each do |row|
32
+ return row[0] # if row.class == Array # This is the first url, shouldn't be more than one.
33
+ end
34
+ rescue SQLite3::Exception => e
35
+ puts "Unable to get url for code #{code}"
36
+ puts e
37
+ end
38
+
39
+ # Checks if the given shortcode exists within the database
40
+ def code_exists?(code)
41
+ statement = @db.prepare("SELECT * FROM pairings WHERE code='#{code}'")
42
+ rs = statement.execute
43
+ rs.each do |row|
44
+ return true if row != ''
45
+ return false
46
+ end
47
+ rescue SQLite3::Exception => e
48
+ puts "Unable to get url for code #{code}"
49
+ puts e
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module Ush
2
+ VERSION = '0.1.0b'.freeze
3
+ end
data/lib/ush.rb ADDED
@@ -0,0 +1,45 @@
1
+ require "ush/app"
2
+ require "ush/db/sqlite"
3
+ require "ush/crypto"
4
+ require 'base64'
5
+ require 'digest/sha2'
6
+ require 'addressable/uri'
7
+
8
+ module Ush
9
+
10
+ class Error < StandardError
11
+ end
12
+
13
+ # The message that the user recieves when they try to associate a used shortcode
14
+ class DuplicateCodeError
15
+ def self.message(new, code)
16
+ "#{new} cannot be registered as '#{code}' because '#{code}' is already registered!"
17
+ end
18
+ end
19
+
20
+ class Adapter
21
+
22
+ # Shortens a url to a given 6 character string
23
+ # Adapted from https://github.com/technoweenie/guillotine
24
+ #
25
+ # 1. SHA256 hash the url to hexdigest
26
+ # 2. Convert to Bignum
27
+ # 3. Pack it to a bitstring (big-endian int)
28
+ # 4. b64encode the bitstring removeing trailing junk
29
+ # 5. xor final string with a random value TODO
30
+ def self.shorten(url)
31
+ Base64.urlsafe_encode64([Digest::SHA256.hexdigest(url).to_i(16)].pack("N")).sub(/==\n?$/, '')
32
+ end
33
+
34
+ # Strips a url of basic badchars
35
+ def self.parse_url(url)
36
+ url.gsub!(/\s/, '')
37
+ url.gsub!(/\?.*/, '')
38
+ url.gsub!(/\#.*/, '')
39
+ Addressable::URI.parse(url).to_s
40
+ end
41
+
42
+ end
43
+
44
+
45
+ end
data/ush.gemspec ADDED
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ush/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ush'
8
+ spec.version = Ush::VERSION
9
+ spec.authors = ['cbrnrd']
10
+ spec.email = ['cbawsome77@gmail.com']
11
+
12
+ spec.summary = 'An ultra portable url shortener'
13
+ spec.homepage = 'https://github.com/cbrnrd/ush'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_runtime_dependency('addressable', '~> 2.3.0')
24
+ spec.add_runtime_dependency 'sinatra', '~> 2.0'
25
+ spec.add_runtime_dependency('sqlite3')
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.16'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
30
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ush
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0b
5
+ platform: ruby
6
+ authors:
7
+ - cbrnrd
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: addressable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description:
98
+ email:
99
+ - cbawsome77@gmail.com
100
+ executables:
101
+ - ush
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".idea/misc.xml"
107
+ - ".idea/modules.xml"
108
+ - ".idea/ush.iml"
109
+ - ".idea/vcs.xml"
110
+ - ".idea/workspace.xml"
111
+ - ".rspec"
112
+ - ".rubocop.yml"
113
+ - ".travis.yml"
114
+ - CODE_OF_CONDUCT.md
115
+ - Gemfile
116
+ - LICENSE.txt
117
+ - README.md
118
+ - Rakefile
119
+ - bin/console
120
+ - bin/setup
121
+ - db/.keep
122
+ - exe/ush
123
+ - lib/ush.rb
124
+ - lib/ush/app.rb
125
+ - lib/ush/crypto.rb
126
+ - lib/ush/db/sqlite.rb
127
+ - lib/ush/version.rb
128
+ - ush.gemspec
129
+ homepage: https://github.com/cbrnrd/ush
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">"
145
+ - !ruby/object:Gem::Version
146
+ version: 1.3.1
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.6.14
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: An ultra portable url shortener
153
+ test_files: []