yjcocoa 17.8.26

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a1f6fb36b23404a0613c8094c2b1e2779c647360
4
+ data.tar.gz: 5d3f79a3a09a6c3425e8cbe897e2791f9f3cd413
5
+ SHA512:
6
+ metadata.gz: d1c6a92994cfc5e81c1dbd41e0d5ff42a6ba543ba04bc8adb02bf5dad012255bfd108516a639a2eac286cf8e649332e4472dc00b731050ae07c2f8237f060406
7
+ data.tar.gz: 4c38c996509704d02c02493282dc8958442e6d5ada595e1621a28bd5f91cdc4c81d40a24479e872fb40dee632a48e896cd43e6c37b8bcdf905081fdb9b8245bd
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 阳君
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ ![](https://raw.githubusercontent.com/937447974/Blog/master/Resources/2016110201.png)
2
+
3
+ [![Language: Ruby](https://img.shields.io/badge/language-Ruby-orange.svg?style=flat)](https://www.ruby-lang.org/zh_cn/)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/937447974/YJCocoaGem/blob/master/LICENSE)
5
+ [![](https://img.shields.io/badge/gem-17.8.26-orange.svg?style=flat)](https://rubygems.org/gems/yjcocoa)
6
+ ![QQ群](https://img.shields.io/badge/QQ群-557445088-blue.svg?style=flat)
7
+
8
+ # YJCocoaGem
9
+
10
+ YJ系列Gem开源库
11
+
12
+ [https://rubygems.org/gems/yjcocoa](https://rubygems.org/gems/yjcocoa)
13
+
14
+ ## git命令
15
+
16
+ ![](https://raw.githubusercontent.com/937447974/Blog/master/Resources/2017082601.png)
17
+
18
+ ----------
19
+
20
+ # <a id="Appendix">Appendix
21
+
22
+ ## Author
23
+
24
+ 姓名:阳君
25
+
26
+ QQ:937447974
27
+
28
+ YJ技术支持群:557445088
29
+
30
+ 职位:滴滴 iOS 高级工程师
31
+
32
+ 如果你觉得这个框架很赞,请点击右上角的Star按钮;如果你对我的框架感兴趣,并想持续获得本人最新的框架源文件,欢迎点击右上角的Fork按钮。
33
+
34
+ 如果你也想来和我们一起在滴滴从事iOS研发工作,欢迎投递简历到937447974@qq.com。
35
+
36
+ ## Copyright
37
+
38
+ CSDN:http://blog.csdn.net/y550918116j
39
+
40
+ GitHub:https://github.com/937447974
data/bin/yjcocoa ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby_executable_hooks
2
+ #
3
+ # yjcocoa
4
+ # YJCocoa
5
+ #
6
+ # https://github.com/937447974
7
+ # YJ技术支持群:557445088
8
+ #
9
+ # Created by 阳君 on 17/8/22.
10
+ # Copyright © 2017年 YJCocoa. All rights reserved.
11
+ #
12
+
13
+ if $PROGRAM_NAME == __FILE__
14
+ lib = File.expand_path('../../lib', __FILE__)
15
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
16
+ end
17
+
18
+ require 'yjcocoa'
19
+ YJCocoa::Command.run(ARGV)
@@ -0,0 +1,79 @@
1
+ #
2
+ # command.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/22.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ require 'claide'
13
+ require 'colored2'
14
+ require 'fileutils'
15
+ require 'yjcocoa/gem_version'
16
+
17
+ module YJCocoa
18
+
19
+ # Usage
20
+ class Command < CLAide::Command
21
+
22
+ DEFAULT_OPTIONS = [['--help', 'Show help banner of specified command'],]
23
+
24
+ self.abstract_command = true
25
+ self.command = 'yjcocoa'
26
+ self.version = VERSION
27
+ self.description = 'YJCocoa, the Cocoa library package manager.'
28
+
29
+ def self.options
30
+ if root_command?
31
+ DEFAULT_ROOT_OPTIONS + DEFAULT_OPTIONS
32
+ else
33
+ DEFAULT_OPTIONS
34
+ end
35
+ end
36
+
37
+ # @abstract 向用户提问,并获取输入
38
+ #
39
+ # @param question 问题
40
+ # @param answers 答案数组
41
+ #
42
+ # @return 用户输入的选项。用户不输入时,默认返回第一个选项
43
+ def askWithAnswers(question = "", answers = [])
44
+ answersDowncase = answers.map { |item| item.downcase }
45
+ return answersDowncase.first if answersDowncase.count <= 1
46
+ result = ""
47
+ block = Proc.new { |again|
48
+ str = again ? "可能的答案是 [" : "#{question}? ["
49
+ answers.each_with_index { |item, i|
50
+ str << " #{(i == 0) ? item.underlined : item}"
51
+ str << " /" unless i == answers.count - 1
52
+ }
53
+ str << " ]: "
54
+ print str
55
+ }
56
+ # do
57
+ block.call(false)
58
+ loop do
59
+ result = STDIN.gets.chomp.downcase
60
+ if result.empty?
61
+ result = answersDowncase.first
62
+ print "default: #{result}".yellow
63
+ else
64
+ result = "yes" if result == "y"
65
+ result = "no" if result == "n"
66
+ end
67
+ break if answersDowncase.include?(result)
68
+ block.call(true)
69
+ end
70
+ return result
71
+ end
72
+
73
+ end
74
+
75
+ # Commands
76
+ require 'yjcocoa/git/git'
77
+
78
+ end
79
+
@@ -0,0 +1,16 @@
1
+ #
2
+ # gem_version.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/22.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ module YJCocoa
13
+
14
+ VERSION = '17.8.26'.freeze unless defined? YJCocoa::VERSION
15
+
16
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # git.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/22.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ module YJCocoa
13
+
14
+ # Usage
15
+ class Git < Command
16
+
17
+ self.abstract_command = true
18
+ self.command = 'git'
19
+ self.summary = 'git commands'
20
+ self.description = 'These are common Git commands used in YJCocoa.'
21
+
22
+ def gitExist?
23
+ if File.exist?(".git")
24
+ return true
25
+ elsif Dir.pwd == "/"
26
+ puts "fatal: Not a git repository (or any of the parent directories): .git".red
27
+ return false
28
+ end
29
+ Dir.chdir("..") {
30
+ return self.gitExist?
31
+ }
32
+ end
33
+
34
+ end
35
+
36
+ # Commands
37
+ require 'yjcocoa/git/git_branch'
38
+ require 'yjcocoa/git/git_cache'
39
+ require 'yjcocoa/git/git_pull'
40
+ require 'yjcocoa/git/git_tag'
41
+
42
+ end
43
+
@@ -0,0 +1,72 @@
1
+ #
2
+ # git_branch.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/26.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ module YJCocoa
13
+
14
+ class GitBranch < Git
15
+
16
+ self.command = 'branch'
17
+ self.summary = 'git branch'
18
+ self.description = <<-DESC
19
+ 操作 branch 并同步到服务器
20
+
21
+ 1. 增加branch develop:yjcocoa git Branch --branch=develop
22
+
23
+ 2. 删除多个branch develop 和 fixbug:yjcocoa git Branch --branch=develop,fixbug
24
+ DESC
25
+
26
+ def self.options
27
+ [['--add', '增加branch并推送到服务器'],
28
+ ['--delete', '删除多个branch并推送到服务器'],]
29
+ end
30
+
31
+ # property
32
+ attr_accessor :addBranch
33
+ attr_accessor :deleteBranchs
34
+
35
+ # 初始化
36
+ def initialize(argv)
37
+ super
38
+ self.addBranch = argv.option('add')
39
+ self.deleteBranchs = argv.option('delete')
40
+ self.deleteBranchs = self.deleteBranchs.split(",").reject {|i| i.empty? } if self.deleteBranchs
41
+ end
42
+
43
+ # businrss
44
+ def validate!
45
+ exit 0 unless self.gitExist?
46
+ self.banner! unless self.addBranch || self.deleteBranchs
47
+ end
48
+
49
+ def run
50
+ if self.addBranch
51
+ self.gitBranchAdd
52
+ puts
53
+ end
54
+ self.gitBranchDelete if self.deleteBranchs && !self.deleteBranchs.empty?
55
+ end
56
+
57
+ def gitBranchAdd
58
+ puts "YJCocoa git add branch #{self.addBranch}".green
59
+ system("git push --set-upstream origin #{self.addBranch}") if system("git checkout -b #{self.addBranch}")
60
+ end
61
+
62
+ def gitBranchDelete
63
+ puts "YJCocoa git delete branchs #{self.deleteBranchs}".green
64
+ self.deleteBranchs.each { |branch|
65
+ system("git branch -d #{branch}")
66
+ system("git push origin --delete #{branch}")
67
+ }
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,87 @@
1
+ #
2
+ # git_cache.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/26.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ module YJCocoa
13
+
14
+ class GitCache < Git
15
+
16
+ self.command = 'cache'
17
+ self.summary = 'Manipulate the git cache'
18
+ self.description = <<-DESC
19
+ 主要用于删除 git 仓库中的历史缓存文件。
20
+
21
+ 注意事项:
22
+
23
+ 1. 删除的文件将在本地和远端永久删除,无法回滚;
24
+
25
+ 2. 需在 git 仓库的根目录执行。
26
+ DESC
27
+
28
+ def self.options
29
+ [['--delete-path', '删除的文件路径,多个路径用‘,’隔开']]
30
+ end
31
+
32
+ # property
33
+ attr_accessor :paths
34
+
35
+ # 初始化
36
+ def initialize(argv)
37
+ super
38
+ self.paths = argv.option('delete-path')
39
+ self.paths = self.paths.split(",").reject {|i| i.empty? } if self.paths
40
+ end
41
+
42
+ # businrss
43
+ def validate!
44
+ exit 0 unless self.gitExist?
45
+ unless File.exist?(".git")
46
+ puts "需在 git 仓库的根目录执行".red
47
+ self.banner!
48
+ end
49
+ unless self.paths
50
+ puts "文件路径为空".red
51
+ self.banner!
52
+ end
53
+ end
54
+
55
+ def run
56
+ self.cleanWorkDirectory
57
+ answer = self.askWithAnswers("强制推动您的本地更改覆盖您的GitHub仓库", ["Yes", "No"])
58
+ if answer == "yes"
59
+ self.pushOrigin
60
+ self.cleanRepository
61
+ end
62
+ end
63
+
64
+ def cleanWorkDirectory
65
+ self.paths.each { |path|
66
+ puts "YJCocoa git delete cache #{path}".green
67
+ system("git filter-branch --force --index-filter \
68
+ 'git rm -r --cached --ignore-unmatch #{path}' \
69
+ --prune-empty --tag-name-filter cat -- --all")
70
+ puts
71
+ }
72
+ end
73
+
74
+ def pushOrigin
75
+ system("git push origin --force --all")
76
+ system("git push origin --force --tags")
77
+ end
78
+
79
+ def cleanRepository
80
+ system("git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin")
81
+ system("git reflog expire --expire=now --all")
82
+ system("git gc --prune=now")
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -0,0 +1,85 @@
1
+ #
2
+ # git_pull.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/22.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ module YJCocoa
13
+
14
+ class GitPull < Git
15
+
16
+ self.command = 'pull'
17
+ self.summary = 'git pull'
18
+ self.description = 'git pull 当前文件夹下所有 gits 和 branchs'
19
+
20
+ def self.options
21
+ [['--current-branch', '只拉取当前分支'],]
22
+ end
23
+
24
+ # property
25
+ attr_accessor :currentBranch #是否只拉取当前分支
26
+ attr_accessor :gits # git array
27
+
28
+ # 初始化
29
+ def initialize(argv)
30
+ super
31
+ self.currentBranch = argv.flag?('current-branch', false)
32
+ end
33
+
34
+ # businrss
35
+ def run
36
+ self.buildGitPaths
37
+ if self.gits.empty?
38
+ if self.gitExist?
39
+ self.gitPull
40
+ end
41
+ else
42
+ self.gits.each { |path|
43
+ self.gitPull(path)
44
+ }
45
+ end
46
+ end
47
+
48
+ def buildGitPaths
49
+ self.gits = Dir["**/.git"]
50
+ self.gits.map! { |path|
51
+ File.dirname(path)
52
+ }
53
+ end
54
+
55
+ def gitPull(path=".")
56
+ thread = Thread.new {
57
+ Dir.chdir(path) {
58
+ puts "YJCocoa git pull #{path}/.git".green
59
+ localChanges = !(`git stash` =~ /No local changes to save/)
60
+ system("git pull")
61
+ unless self.currentBranch
62
+ list = (`git branch`).split("\n")
63
+ if list.size >= 2
64
+ headBranch = "master"
65
+ list.each { |item|
66
+ if item =~ /\* /
67
+ headBranch = item.gsub(/\* /, "")
68
+ else
69
+ `git checkout #{item}`
70
+ system("git pull")
71
+ end
72
+ }
73
+ `git checkout #{headBranch}`
74
+ end
75
+ end
76
+ `git stash pop` if localChanges
77
+ puts
78
+ }
79
+ }
80
+ thread.join
81
+ end
82
+
83
+ end
84
+
85
+ end
@@ -0,0 +1,71 @@
1
+ #
2
+ # git_pull.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/22.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ module YJCocoa
13
+
14
+ class GitTag < Git
15
+
16
+ self.command = 'tag'
17
+ self.summary = 'git tag'
18
+ self.description = <<-DESC
19
+ 操作 tag 并同步到服务器
20
+
21
+ 1. 增加tag 1.0:yjcocoa git tag --add=1.0
22
+
23
+ 2. 删除多个tag 1.0 和 2.0:yjcocoa git tag --delete=1.0,2.0
24
+ DESC
25
+
26
+ def self.options
27
+ [['--add', '增加tag并推送到服务器'],
28
+ ['--delete', '删除多个tags并推送到服务器'],]
29
+ end
30
+
31
+ # property
32
+ attr_accessor :addTag
33
+ attr_accessor :deleteTags
34
+
35
+ # 初始化
36
+ def initialize(argv)
37
+ super
38
+ self.addTag = argv.option('add')
39
+ self.deleteTags = argv.option('delete')
40
+ self.deleteTags = self.deleteTags.split(",").reject {|i| i.empty? } if self.deleteTags
41
+ end
42
+
43
+ # businrss
44
+ def validate!
45
+ exit 0 unless self.gitExist?
46
+ self.banner! unless self.addTag || self.deleteTags
47
+ end
48
+
49
+ def run
50
+ if self.addTag
51
+ self.gitTagAdd
52
+ puts
53
+ end
54
+ self.gitTagDelete if self.deleteTags && !self.deleteTags.empty?
55
+ end
56
+
57
+ def gitTagAdd
58
+ puts "YJCocoa git add tag #{self.addTag}".green
59
+ system("git push origin #{self.addTag}") if system("git tag #{self.addTag}")
60
+ end
61
+
62
+ def gitTagDelete
63
+ puts "YJCocoa git delete tags #{self.deleteTags}".green
64
+ self.deleteTags.each { |tag|
65
+ system("git push origin :refs/tags/#{tag}") if system("git tag -d #{tag}")
66
+ }
67
+ end
68
+
69
+ end
70
+
71
+ end
data/lib/yjcocoa.rb ADDED
@@ -0,0 +1,21 @@
1
+ #
2
+ # gem_version.rb
3
+ # YJCocoa
4
+ #
5
+ # https://github.com/937447974
6
+ # YJ技术支持群:557445088
7
+ #
8
+ # Created by 阳君 on 17/8/1.
9
+ # Copyright © 2017年 YJCocoa. All rights reserved.
10
+ #
11
+
12
+ require 'rubygems'
13
+ require 'claide'
14
+ require 'colored'
15
+ require 'yjcocoa/command'
16
+
17
+ module YJCocoa
18
+
19
+ autoload :Command, 'cocoapods/command'
20
+
21
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yjcocoa
3
+ version: !ruby/object:Gem::Version
4
+ version: 17.8.26
5
+ platform: ruby
6
+ authors:
7
+ - 阳君
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: claide
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: colored2
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.1'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.1.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.1'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.1.2
53
+ description: YJ系列开源工具
54
+ email:
55
+ - 937447974@qq.com
56
+ executables:
57
+ - yjcocoa
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - LICENSE
62
+ - README.md
63
+ - bin/yjcocoa
64
+ - lib/yjcocoa.rb
65
+ - lib/yjcocoa/command.rb
66
+ - lib/yjcocoa/gem_version.rb
67
+ - lib/yjcocoa/git/git.rb
68
+ - lib/yjcocoa/git/git_branch.rb
69
+ - lib/yjcocoa/git/git_cache.rb
70
+ - lib/yjcocoa/git/git_pull.rb
71
+ - lib/yjcocoa/git/git_tag.rb
72
+ homepage: https://github.com/937447974/YJCocoaGem
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 2.0.0
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.6.12
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: YJCocoa, the Cocoa library package manager.
96
+ test_files: []