xkcd_downloader 0.1.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 +7 -0
- data/lib/xkcd_downloader.rb +30 -0
- metadata +58 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 2bd0e4cdde35a41a7b67f41509ccd4298942f409
         | 
| 4 | 
            +
              data.tar.gz: 6c066df4e90acafedcd4e8edda2c25f4ffe7f73c
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: d1ca13b25cafea71a34d74be52fd4b3eccac9e8991a979864aa06514aada9080ed3b6415fe2417ea18664f58bbb2170e7a8edff7ff38a38d928ac512871ebbf2
         | 
| 7 | 
            +
              data.tar.gz: af2fa2b22fcd52b5aac913f12151861efa2a9b242b4382fc91b248cc1f153ce2761d97daee4f91c408bcf83740d75da428d03d318ed6f9f15bc042e88ef8f7ec
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            #!/usr/bin/ruby
         | 
| 2 | 
            +
            require 'mechanize'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            $agent = Mechanize.new
         | 
| 5 | 
            +
            $pwd = Dir.pwd
         | 
| 6 | 
            +
             | 
| 7 | 
            +
             | 
| 8 | 
            +
             | 
| 9 | 
            +
            def get_xkcd(number, caption = false, location = nil,name = nil)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            	page = $agent.get("http://xkcd.com/#{number}/")
         | 
| 12 | 
            +
            	comic = page.image_with(:src => /\/comics\//)
         | 
| 13 | 
            +
            	last_dot = comic.src.rindex('.')
         | 
| 14 | 
            +
            	extension = comic.src[last_dot..-1]
         | 
| 15 | 
            +
            	if location.nil?
         | 
| 16 | 
            +
            		location = $pwd
         | 
| 17 | 
            +
            	end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            	if name.nil? 
         | 
| 20 | 
            +
            		name = "\##{number} - "+comic.alt
         | 
| 21 | 
            +
            	end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            	path_to_file = location+'/'+name
         | 
| 24 | 
            +
            	comic.fetch.save path_to_file + extension
         | 
| 25 | 
            +
            	if caption
         | 
| 26 | 
            +
            		File.open(path_to_file + " - caption",'w') do |f|
         | 
| 27 | 
            +
            			f.write comic.title
         | 
| 28 | 
            +
            		end
         | 
| 29 | 
            +
            	end
         | 
| 30 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: xkcd_downloader
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Ravi Kumar
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-04-15 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: mechanize
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 2.7.3
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 2.7.3
         | 
| 27 | 
            +
            description: A simple xkcd comic downloading gem see [blog post] for more info.
         | 
| 28 | 
            +
            email: upman116@gmail.com
         | 
| 29 | 
            +
            executables: []
         | 
| 30 | 
            +
            extensions: []
         | 
| 31 | 
            +
            extra_rdoc_files: []
         | 
| 32 | 
            +
            files:
         | 
| 33 | 
            +
            - lib/xkcd_downloader.rb
         | 
| 34 | 
            +
            homepage: http://rubygems.org/gems/xkcd_downloader
         | 
| 35 | 
            +
            licenses:
         | 
| 36 | 
            +
            - MIT
         | 
| 37 | 
            +
            metadata: {}
         | 
| 38 | 
            +
            post_install_message: 
         | 
| 39 | 
            +
            rdoc_options: []
         | 
| 40 | 
            +
            require_paths:
         | 
| 41 | 
            +
            - lib
         | 
| 42 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
              requirements:
         | 
| 44 | 
            +
              - - ">="
         | 
| 45 | 
            +
                - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                  version: '0'
         | 
| 47 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 48 | 
            +
              requirements:
         | 
| 49 | 
            +
              - - ">="
         | 
| 50 | 
            +
                - !ruby/object:Gem::Version
         | 
| 51 | 
            +
                  version: '0'
         | 
| 52 | 
            +
            requirements: []
         | 
| 53 | 
            +
            rubyforge_project: 
         | 
| 54 | 
            +
            rubygems_version: 2.2.1
         | 
| 55 | 
            +
            signing_key: 
         | 
| 56 | 
            +
            specification_version: 4
         | 
| 57 | 
            +
            summary: Download xkcd comics
         | 
| 58 | 
            +
            test_files: []
         |