phototrim 0.0.1 → 0.0.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjMwNDEzYjc5MmJkMTIyMDcwZGM3M2UzODMwMDdmODhiNTRjNGFiZA==
4
+ ZTQ4MzUxMzI4NzI0ZmRjMDQ1ODgxYWI1MDk0MWMwNzQ3MTI0Mjk3YQ==
5
5
  data.tar.gz: !binary |-
6
- MWNmNWQ1NDQyZThmNThmNzU5MzJmM2UyZjQwOGVkNWJlOWUwM2UyOA==
6
+ MzI2ZDhiMWZkYzkwNWIxZDZlMjRiOTc5YmRlMDVjYWJmNDhmMDMwOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTkwMjUwYTU4MTBmZmIxZGJiNDUzNDljNjEzMmRlZGFmNWU2NWNjZjdmYzJm
10
- YTI2OThmYzZmNjQyNGExNDNkZmJjYzkwNWM4Y2ZiMGE2MGM4ZDc5NDY3OTE5
11
- ZTQ0MDBiZDg4MTk5ZTg0MTNlYTk0ZTE2NzAyNGIwZTNmZDMyMjA=
9
+ ZWEzYWNhODViOTUxZGJjYjA3MzAyYWM5NzQyZTk3MTgxYjI3ZGI2NTJjZjA2
10
+ NTdhOWU1YjQ3NGYyOWI2MzA4MTg1MTM5NmZkN2E4YmQ3MDYxZjM2NmQyZDhk
11
+ NTY1YTQ3YmQ1MGM3YTgzMzJlNTJiNTAzNWY0YjM1YTM2NTI4NDU=
12
12
  data.tar.gz: !binary |-
13
- ZjM2ZjMyNTQyMDY4OTRlN2RmMmQ2NWEzZDAwZDM3M2I0Zjk2YjM5MzgxOGYy
14
- ODM5NzA0MjQ2ZDA3NDhiZjU1N2QzYjZlM2YyODU3M2I5Y2E4ODgwMWQxNjg5
15
- YjIzNmMzNmRkMDRlMzA5YTMzNThjY2Q1ODQ1M2NiMDY2NmY5YmI=
13
+ NzM3OGM5NzExMTZjYWVmNzhkNTI1OTdiNzg4YjMyMDRjY2M1MzA3ZDJhMDg2
14
+ MzNhNjEzOTA2ZmIwNWYyYzQ5ODI0ZDBkNTc0ZWUzMzkyMjMyYjIwNDk0YTYw
15
+ YmYwYjM3M2FhNDQ5OGRmNTRkOGJiMzUzOWE5MGQzODJmOTQ2MTA=
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in phototrim.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sarup Banskota
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Phototrim
2
+
3
+ Simple gem that helps with resizing a bunch of photos
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'phototrim'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install phototrim
18
+
19
+
20
+ ## Contributing
21
+
22
+ 1. Fork it ( https://github.com/sarupbanskota/phototrim/fork )
23
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
24
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
25
+ 4. Push to the branch (`git push origin my-new-feature`)
26
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'bundler/gem_tasks'
2
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
3
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ module Phototrim
2
+ VERSION = "0.0.3"
3
+ end
data/lib/phototrim.rb CHANGED
@@ -1,27 +1,30 @@
1
1
  #! /usr/local/bin/ruby -w
2
2
  # Sarup Banskota, 1 December 2014
3
-
3
+ require 'phototrim/version'
4
4
  require 'RMagick'
5
5
  include Magick
6
6
 
7
- Dir.foreach('images') do |subdir|
8
- unless subdir == "." or subdir == ".."
9
- print "Processing images within " + subdir.to_s + "\n"
10
- Dir.foreach(File.join("images", subdir)) do |victimfile|
11
- unless victimfile == "." or victimfile == ".." or File.extname(victimfile) == ".svg"
12
- print "Processing file " + victimfile + "\n"
13
- victim = ImageList.new(File.join("images", subdir, victimfile))
14
- if victim.columns > 640
15
- print victimfile.to_s + " is beyond 640px wide, scaling down.. \n"
16
- victim = victim.scale(640.0/victim.columns)
17
- print "Scaled down " + victimfile.to_s + ".\n"
18
- victim.write(File.join("images", subdir, victimfile))
19
- end
7
+ class Phototrim
8
+ def self.trim(max_size, root_dir)
9
+ Dir.foreach(root_dir) do |subdir|
10
+ unless subdir == "." or subdir == ".."
11
+ print "Processing images within " + subdir.to_s + "\n"
12
+ Dir.foreach(File.join(root_dir, subdir)) do |victimfile|
13
+ unless victimfile == "." or victimfile == ".." or File.extname(victimfile) == ".svg"
14
+ print "Processing file " + victimfile + "\n"
15
+ victim = ImageList.new(File.join(root_dir, subdir, victimfile))
16
+ if victim.columns > max_size
17
+ print victimfile.to_s + " is beyond " + max_size.to_s + "px wide, scaling down.. \n"
18
+ victim = victim.scale(max_size.to_f/victim.columns)
19
+ print "Scaled down " + victimfile.to_s + ".\n"
20
+ victim.write(File.join(root_dir, subdir, victimfile))
21
+ end
22
+ end
23
+ end
20
24
  end
21
25
  end
26
+
27
+ print "Done! \n"
22
28
  end
23
29
  end
24
30
 
25
- print "Done!"
26
-
27
- exit
data/phototrim.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'phototrim/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "phototrim"
8
+ spec.version = Phototrim::VERSION
9
+ spec.authors = ["Sarup Banskota"]
10
+ spec.email = ["sbanskota08@gmail.com"]
11
+ spec.summary = %q{Simple gem that helps with resizing a bunch of photos}
12
+ spec.description = %q{Makes simple calls to RMagick methods and scales photos}
13
+ spec.homepage = "http://rubygems.org/gems/phototrim"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'rmagick', '2.13.4'
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency 'rake', '~> 0'
24
+ end
metadata CHANGED
@@ -1,22 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phototrim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sarup Banskota
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-01 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Scales photos down to neat-ify blogs
14
- email: sarupbanskota@fedoraproject.org
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rmagick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.13.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.13.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Makes simple calls to RMagick methods and scales photos
56
+ email:
57
+ - sbanskota08@gmail.com
15
58
  executables: []
16
59
  extensions: []
17
60
  extra_rdoc_files: []
18
61
  files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
19
67
  - lib/phototrim.rb
68
+ - lib/phototrim/version.rb
69
+ - phototrim.gemspec
20
70
  homepage: http://rubygems.org/gems/phototrim
21
71
  licenses:
22
72
  - MIT
@@ -40,6 +90,5 @@ rubyforge_project:
40
90
  rubygems_version: 2.2.2
41
91
  signing_key:
42
92
  specification_version: 4
43
- summary: Phototrim
93
+ summary: Simple gem that helps with resizing a bunch of photos
44
94
  test_files: []
45
- has_rdoc: