vv 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vv/file_methods.rb +57 -0
- data/lib/vv/string_methods.rb +4 -0
- data/lib/vv/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c48205876964c325525e215eeb44d1102faaacbfdb6eaf7e13f87d8dac12ec8
|
4
|
+
data.tar.gz: 9cb5aba28717d98ccf01aed2ebbb3702e2018c3adececa15133d74d0f2afad3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21870db1e91747311a51a06e485580d6b461896872449cc0fc6000803ca809f293aafc1b51943e0601cc8fb4bb9be7ef04bfd52a281361ad1c35c61b57cf2d0d
|
7
|
+
data.tar.gz: a45e0f33c37dd46011270b2da869b5790703e7ab4e5c79fb2d073e7222544b65c7851649991a21769b30234ef34cc255c647e63b4b80670842f5a9b5c5892346
|
data/lib/vv/file_methods.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
module VV
|
2
2
|
module FileMethods
|
3
3
|
|
4
|
+
def self.check_file_methods
|
5
|
+
ClassMethods.public_instance_methods.each do |method|
|
6
|
+
next if method.to_s.starts_with? "vv_"
|
7
|
+
|
8
|
+
message = \
|
9
|
+
"File defines method already, cowardly exiting."
|
10
|
+
fail message if File.respond_to? method
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
def self.included(base)
|
15
|
+
self.check_file_methods if base == File
|
16
|
+
|
5
17
|
base.extend(ClassMethods)
|
6
18
|
end
|
7
19
|
|
@@ -15,6 +27,51 @@ module VV
|
|
15
27
|
File.readlines(*args, **kwargs).map!(&:chomp)
|
16
28
|
end
|
17
29
|
|
30
|
+
def vv_split string
|
31
|
+
response = string.split(File::SEPARATOR)
|
32
|
+
response[0] = File::SEPARATOR if response.first.blank?
|
33
|
+
response
|
34
|
+
end
|
35
|
+
|
36
|
+
def repo_directory missing_throws_exception: true
|
37
|
+
directory_fragments = File.vv_split self.file_directory
|
38
|
+
|
39
|
+
while directory_fragments.any?
|
40
|
+
current_directory = File.join directory_fragments
|
41
|
+
|
42
|
+
supported_source_control_directories = %w(.git .hg)
|
43
|
+
|
44
|
+
supported_source_control_directories
|
45
|
+
.each do | directory |
|
46
|
+
full_path = File.join current_directory, directory
|
47
|
+
path_exists = File.directory? full_path
|
48
|
+
return current_directory if path_exists
|
49
|
+
end
|
50
|
+
|
51
|
+
directory_fragments.pop
|
52
|
+
end
|
53
|
+
|
54
|
+
return unless missing_throws_exception
|
55
|
+
|
56
|
+
fail "No repository detected"
|
57
|
+
end
|
58
|
+
|
59
|
+
def file_directory
|
60
|
+
File.dirname caller_locations[0].path
|
61
|
+
end
|
62
|
+
|
63
|
+
def file
|
64
|
+
caller_locations[0].path
|
65
|
+
end
|
66
|
+
|
67
|
+
def pwd
|
68
|
+
File.expand_path(Dir.pwd)
|
69
|
+
end
|
70
|
+
|
71
|
+
def separator
|
72
|
+
File::SEPARATOR
|
73
|
+
end
|
74
|
+
|
18
75
|
end
|
19
76
|
|
20
77
|
def vv_readlines
|
data/lib/vv/string_methods.rb
CHANGED
data/lib/vv/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Aysan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|