cliz 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cliz +2 -16
  3. data/lib/functions.rb +17 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff3f968702225f2eca11654dc309d70faa3ffba83da660aa1c6b570d759a2719
4
- data.tar.gz: 4d7c5ec22057ba4985b3076def8901abf35eb023c14d4d5bf8ef7031f70cf790
3
+ metadata.gz: 3244d06cf94a457489f61c5f74aa87e38809ddf73ae1d4afff4cd1223e3bf20a
4
+ data.tar.gz: 555842ee24707775b95c7cdedac5e1f0a385454951987b6e10317baec436e8c5
5
5
  SHA512:
6
- metadata.gz: e40b13d6b3d477e31ca9c308d5a439f0536ded157e17774f2730584c25df56cf48f43833ba376bd796796d9a9dcd942de0ee9c2082af9da069e452a57bb8b81f
7
- data.tar.gz: d87a0a516beb1d428582324849c8018461dbcaac577c31284824f7674cb47761ec0a015462eac7f1d09842b296abc90bf93b60a0b9ef710d574b630f0cd73ad3
6
+ metadata.gz: 04da2ae52ffb1b8756e349f8e177751d5040bb4309f8ff00c19deb2d8229fce35f704a0be5335da0ae382c208b15eb314ab3d08b8ca625b64cc41a58889d9a50
7
+ data.tar.gz: 8baec4b0aa47d518723a56be58113c1f5436e0ae75638592c10d045babeccfac395117d0becdd5630b2e6fc5c4fdfd100b229ef63f6c976b70930b72ed7bd703
data/bin/cliz CHANGED
@@ -7,21 +7,7 @@ require_relative '../lib/functions.rb'
7
7
 
8
8
 
9
9
  config = YAML.load(File.read('config.yml'))
10
-
11
- OUTPUT_DIR = config['output_dir']
12
- BASE_DOMAIN = config['base_domain']
13
- DEPLOY_SCRIPT = config['deploy_script']
14
- PRE_SCRIPT = config['pre_script']
15
-
16
10
  url = ARGV[0]
17
11
  short_suggestion = ARGV[1]
18
-
19
- system("sh #{PRE_SCRIPT}") if PRE_SCRIPT
20
-
21
- short_suggestion ||= generate_short_suggestion OUTPUT_DIR
22
- folder_path = get_a_folder_path OUTPUT_DIR, short_suggestion
23
- create_index_file(url, folder_path)
24
-
25
- system("sh #{DEPLOY_SCRIPT}") if DEPLOY_SCRIPT
26
-
27
- puts File.join BASE_DOMAIN, short_suggestion
12
+ short_url = short config, url, short_suggestion
13
+ puts short_url
data/lib/functions.rb CHANGED
@@ -54,4 +54,21 @@ def create_index_file url, folder_path
54
54
  File.open "#{folder_path}/index.html", 'w' do |f|
55
55
  f.puts redirect_content
56
56
  end
57
+ end
58
+
59
+ def short config, url, short_suggestion = nil
60
+ output_dir = config['output_dir']
61
+ base_domain = config['base_domain']
62
+ deploy_script = config['deploy_script']
63
+ pre_script = config['pre_script']
64
+
65
+ system("sh #{pre_script}") if pre_script
66
+
67
+ short_suggestion ||= generate_short_suggestion output_dir
68
+ folder_path = get_a_folder_path output_dir, short_suggestion
69
+ create_index_file(url, folder_path)
70
+
71
+ system("sh #{deploy_script}") if deploy_script
72
+
73
+ File.join base_domain, short_suggestion
57
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cliz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karthikeyan A K
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-24 00:00:00.000000000 Z
11
+ date: 2021-04-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Cliz - The static URL shortner
14
14
  email: mindaslab@protonmail.com