mk3 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/mk3 +17 -0
- data/lib/line_processor.rb +41 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 70ec535eda349802f887d959ef36257c8cde9a886b5b4c82fc6deb1b8cee17fe
|
4
|
+
data.tar.gz: e6672b8f3c8a2c53ffb58a406c0e4b7be5f6bb38a1571ad9a106a5915ae6641c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 59c60a43cd71ed4e745b44ad8db1cc804185a34687d2c07e7fc7105a7783ecff495fb913321a35bfc2fc6b451803c762e04071d6dddba7739e47152bde77d643
|
7
|
+
data.tar.gz: 255bac94b0f08a00f81328ec26e71fc060304ec489fc8d52218876c5c93fbfdc1987b43b47c0e72e152bbaa638ad167d90c351a1a5ffab7efef5eae2d5d97d50
|
data/bin/mk3
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# require 'pry'
|
4
|
+
require "tty-prompt"
|
5
|
+
require_relative '../lib/line_processor'
|
6
|
+
|
7
|
+
file = ARGV[0]
|
8
|
+
lines = nil
|
9
|
+
|
10
|
+
if file
|
11
|
+
lines = File.open(file, "r").readlines
|
12
|
+
else
|
13
|
+
prompt = TTY::Prompt.new
|
14
|
+
lines = prompt.multiline("Enter directory structure:")
|
15
|
+
end
|
16
|
+
|
17
|
+
Mk3.lines_processor lines
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
SPACE_LENGTH = 2
|
3
|
+
|
4
|
+
module Mk3
|
5
|
+
def self.create_direcory? line
|
6
|
+
line.match /\/$/
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.touch_file? line
|
10
|
+
! create_direcory? line
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.create_directory line
|
14
|
+
FileUtils.mkdir_p line.strip
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.touch_file line
|
18
|
+
FileUtils.touch(line.strip) unless line.strip.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.level line
|
22
|
+
match = line.match(/^\s+/)
|
23
|
+
match[0].size / SPACE_LENGTH if match
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.lines_processor lines
|
27
|
+
array = []
|
28
|
+
|
29
|
+
for line in lines
|
30
|
+
line_level = level(line).to_i
|
31
|
+
array[line_level] = line.strip
|
32
|
+
array = array[..line_level]
|
33
|
+
string = array.join
|
34
|
+
|
35
|
+
unless line.strip.empty?
|
36
|
+
create_directory(string) if create_direcory?(string)
|
37
|
+
touch_file(string) if touch_file?(string)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mk3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Karthikeyan A K
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tty-prompt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.23'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.23'
|
27
|
+
description:
|
28
|
+
email: mindaslab@protonmail.com
|
29
|
+
executables:
|
30
|
+
- mk3
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/mk3
|
35
|
+
- lib/line_processor.rb
|
36
|
+
homepage: https://gitlab.com/mindaslab/mk3
|
37
|
+
licenses:
|
38
|
+
- GPL-3.0-or-later
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubygems_version: 3.3.7
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: make directory and file tree
|
59
|
+
test_files: []
|