zbox 0.0.1
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/zbox.rb +8 -0
- data/lib/zbox/img/qm_ext.rb +29 -0
- data/lib/zbox/myext/array.rb +0 -0
- data/lib/zbox/myext/hash.rb +5 -0
- data/lib/zbox/myext/numeric.rb +5 -0
- data/lib/zbox/myext/struct.rb +5 -0
- data/lib/zbox/myext/time.rb +20 -0
- data/lib/zbox/version.rb +3 -0
- data/zbox.gemspec +22 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/lib/zbox.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "quick_magick"
|
2
|
+
module Zbox
|
3
|
+
module QmExt
|
4
|
+
def self.resize(filepath,opts={})
|
5
|
+
allsize={:small=>[160,112],:middle=>[320,224],:default=>[640,480]}
|
6
|
+
if opts[:width] and opts[:height]
|
7
|
+
mw = opts[:width]
|
8
|
+
mh = opts[:height]
|
9
|
+
elsif opts[:size]
|
10
|
+
size = allsize[opts[:size]]
|
11
|
+
mw,mh = size[0],size[1]
|
12
|
+
else
|
13
|
+
size = allsize[:default]
|
14
|
+
mw,mh = size[0],size[1]
|
15
|
+
end
|
16
|
+
|
17
|
+
img = QuickMagick::Image.open(filepath).first
|
18
|
+
w,h=img.width,img.height
|
19
|
+
return if w<mw
|
20
|
+
if opts[:percent]
|
21
|
+
img.resize opts[:percent]
|
22
|
+
#img.save filepath
|
23
|
+
else
|
24
|
+
img.resize "#{mw}x#{mh}!"
|
25
|
+
end
|
26
|
+
img.save!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Time
|
3
|
+
def to_fmt1
|
4
|
+
strftime("%Y-%m-%d %H:%M")
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_date1
|
8
|
+
year=self.year
|
9
|
+
month=self.month
|
10
|
+
day=self.day
|
11
|
+
year.to_s+"年"+month.to_s+"月"+day.to_s+"日"
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_date2
|
15
|
+
year=self.year
|
16
|
+
month=self.month
|
17
|
+
day=self.day
|
18
|
+
year.to_s+"-"+month.to_s+"-"+day.to_s
|
19
|
+
end
|
20
|
+
end
|
data/lib/zbox/version.rb
ADDED
data/zbox.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "zbox/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "zbox"
|
7
|
+
s.version = Zbox::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.add_dependency('quick_magick')
|
10
|
+
s.authors = ["zxy"]
|
11
|
+
s.email = ["zxy@qq.com"]
|
12
|
+
s.homepage = ""
|
13
|
+
s.summary = %q{zxy's ruby toolbox'}
|
14
|
+
s.description = %q{zxy's ruby tool collections'}
|
15
|
+
|
16
|
+
s.rubyforge_project = "zbox"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zbox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- zxy
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-21 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: quick_magick
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
description: zxy's ruby tool collections'
|
27
|
+
email:
|
28
|
+
- zxy@qq.com
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- Gemfile
|
38
|
+
- Rakefile
|
39
|
+
- lib/zbox.rb
|
40
|
+
- lib/zbox/img/qm_ext.rb
|
41
|
+
- lib/zbox/myext/array.rb
|
42
|
+
- lib/zbox/myext/hash.rb
|
43
|
+
- lib/zbox/myext/numeric.rb
|
44
|
+
- lib/zbox/myext/struct.rb
|
45
|
+
- lib/zbox/myext/time.rb
|
46
|
+
- lib/zbox/version.rb
|
47
|
+
- zbox.gemspec
|
48
|
+
homepage: ""
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: zbox
|
71
|
+
rubygems_version: 1.7.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: zxy's ruby toolbox'
|
75
|
+
test_files: []
|
76
|
+
|