ld 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +4 -0
- data/.idea/ld.iml +17 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +6 -0
- data/.idea/workspace.xml +49 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ld.gemspec +35 -0
- data/lib/ld/dir.rb +123 -0
- data/lib/ld/excel.rb +623 -0
- data/lib/ld/file.rb +82 -0
- data/lib/ld/node.rb +13 -0
- data/lib/ld/nodes.rb +33 -0
- data/lib/ld/tree.rb +39 -0
- data/lib/ld/version.rb +3 -0
- data/lib/ld.rb +32 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5d91fc3a83e79352469f61903e256d7b941a583c
|
4
|
+
data.tar.gz: fd5280f76340e73134a3450a19302fcc68beef91
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55e14a702a0c834b341729f4ec5120df3d09abdcd64925d4ad18c7d7961b45648eb721cd0f24abb267d1a693446eaa4d9f058d7b2be39954c26bd4e471b1e878
|
7
|
+
data.tar.gz: b40e2682c4a11070d8231a1149c861767325f8826d0fca0ff829b9b964928a1d6a222f9a9bfb8138bb7d482bba27cfe64a01ffc7c7b0ed6b2f1a8d86ea1eba70
|
data/.gitignore
ADDED
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build ld-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install ld-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.1.0 and build and push ld-0.1.0.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="" fullCmd="default" taksId="default" /></RakeGroup></Settings>
|
data/.idea/encodings.xml
ADDED
data/.idea/ld.iml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Ruby Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
12
|
+
<component name="NewModuleRootManager">
|
13
|
+
<content url="file://$MODULE_DIR$" />
|
14
|
+
<orderEntry type="inheritedJdk" />
|
15
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
16
|
+
</component>
|
17
|
+
</module>
|
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
data/.idea/vcs.xml
ADDED
data/.idea/workspace.xml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ChangeListManager">
|
4
|
+
<option name="TRACKING_ENABLED" value="true" />
|
5
|
+
<option name="SHOW_DIALOG" value="false" />
|
6
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
7
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
8
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
9
|
+
</component>
|
10
|
+
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
|
11
|
+
<component name="CreatePatchCommitExecutor">
|
12
|
+
<option name="PATCH_PATH" value="" />
|
13
|
+
</component>
|
14
|
+
<component name="DaemonCodeAnalyzer">
|
15
|
+
<disable_hints />
|
16
|
+
</component>
|
17
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
18
|
+
<OptionsSetting value="true" id="Add" />
|
19
|
+
<OptionsSetting value="true" id="Remove" />
|
20
|
+
<OptionsSetting value="true" id="Checkout" />
|
21
|
+
<OptionsSetting value="true" id="Update" />
|
22
|
+
<OptionsSetting value="true" id="Status" />
|
23
|
+
<OptionsSetting value="true" id="Edit" />
|
24
|
+
<ConfirmationsSetting value="0" id="Add" />
|
25
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
26
|
+
</component>
|
27
|
+
<component name="RunManager">
|
28
|
+
<list size="0" />
|
29
|
+
</component>
|
30
|
+
<component name="ShelveChangesManager" show_recycled="false" />
|
31
|
+
<component name="TaskManager">
|
32
|
+
<task active="true" id="Default" summary="Default task">
|
33
|
+
<option name="number" value="Default" />
|
34
|
+
</task>
|
35
|
+
<servers />
|
36
|
+
</component>
|
37
|
+
<component name="VcsContentAnnotationSettings">
|
38
|
+
<option name="myLimit" value="2678400000" />
|
39
|
+
</component>
|
40
|
+
<component name="VcsManagerConfiguration">
|
41
|
+
<option name="myTodoPanelSettings">
|
42
|
+
<TodoPanelSettings />
|
43
|
+
</option>
|
44
|
+
</component>
|
45
|
+
<component name="XDebuggerManager">
|
46
|
+
<breakpoint-manager />
|
47
|
+
<watches-manager />
|
48
|
+
</component>
|
49
|
+
</project>
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at chuangye201012@163.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Liu Dong
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Ld
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ld`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ld'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ld
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ld. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ld"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/ld.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ld/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ld"
|
8
|
+
spec.version = Ld::VERSION
|
9
|
+
spec.authors = ["Liu Dong"]
|
10
|
+
spec.email = ["chuangye201012@163.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{这是总结.}
|
13
|
+
spec.description = %q{这是描述.}
|
14
|
+
spec.homepage = "https://github.com/18810625123/ld"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
end
|
data/lib/ld/dir.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
class Ld::Dir
|
2
|
+
|
3
|
+
attr_accessor :path, :name, :dir, :dirs, :files
|
4
|
+
|
5
|
+
def initialize path, dir = nil
|
6
|
+
@path = path
|
7
|
+
@dir = dir
|
8
|
+
@name = File.basename path
|
9
|
+
iter
|
10
|
+
end
|
11
|
+
|
12
|
+
# 迭代记录所有目录与文件
|
13
|
+
def iter
|
14
|
+
@dirs = []
|
15
|
+
@files = []
|
16
|
+
Dir.foreach path do |p|
|
17
|
+
if !['.','..','.DS_Store'].include?(p)
|
18
|
+
if File.directory? "#{path}/#{p}"
|
19
|
+
@dirs << Ld::Dir.new("#{path}/#{p}", self)
|
20
|
+
else
|
21
|
+
@files << Ld::File.new("#{path}/#{p}", self)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# 手动
|
28
|
+
def iter_all
|
29
|
+
iter.dirs.each do |dir2|
|
30
|
+
dir2.iter_all
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# 移动文件夹
|
35
|
+
def mv_to dir
|
36
|
+
files.each do |file|
|
37
|
+
file.mv dir
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# 创建文件夹
|
42
|
+
def mkdir name
|
43
|
+
Dir.mkdir "#{path}/#{name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
# 删除文件夹以及其下所有文件与目录
|
47
|
+
def destroy_all
|
48
|
+
# FileUtils.rm_r path
|
49
|
+
end
|
50
|
+
|
51
|
+
# 创建文件
|
52
|
+
def create_file name
|
53
|
+
File.new "#{@path}/#{name}"
|
54
|
+
end
|
55
|
+
|
56
|
+
# 创建文件夹
|
57
|
+
def create_dir name
|
58
|
+
Dir.mkdir "#{@path}/#{name}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def print_tree
|
62
|
+
dirs.each do |dir|
|
63
|
+
puts "#{dir.name}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# 查看当前目录文件总大小
|
68
|
+
def files_count
|
69
|
+
sum = 0
|
70
|
+
files.each do |file|
|
71
|
+
sum += file.size
|
72
|
+
end
|
73
|
+
sum
|
74
|
+
end
|
75
|
+
|
76
|
+
# 查看当前目录下所有文件个数
|
77
|
+
def sum_files_count count = 0
|
78
|
+
@@sum_count = count + files.size
|
79
|
+
# puts "#{@@sum_count}\t+=\t#{count}\t+\t#{files.size}"
|
80
|
+
dirs.each do |dir|
|
81
|
+
dir.sum_files_count @@sum_count
|
82
|
+
end
|
83
|
+
@@sum_count
|
84
|
+
end
|
85
|
+
|
86
|
+
# 查看当前目录下所有文件个数
|
87
|
+
def sum_files_size size = 0
|
88
|
+
@@sum_size = size + files_count
|
89
|
+
# puts "#{@@sum_size}\t+=\t#{size}\t+\t#{files_count/1024.round(3)} (#{name})"
|
90
|
+
dirs.each do |dir|
|
91
|
+
dir.sum_files_size @@sum_size
|
92
|
+
end
|
93
|
+
@@sum_size
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# 迭代打印当前目录下所有文件与文件夹的信息
|
98
|
+
def info_all(i = 0)
|
99
|
+
info(i)
|
100
|
+
files_info(i)
|
101
|
+
i += 1
|
102
|
+
dirs.each_with_index do |dir,k|
|
103
|
+
dir.info_all(i)
|
104
|
+
end
|
105
|
+
nil
|
106
|
+
end
|
107
|
+
|
108
|
+
# 打印当前目录下所有文件夹的信息
|
109
|
+
def files_info(i = 0)
|
110
|
+
files.each do |file|
|
111
|
+
file.info(i + 1)
|
112
|
+
end
|
113
|
+
puts
|
114
|
+
end
|
115
|
+
|
116
|
+
# 打印当前目录的汇总信息
|
117
|
+
def info(i = 0)
|
118
|
+
print "\t" * i
|
119
|
+
puts "目录#{path}下:子文件夹个数#{dirs.size},子文件个数#{files.size}"
|
120
|
+
puts "总文件个数#{sum_files_count},当前文件夹大小#{files_count/1024.round(3)}K,文件夹总大小#{sum_files_size}K"
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|