rubisc 0.2.7 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a636160ed306d35c6e6cca307cd16de5c1aa161c
4
- data.tar.gz: 827ab785ad60b62b1a2c28e57f763bda4ce70c0f
3
+ metadata.gz: c49bc2a7aec55c9e35b652aaa8227a4bfe33b2e5
4
+ data.tar.gz: 47626f8865aa75de2fe6e77eb755ac3b8cd0f698
5
5
  SHA512:
6
- metadata.gz: 8876731916269b8172647d0c2e9e5c3a71e8dea4caef3fc618e45f1c61ccef81ed29b192720465714e9f48994edc10814ca4319cb4f9b41f4f27fb66af1157b0
7
- data.tar.gz: 91adcdb8d8bc619d1c224af617ea03e80dea34acc4a4d38bb6ee78c78753a0001947bc698ff22b51262c4f55806272a1e6f3999e6e7b9704dc6b9534d6026de9
6
+ metadata.gz: 662ca65a3c4db50f6ad15e36d0628b9840ab36a00a4a683b1b8173078c5f9ff93180993b6da9b347b93672d5c3aca05bca301192920653819a2a8a1521e89ba3
7
+ data.tar.gz: a5f430325507bc5d0708fdf073c945f3a3aedcad35798996920d5715e8a1ad7d82ed628d2aa311c19c460cda17456b4d3ded3454b74c5e0b0f92061f1ec21989
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib','fileutil')
4
+
5
+ unless ARGV[0] and ARGV[1]
6
+ puts "Usage: contains? <path> <regex>"
7
+ puts "Example: contains? mydir/ hello"
8
+ exit
9
+ end
10
+
11
+ unless File.exist? ARGV[0]
12
+ puts "#{ARGV[0]} does not exist."
13
+ puts "Please provide the path to the file or directory to process."
14
+ exit
15
+ end
16
+
17
+ path=ARGV[0]
18
+ pattern=ARGV[1]
19
+
20
+ contains=Rubisc::FileUtil::contains_pattern? path,pattern
21
+ raise "Assersion failure." unless contains
data/bin/pod-publish CHANGED
File without changes
data/bin/substitute CHANGED
@@ -9,39 +9,12 @@ unless ARGV[0] and ARGV[1] and ARGV[2]
9
9
  end
10
10
  unless File.exist? ARGV[0]
11
11
  puts "#{ARGV[0]} does not exist."
12
- puts "Please provide the path to the file or directory you want to manipulate."
12
+ puts "Please provide the path to the file or directory to process."
13
13
  exit
14
14
  end
15
15
 
16
16
  path=ARGV[0]
17
- @old_content=ARGV[1]
18
- @new_content=ARGV[2]
17
+ old_content=ARGV[1]
18
+ new_content=ARGV[2]
19
19
 
20
- def file_substitute file_path
21
- success=Rubisc::FileUtil::process_file file_path,true do |content|
22
- pattern=content.match /#{@old_content}/
23
- if !pattern
24
- puts "No matching found."
25
- end
26
- content=content.gsub /#{@old_content}/,@new_content
27
- end
28
- if !success
29
- puts 'Failed to process file '+file_path+'.'
30
- end
31
- end
32
-
33
- def dir_substitute path
34
- if path!="." and path!=".."
35
- if File.directory?(path)
36
- Dir.entries(path).each do |sub|
37
- if sub!="." and sub!=".."
38
- dir_substitute "#{path}/#{sub}"
39
- end
40
- end
41
- else
42
- file_substitute path
43
- end
44
- end
45
- end
46
-
47
- dir_substitute path
20
+ Rubisc::FileUtil::substitute path,old_content,new_content
data/lib/fileutil.rb CHANGED
@@ -28,5 +28,53 @@ module Rubisc
28
28
  file.close
29
29
  return true
30
30
  end
31
+
32
+ def self.substitute path,old_content,new_content
33
+ if path!="." and path!=".."
34
+ if File.directory?(path)
35
+ Dir.entries(path).each do |sub|
36
+ if sub!="." and sub!=".."
37
+ substitute "#{path}/#{sub}",old_content,new_content
38
+ end
39
+ end
40
+ else
41
+ file_substitute path,old_content,new_content
42
+ end
43
+ end
44
+ end
45
+
46
+ def self.file_substitute file_path,pattern,new_content
47
+ process_file file_path,true do |content|
48
+ matches=content.match /#{pattern}/
49
+ if !matches
50
+ puts "No matching found."
51
+ end
52
+ content=content.gsub /#{pattern}/,new_content
53
+ end
54
+ end
55
+
56
+ def self.contains_pattern? path,pattern
57
+ contains=false
58
+ if path!="." and path!=".."
59
+ if File.directory?(path)
60
+ Dir.entries(path).each do |sub|
61
+ if sub!="." and sub!=".."
62
+ contains=contains_pattern? "#{path}/#{sub}",pattern
63
+ end
64
+ end
65
+ else
66
+ contains=file_contains_pattern? path,pattern
67
+ end
68
+ end
69
+ contains
70
+ end
71
+
72
+ def self.file_contains_pattern? path,pattern
73
+ matches=nil
74
+ process_file path,false do |content|
75
+ matches=content.match /#{pattern}/
76
+ end
77
+ matches!=nil
78
+ end
31
79
  end
32
80
  end
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubisc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - luqyluqe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-21 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Wicked cool ruby scripts
14
14
  email: luqy.luqe@gmail.com
15
15
  executables:
16
+ - assert-contains
16
17
  - substitute
17
18
  - xcodeproj-scan
18
19
  - pod-publish
@@ -20,12 +21,13 @@ executables:
20
21
  extensions: []
21
22
  extra_rdoc_files: []
22
23
  files:
23
- - rubisc.rb
24
- - bin/substitute
25
- - bin/xcodeproj-scan
24
+ - bin/assert-contains
26
25
  - bin/pod-publish
27
26
  - bin/pod-publish.sh
27
+ - bin/substitute
28
+ - bin/xcodeproj-scan
28
29
  - lib/fileutil.rb
30
+ - rubisc.rb
29
31
  homepage: https://github.com/luqyluqe/Rubisc
30
32
  licenses:
31
33
  - MIT
@@ -36,17 +38,17 @@ require_paths:
36
38
  - lib
37
39
  required_ruby_version: !ruby/object:Gem::Requirement
38
40
  requirements:
39
- - - '>='
41
+ - - ">="
40
42
  - !ruby/object:Gem::Version
41
43
  version: '0'
42
44
  required_rubygems_version: !ruby/object:Gem::Requirement
43
45
  requirements:
44
- - - '>='
46
+ - - ">="
45
47
  - !ruby/object:Gem::Version
46
48
  version: '0'
47
49
  requirements: []
48
50
  rubyforge_project:
49
- rubygems_version: 2.0.14.1
51
+ rubygems_version: 2.6.11
50
52
  signing_key:
51
53
  specification_version: 4
52
54
  summary: Wicked cool ruby scripts