itools 0.1.8 → 0.1.9

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f063982f398eca1698f30ff40f9d9ab5c010aa82430d9294d449727c67ada56e
4
- data.tar.gz: 1842d947617713fbed541fa733d010b2ef4fc381b97be952a4390eef43bb1854
3
+ metadata.gz: d5a2dd0a4c63ba9c35827381356062ecc73673d8fba4cc2ef54283cf22bb4adb
4
+ data.tar.gz: 54362d1c7d7d99f68b2d71b03375ea9d8660ffbfa826ead96e4b9fd94d590d15
5
5
  SHA512:
6
- metadata.gz: 6ea0e05de8c8013bac3cff981399160448baf9285c06b21b001f25ed0ebd555d75d82236ab8a03606093b72e83285986fdc601f89259a30019c18190e7bf4012
7
- data.tar.gz: b552c4c0e4e04e24dc26e7184b0565ff99967ffad72e31ed09545de4dc71a20c40801d7b6b95f4cbcabeccd5a6c054ba1068924235db9660d5c9cea90dc1af52
6
+ metadata.gz: 76ebe6bd9d8a65f74fe64ec7f5b3f7528e6a7658ebc8f0855eb630e3ddf27d90338cc8f3db3a20e8391cdc199a6848be1c327c61ddba729b01501b2918f8a9f2
7
+ data.tar.gz: 7383afa8bfbfbc7d441164d63cad0298321d8518cf6dde2fd86f5648698e4ec4d2135e96aa28d7403eac7595c69f3cbabbb761b34c3899ecd8907a0e9b7dce4c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itools (0.1.8)
4
+ itools (0.1.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -89,6 +89,12 @@ itools find /Users/zhanggui/zhanggui/tdp
89
89
  先将目录下面所有的图片(仅支持png、jpg、gif)找到,然后遍历所有.m文件。查找出没有使用的图片。
90
90
  **注:这里查找不太准确,仅供参考,因为有可能有的图片不是通过.m文件使用的。而有的图片仅仅是为了配置(例如1024*1024),所以还是不要依赖该工具的图片查找,找到之后可以自行再次确认一下。**
91
91
 
92
+ ### 功能4:计算文件大小
93
+ 命令
94
+ ```
95
+ itools sizeFor /Users/zhanggui/zhanggui/my 1000(or 1024)
96
+ ```
97
+ 计算sizeFor后面跟的参数内容所占内存大小,如果参数为文件路径,则计算文件大小,如果是文件夹,会遍历所有文件,然后计算大小。第二个参数为计算系数(windows为1024,mac为1000,不传默认为1024)
92
98
  ## Contributing
93
99
 
94
100
  Bug reports and pull requests are welcome on GitHub at https://github.com/ScottZg/itools. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
data/bin/itools CHANGED
@@ -35,7 +35,7 @@ desc "calculate the memory footprint of file or folder(contain file)"
35
35
  arg 'xxx.txt'
36
36
  command :sizeFor do |c|
37
37
  c.action do |global_options, options, args|
38
- Itools::Memory.sizeFor(args[0])
38
+ Itools::Memory.sizeFor(args)
39
39
  end
40
40
  end
41
41
  exit run(ARGV)
@@ -1,8 +1,16 @@
1
1
  require 'find'
2
2
  module Itools
3
3
  class Memory
4
+ attr_accessor :pro
4
5
  # 分发吹
5
- def hand_cal_size(file)
6
+ def hand_cal_size(file,prop)
7
+ if prop.nil?
8
+ @pro = 1024
9
+ elsif prop == 0
10
+ @pro = 1024
11
+ else
12
+ @pro = prop
13
+ end
6
14
  handle_method = ''
7
15
  if File.file?(file)
8
16
  puts "\033[32m开始计算文件的大小...\033[0m"
@@ -36,22 +44,24 @@ module Itools
36
44
  end
37
45
  # get_show_size
38
46
  def get_show_size(size)
39
- if size > 1024 * 1024
40
- return format("%.2f",(size.to_f/(1024*1024))) + "MB"
41
- elsif size > 1024
42
- return format("%.2f",(size.to_f/1024)) + "KB"
47
+ if size > @pro * @pro
48
+ return format("%.2f",(size.to_f/(@pro*@pro))) + "MB"
49
+ elsif size > @pro
50
+ return format("%.2f",(size.to_f/@pro)) + "KB"
43
51
  else
44
52
  return size.to_s + "B"
45
53
  end
46
54
  end
47
55
  # 对外暴露方法
48
- def self.sizeFor(file)
56
+ def self.sizeFor(proport)
57
+ file = proport[0]
58
+ pro = proport[1].to_i
49
59
  if file.nil?
50
60
  puts "\033[31m参数异常,请传入一个参数\033[0m"
51
61
  return
52
62
  end
53
63
  memory = Memory.new
54
- memory.hand_cal_size(file)
64
+ memory.hand_cal_size(file,pro)
55
65
  end
56
66
  end
57
67
  end
@@ -1,3 +1,3 @@
1
1
  module Itools
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhanggui