picpacput 0.0.1c → 0.0.2
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.
- data/lib/picpacput.rb +25 -4
 - data/lib/picpacput/version.rb +1 -1
 - metadata +5 -5
 
    
        data/lib/picpacput.rb
    CHANGED
    
    | 
         @@ -1,26 +1,31 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/ruby
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require 'find'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'tmpdir' # Dir.tmpdir
         
     | 
| 
      
 4 
     | 
    
         
            +
            #require 'tmpdir' # Dir.tmpdir
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       6 
6 
     | 
    
         
             
            require 'RMagick'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'zip/zip'
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
            class PicPacPut
         
     | 
| 
       10 
     | 
    
         
            -
              attr_accessor :folder, :extension, :scale_by, :outfolder, :ext_types
         
     | 
| 
      
 11 
     | 
    
         
            +
              attr_accessor :folder, :recursive, :extension, :scale_by, :outfolder, :ext_types
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
              def initialize( opts = {} )
         
     | 
| 
       13 
14 
     | 
    
         
             
                options = {
         
     | 
| 
       14 
15 
     | 
    
         
             
                  :folder => ('.'+File::SEPARATOR),
         
     | 
| 
      
 16 
     | 
    
         
            +
                  :recursive => true,
         
     | 
| 
       15 
17 
     | 
    
         
             
                  :extension => "*.JPG",
         
     | 
| 
       16 
18 
     | 
    
         
             
                  :scale_by => 0.05,
         
     | 
| 
      
 19 
     | 
    
         
            +
                  :zipFile => 'output.zip',
         
     | 
| 
       17 
20 
     | 
    
         
             
                  :outfolder => ('resized'+File::SEPARATOR),
         
     | 
| 
       18 
21 
     | 
    
         
             
                  :ext_types => ["png","PNG","jpg","JPG","jpeg","JPEG","gif","GIF","bmp","BMP"]
         
     | 
| 
       19 
22 
     | 
    
         
             
                }.merge(opts)
         
     | 
| 
       20 
23 
     | 
    
         
             
                @folder = options[:folder]
         
     | 
| 
      
 24 
     | 
    
         
            +
                @recursive = options[:recursive]
         
     | 
| 
       21 
25 
     | 
    
         
             
                @extension = options[:extension]
         
     | 
| 
       22 
26 
     | 
    
         
             
                @scale_by = options[:scale_by]
         
     | 
| 
       23 
27 
     | 
    
         
             
                @outfolder = options[:outfolder]
         
     | 
| 
      
 28 
     | 
    
         
            +
                @zipFile = options[:zipFile]
         
     | 
| 
       24 
29 
     | 
    
         
             
                @ext_types = options[:ext_types]
         
     | 
| 
       25 
30 
     | 
    
         
             
                Dir.mkdir(@outfolder) unless File.exists?(@outfolder)
         
     | 
| 
       26 
31 
     | 
    
         
             
              end
         
     | 
| 
         @@ -51,7 +56,10 @@ class PicPacPut 
     | 
|
| 
       51 
56 
     | 
    
         
             
                end
         
     | 
| 
       52 
57 
     | 
    
         
             
              end
         
     | 
| 
       53 
58 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
              def  
     | 
| 
      
 59 
     | 
    
         
            +
              def pic
         
     | 
| 
      
 60 
     | 
    
         
            +
                if not @recursive
         
     | 
| 
      
 61 
     | 
    
         
            +
                  return thumbit
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
       55 
63 
     | 
    
         
             
                dirList = []
         
     | 
| 
       56 
64 
     | 
    
         
             
                Find.find(@folder) do |f|
         
     | 
| 
       57 
65 
     | 
    
         
             
                  if !!f[@outfolder]
         
     | 
| 
         @@ -67,7 +75,20 @@ class PicPacPut 
     | 
|
| 
       67 
75 
     | 
    
         
             
                end
         
     | 
| 
       68 
76 
     | 
    
         
             
                dirList
         
     | 
| 
       69 
77 
     | 
    
         
             
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              def pac
         
     | 
| 
      
 80 
     | 
    
         
            +
                Zip::ZipFile.open( @outfolder + File::SEPARATOR + @zipFile, Zip::ZipFile::CREATE) do |zipfile|
         
     | 
| 
      
 81 
     | 
    
         
            +
                  Dir.glob( @outfolder + File::SEPARATOR + '*' ).each do |filename|
         
     | 
| 
      
 82 
     | 
    
         
            +
                    filename.gsub!(File::SEPARATOR*2, File::SEPARATOR)
         
     | 
| 
      
 83 
     | 
    
         
            +
                    if File.directory?(filename) or !!filename[@zipFile]
         
     | 
| 
      
 84 
     | 
    
         
            +
                      next
         
     | 
| 
      
 85 
     | 
    
         
            +
                    end
         
     | 
| 
      
 86 
     | 
    
         
            +
                    zipfile.add(filename, filename)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
       70 
90 
     | 
    
         
             
            end
         
     | 
| 
       71 
91 
     | 
    
         | 
| 
       72 
92 
     | 
    
         
             
            #picpacput = PicPacPut.new
         
     | 
| 
       73 
     | 
    
         
            -
            #picpacput. 
     | 
| 
      
 93 
     | 
    
         
            +
            #picpacput.pic
         
     | 
| 
      
 94 
     | 
    
         
            +
            #picpacput.pac
         
     | 
    
        data/lib/picpacput/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: picpacput
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
       5 
     | 
    
         
            -
              prerelease:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Daniel P. Clark / 6ftDan(TM)
         
     | 
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012-12- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-12-19 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rmagick
         
     | 
| 
         @@ -56,9 +56,9 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       56 
56 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       57 
57 
     | 
    
         
             
              none: false
         
     | 
| 
       58 
58 
     | 
    
         
             
              requirements:
         
     | 
| 
       59 
     | 
    
         
            -
              - - ! ' 
     | 
| 
      
 59 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
       60 
60 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       61 
     | 
    
         
            -
                  version:  
     | 
| 
      
 61 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       62 
62 
     | 
    
         
             
            requirements: []
         
     | 
| 
       63 
63 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       64 
64 
     | 
    
         
             
            rubygems_version: 1.8.24
         
     |