vv 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f85730241772824e99721c4172486afcfda2bf780c1054617de82ab689b02cd
4
- data.tar.gz: 7d2aa4dfefa395bbf006cedd95d4364c74a9f2a0c7fb76f23e826a5f00050952
3
+ metadata.gz: 1c48205876964c325525e215eeb44d1102faaacbfdb6eaf7e13f87d8dac12ec8
4
+ data.tar.gz: 9cb5aba28717d98ccf01aed2ebbb3702e2018c3adececa15133d74d0f2afad3a
5
5
  SHA512:
6
- metadata.gz: 72731d67ba4dfe17b6915b49803a9392d4762c060e14dd067cb24cf9880610b95dc45f82823f185fbe29699f49a43cf201f1a9e2a42e3af2672ee8f662fe7d9e
7
- data.tar.gz: 44046a685b2f979e12d9db183c920f33553fad651b2df84c94f52d8939210db699483108e4a19b079f8edd865b0cf0366a03d81aef8ca8e60636c350e5af4846
6
+ metadata.gz: 21870db1e91747311a51a06e485580d6b461896872449cc0fc6000803ca809f293aafc1b51943e0601cc8fb4bb9be7ef04bfd52a281361ad1c35c61b57cf2d0d
7
+ data.tar.gz: a45e0f33c37dd46011270b2da869b5790703e7ab4e5c79fb2d073e7222544b65c7851649991a21769b30234ef34cc255c647e63b4b80670842f5a9b5c5892346
@@ -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
@@ -192,6 +192,10 @@ module VV
192
192
  raise
193
193
  end
194
194
 
195
+ def to_i!
196
+ Integer(self)
197
+ end
198
+
195
199
  def to_boolean
196
200
  _true = self == "true"
197
201
  return true if _true
data/lib/vv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module VV
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
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.3
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 00:00:00.000000000 Z
11
+ date: 2018-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake