rubisc 0.1.3 → 0.2.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 +4 -4
 - data/bin/substitute +1 -1
 - data/lib/fileutil.rb +2 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 197848ffd9fc6c255962d98c3b3b1bfe456b06ce
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 85b3833b812595960f719c48b5a9b793db614c6f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b1a57984823c174fc5fcab371d88282d6b6d1fd85d86c4c74814e67e4b42bf34adcf6a536a7f088afe82a0801e62eb5e36a3827fb82d03aa705d274d7c637a5f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 560862c1f34c0a8a765d3a570223887b2ae1a057dfe1b5499da7e260bcc4f7507e4d9a4403d6965906e4276c2cc4aff33fa8bf25502c4cf2706b9b9c535138df
         
     | 
    
        data/bin/substitute
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ path=ARGV[0] 
     | 
|
| 
       18 
18 
     | 
    
         
             
            @new_content=ARGV[2]
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
            def file_substitute file_path
         
     | 
| 
       21 
     | 
    
         
            -
            	success=Rubisc::FileUtil::process_file 
     | 
| 
      
 21 
     | 
    
         
            +
            	success=Rubisc::FileUtil::process_file file_path,true do |content|
         
     | 
| 
       22 
22 
     | 
    
         
             
            		pattern=content.match /#{@old_content}/
         
     | 
| 
       23 
23 
     | 
    
         
             
            		if !pattern
         
     | 
| 
       24 
24 
     | 
    
         
             
            			puts "No matching found."
         
     | 
    
        data/lib/fileutil.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/ruby
         
     | 
| 
       2 
2 
     | 
    
         
             
            module Rubisc
         
     | 
| 
       3 
3 
     | 
    
         
             
            	module FileUtil
         
     | 
| 
       4 
     | 
    
         
            -
            		def self.process_file file_path
         
     | 
| 
      
 4 
     | 
    
         
            +
            		def self.process_file file_path,write
         
     | 
| 
       5 
5 
     | 
    
         
             
            			return true unless block_given?
         
     | 
| 
       6 
6 
     | 
    
         
             
            			if !File.file? file_path
         
     | 
| 
       7 
7 
     | 
    
         
             
            				puts "Not a file: "+file_path
         
     | 
| 
         @@ -18,6 +18,7 @@ module Rubisc 
     | 
|
| 
       18 
18 
     | 
    
         
             
            			end
         
     | 
| 
       19 
19 
     | 
    
         
             
            			content=yield content
         
     | 
| 
       20 
20 
     | 
    
         
             
            			file.close
         
     | 
| 
      
 21 
     | 
    
         
            +
            			return true unless write
         
     | 
| 
       21 
22 
     | 
    
         
             
            			file=File.new file_path,"w"
         
     | 
| 
       22 
23 
     | 
    
         
             
            			if !file
         
     | 
| 
       23 
24 
     | 
    
         
             
            				puts "Failed to write file "+file_path
         
     |