stool 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9087dc7a077981a605928ca0ddf072cdf0f89da5
4
+ data.tar.gz: 43801ab73b2147d3c025909c5558ddc9a1cf05a0
5
+ SHA512:
6
+ metadata.gz: 8e08b78b68d280ab6cc36f6a3f7746d3c946a3c5bdff0e8a417e69402082332322c8b59a32281e1360ffc27529aa7abaaf1014ca17a981b9722513ed8d14eb1c
7
+ data.tar.gz: 49f84777e00d90b37140dced8194c6d7d19e64297494e3bc2155806fd1dcba6af7843b7e1b423e717734ec5d1cc3b886d359d623dd00ead72d0afc64312e62a7
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Stool
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/stool`. 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 'stool'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install stool
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. Then, run `rake spec` to run the tests. 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]/stool. 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
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Stool project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/stool/blob/master/CODE_OF_CONDUCT.md).
data/bin/sl ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'stool.rb'
4
+
5
+ Stool::Command.run(ARGV)
data/lib/VERSION.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Stool
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,37 @@
1
+ #版本号
2
+ require 'Utils/StringUtil'
3
+ include StringUtile
4
+
5
+ module Stool
6
+ class Command
7
+ class Lib < Command
8
+ class VersionAdd < Lib
9
+
10
+ self.command = 'vadd'
11
+ self.summary = '本地lib版本号增加'
12
+ self.arguments = [
13
+ CLAide::Argument.new('NAME', true),
14
+ ]
15
+
16
+ def run
17
+
18
+ @info.info_tos
19
+
20
+ puts '版本增加 1'
21
+ newVersion = StringUtile::versionUpdate(@info.version,'1')
22
+
23
+ file = File.open(@info.path + "/#{@info.name}" + ".podspec", "r+")
24
+ file.each_line do |line|
25
+ if line[/#{@info.version}/]
26
+
27
+ file.seek(-line.length, IO::SEEK_CUR)
28
+
29
+ file.write(line.sub(/#{@info.version}/, newVersion))
30
+ end
31
+ end
32
+ file.close
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,84 @@
1
+ #本地pod lib项目
2
+ require 'Core/LibInfo'
3
+ require 'Command/Lib/VersionAdd'
4
+ require 'Command/LibPool/List'
5
+
6
+ module Stool
7
+ class Command
8
+ class Lib < Command
9
+
10
+ # self.abstract_command = true
11
+ self.command = 'lib'
12
+ self.summary = '本地lib信息、处理'
13
+ # self.default_subcommand = 'list'
14
+ self.arguments = [
15
+ CLAide::Argument.new('NAME', true),
16
+ ]
17
+
18
+ #要查询的lib名字
19
+ attr_accessor :name
20
+ #查询结果lib信息
21
+ attr_accessor :info
22
+
23
+ def initialize(argv)
24
+ # @info = LibInfo.new()
25
+ @name = argv.shift_argument
26
+ # @progress = argv.flag?('progress')
27
+ super
28
+ end
29
+
30
+ def validate!
31
+ super
32
+ unless @name
33
+ help! 'need the lib `NAME`.'
34
+ end
35
+
36
+ unless existAtPools?
37
+ help! "the lib named #{@name} did not find."
38
+ end
39
+ end
40
+
41
+ def run
42
+ if @info
43
+ @info.info_tos
44
+ end
45
+ end
46
+
47
+
48
+ def existAtPools?
49
+ #在libPool中查找lib
50
+ arrayPools = LibPool::List::pools_from_config
51
+ arrayPools.each {|pool|
52
+ Dir.new(pool.path).each{|file|
53
+ if @name.eql?(file)
54
+ path = pool.path + "/#{file}"
55
+ @info = LibInfo::loadFromPath(path)
56
+ end
57
+ }
58
+ }
59
+ @info
60
+ end
61
+
62
+ # def fuzzy_search
63
+ # arr = []
64
+ #
65
+ # #在libPool中查找lib
66
+ # arrayPools = LibPool::List::pools_from_config
67
+ # arrayPools.each {|pool|
68
+ # Dir.new(pool.path).each{|file|
69
+ # if file[@name]
70
+ # path = pool.path + "/#{file}"
71
+ # libInfo = LibInfo::loadFromPath(path)
72
+ # if libInfo.kind_of?(LibInfo)
73
+ # arr.push(libInfo)
74
+ # end
75
+ # end
76
+ # }
77
+ # }
78
+ #
79
+ # arr
80
+ # end
81
+
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,96 @@
1
+ #添加一个池
2
+
3
+ require 'yaml'
4
+
5
+ module Stool
6
+ class Command
7
+ class LibPool < Command
8
+ class Add < LibPool
9
+
10
+ self.command = 'add'
11
+ self.summary = '添加一个本地pod池.'
12
+
13
+ self.description = <<-DESC
14
+ '添加一个私有pod库的池,'
15
+ DESC
16
+
17
+ self.arguments = [
18
+ CLAide::Argument.new('NAME', true),
19
+ CLAide::Argument.new('PATH', true),
20
+ ]
21
+
22
+ # def self.options
23
+ # [
24
+ # ['--progress', 'Show the progress of cloning the spec repository'],
25
+ # ].concat(super)
26
+ # end
27
+
28
+ def initialize(argv)
29
+ puts 'Add --- init'
30
+ @pInfo.name = argv.shift_argument
31
+ @pInfo.path = argv.shift_argument
32
+ # @progress = argv.flag?('progress')
33
+ super
34
+ end
35
+
36
+ def validate!
37
+ super
38
+ puts 'Add --- validate!'
39
+ unless @pInfo.name && @pInfo.path
40
+ help! 'Adding a libPool needs a `NAME` and a `PATH`.'
41
+ end
42
+
43
+ unless File.exist?(@path)
44
+ raise Informative,
45
+ 'To add a pool, please give a ensure the path of folder is exist.'
46
+ end
47
+ end
48
+
49
+ def run
50
+ puts 'Add --- run'
51
+ #do cache
52
+ obj = hadCached?
53
+ if obj
54
+ obj.path = @path
55
+ else
56
+ doCacheByYamlToPath(@@PathForCache,@name)
57
+ end
58
+
59
+ # section = "Cloning spec repo `#{@name}` from `#{@url}`"
60
+ # section << " (branch `#{@branch}`)" if @branch
61
+ # UI.section(section) do
62
+ # create_repos_dir
63
+ # clone_repo
64
+ # checkout_branch
65
+ # config.sources_manager.sources([dir.basename.to_s]).each(&:verify_compatibility!)
66
+ # end
67
+ end
68
+
69
+ def hadCached?
70
+ puts "@PathForCache = #{@@PathForCache}"
71
+ puts "@name = #{@name}"
72
+
73
+ obj = nil
74
+ if File.exist?(self.cachePath)
75
+ obj = YAML::load(File.open(self.cachePath))
76
+ end
77
+ end
78
+
79
+ def doCacheByYamlToPath(cacheDirPath,fileName)
80
+ puts "....do cache to #{cacheDirPath}"
81
+ unless File::exists?(cacheDirPath)
82
+ Dir.mkdir(cacheDirPath,0777)
83
+ end
84
+ File.open(File.join(cacheDirPath,fileName) + '.yaml', "w") { |file|
85
+ YAML.dump(self, file)
86
+ }
87
+ end
88
+
89
+ def cachePath
90
+ path = "#{@@PathForCache + @name + '.yaml'}"
91
+ path.to_s
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,32 @@
1
+ #查看当前pool列表
2
+ module Stool
3
+ class Command
4
+ class LibPool < Command
5
+ class List < LibPool
6
+
7
+ self.command = 'list'
8
+ self.summary = '本地pod池列表'
9
+
10
+ self.arguments = [
11
+ CLAide::Argument.new('NAME', false),
12
+ ]
13
+
14
+ def initialize(argv)
15
+ super
16
+ end
17
+
18
+ #查看当前的pool list
19
+ def run
20
+ pp('')
21
+ pp('**Pool list')
22
+ List::pools_from_config.map do |pInfo|
23
+ pInfo.info_tos
24
+ end
25
+ end
26
+
27
+ @public
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,40 @@
1
+ #私有库的池,池中有多个lib
2
+ require 'Core/PoolInfo'
3
+
4
+ module Stool
5
+ class Command
6
+ class LibPool < Command
7
+
8
+ require 'Command/LibPool/List'
9
+
10
+ self.abstract_command = true
11
+ self.command = 'lp'
12
+ self.summary = 'LibPool - 本地pod池.'
13
+ self.default_subcommand = 'list'
14
+
15
+ #pool信息
16
+ # attr_accessor :pInfo
17
+
18
+ def initialize(argv)
19
+ super
20
+ end
21
+
22
+ #配置文件中读取
23
+ def self.pools_from_config
24
+ arr = @@config.pools
25
+
26
+ arr.each do |obj|
27
+ # puts '**** obj===' + "#{obj}"
28
+ if obj.respond_to?('path')
29
+ unless File.exist?(obj.path)
30
+ puts "warning__> #{obj.path} not exist"
31
+ arr.delete(obj)
32
+ end
33
+ end
34
+ end
35
+ arr
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,48 @@
1
+ #查看当前workspace列表
2
+
3
+ require 'yaml'
4
+
5
+ module Stool
6
+ class Command
7
+ class WorkSpace < Command
8
+ class List < WorkSpace
9
+
10
+ self.command = 'list'
11
+ self.summary = 'workspace列表'
12
+
13
+ self.arguments = [
14
+ #CLAide::Argument.new('NAME', false),
15
+ ]
16
+
17
+ def initialize(argv)
18
+ super
19
+ end
20
+
21
+ #查看当前的pool list
22
+ def run
23
+ pp('')
24
+ pp('**WorkSpace list')
25
+ List::tasks_from_config.map{|wp|
26
+ wp.info_tos
27
+ }
28
+ end
29
+
30
+ @public
31
+
32
+ def self.tasks_from_config
33
+ arr = @@config.tasks
34
+ arr.map do |obj|
35
+ if obj.respond_to?('path')
36
+ unless File.exist?(obj.path)
37
+ puts "warning--> #{obj.path} not exist"
38
+ arr.delete(obj)
39
+ end
40
+ end
41
+ end
42
+ arr
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,111 @@
1
+ #对执行pod update的整合
2
+
3
+ module Stool
4
+ class Command
5
+ class WorkSpace < Command
6
+ class Update < WorkSpace
7
+
8
+ self.command = 'up'
9
+ self.summary = '移除pods、podfile.lock后,执行pod update'
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('Tag', true),
13
+ ]
14
+
15
+ def initialize(argv)
16
+ @tag = argv.shift_argument
17
+ super
18
+ end
19
+
20
+ def validate!
21
+ unless @tag
22
+ help! 'need the tag of workspace you configed.'
23
+ end
24
+
25
+ unless existAtConfig?
26
+ help! "To run, please ensure the tag(#{@tag}) exist."
27
+ end
28
+
29
+ unless hasPodfile?(@info.path)
30
+ help! 'To run, please ensure the workspace contain a podfile in zhe folder.' + "#{@info.path}"
31
+ end
32
+
33
+ super
34
+ end
35
+
36
+ @public
37
+
38
+ def run
39
+ repos_up
40
+
41
+ localLibs_git_up
42
+
43
+ @info.task_git_up
44
+
45
+ @info.edit_podfile_use_loaclLibs
46
+
47
+ del_folers
48
+
49
+ pod_update
50
+
51
+ @info.resetPofile
52
+
53
+ @info.open_task
54
+ end
55
+
56
+ #更新相关repo(除了master)
57
+ def repos_up
58
+ getAllRepos.each do |repo|
59
+ puts "*** begin update repo <#{repo}>"
60
+ `pod repo update #{repo}`
61
+ puts "*** end update repo"
62
+ puts ''
63
+ end
64
+ end
65
+
66
+ #更新项目用到的所有本地库
67
+ def localLibs_git_up
68
+ @@config.pools.map do |pool|
69
+ @info.localLibs.map do |lib|
70
+ libInfo = pool.searchLib(lib)
71
+ if libInfo
72
+ libInfo.gitUp
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ #删除一些相关文件
79
+ def del_folers
80
+ # Dir.rmdir(File.join(@info.path, 'Pods'))
81
+ `rm -rf Pods`
82
+
83
+ podLock = File.join(@info.path,"Pofile.lock")
84
+ if File.exist?(podLock)
85
+ File.delete(podLock)
86
+ end
87
+ end
88
+
89
+ #执行pod update
90
+ def pod_update
91
+ useCode = @info.localLibs + @info.otherCode
92
+
93
+ useCode.collect! {|item|
94
+
95
+ item + "_use_code=1 "
96
+ }
97
+
98
+ puts "---源码库有" + useCode.join
99
+
100
+ Dir.chdir(@info.path)
101
+
102
+ puts '---当前目录' + Dir.getwd
103
+
104
+ puts "---update中...."
105
+ puts `#{useCode.join} pod update --no-repo-update`
106
+ end
107
+
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,68 @@
1
+ #iOS-workspcace项目处理
2
+ require 'Core/TaskInfo'
3
+
4
+ module Stool
5
+ class Command
6
+ class WorkSpace < Command
7
+
8
+ require 'Command/WorkSpace/list'
9
+ require 'Command/WorkSpace/update'
10
+
11
+ self.abstract_command = true
12
+ self.command = 'ws'
13
+ self.summary = 'workSpaces - 本地的Workspace项目,关于pod相关的整合'
14
+ # self.default_subcommand = 'list'
15
+
16
+ #要查询的workspace的唯一标识
17
+ attr_accessor :tag
18
+ #查询结果workspace信息
19
+ attr_accessor :info
20
+
21
+ def initialize(argv)
22
+ super
23
+ end
24
+
25
+ @public
26
+
27
+ def validate!
28
+ super
29
+ end
30
+
31
+ # def run
32
+ #
33
+ # end
34
+
35
+ def hasPodfile?(path)
36
+ arr = Dir.glob(File.join(path,'Podfile'))
37
+ arr[0]
38
+ end
39
+
40
+ def existAtConfig?
41
+ #在本地配置中中查找workspace
42
+ arrayTasks = WorkSpace::List::tasks_from_config
43
+ arrayTasks.each {|task|
44
+ if @tag.eql?(task.tag)
45
+ @info = task
46
+ end
47
+ }
48
+ @info
49
+ end
50
+
51
+ def getAllRepos
52
+ arr = []
53
+ if @info.repos.count == 0
54
+ path = @@config.repoCachePath
55
+ arr = Dir.entries(path).delete_if{|file|
56
+ if file['.'] || file.eql?('master')
57
+ 1
58
+ end
59
+ }
60
+ else
61
+ arr = @info.repos
62
+ end
63
+ arr
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,55 @@
1
+ require 'stool/Core/Config'
2
+ require 'version'
3
+ module Stool
4
+ class Command < CLAide::Command
5
+
6
+ #配置中心
7
+ @@config = Config::loadConfig
8
+
9
+ require 'stool/Command/LibPool'
10
+ require 'stool/Command/WorkSpace'
11
+ require 'stool/Command/Lib'
12
+
13
+ self.abstract_command = true
14
+ self.command = 'sl'
15
+ self.version = VERSION
16
+ self.description = 'smart tool - 对iOS相关工作,进行自动化整合,目前只暴露了iOS使用cocoapods时的自动化处理'
17
+ self.plugin_prefixes = %w(claide stool)
18
+
19
+ def self.options
20
+ [
21
+ ['--silent', 'Show nothing'],
22
+ ].concat(super)
23
+ end
24
+
25
+ def initialize(argv)
26
+ checkConfigFile
27
+ super
28
+ end
29
+
30
+ def run
31
+ puts 'it works!!'
32
+
33
+ cc = Config::loadConfig
34
+
35
+ cc.pools.map do |x|
36
+
37
+ puts x.path
38
+ puts x.name
39
+ end
40
+
41
+ end
42
+
43
+ def pp(*args)
44
+ if args.inspect[1]
45
+ puts args[0]
46
+ end
47
+ end
48
+
49
+ #检测系统Config文件
50
+ def checkConfigFile
51
+
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,18 @@
1
+ module Stool
2
+ class BaseObj
3
+
4
+ @public
5
+
6
+ def initialize
7
+ yield self if block_given?
8
+ end
9
+
10
+ def self.fromFile(path)
11
+ if File.exist?(path)
12
+ content = File.open(path, 'r:utf-8', &:read)
13
+ eval(content,nil,path.to_s)
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,128 @@
1
+ #项目相关配置
2
+ require 'Core/BaseObj'
3
+ require 'Core/PoolInfo'
4
+ require 'Core/TaskInfo'
5
+
6
+ module Stool
7
+ class Config < BaseObj
8
+
9
+ #cache路径
10
+ @@cachePath = File.join(Dir.home(),'stool')
11
+ @@configFilePath = File.join(@@cachePath, 'ConfigFile.rb')
12
+ #本地lib池子
13
+ attr_accessor :pools
14
+ #主工程
15
+ attr_accessor :tasks
16
+
17
+ attr_accessor :repoCachePath
18
+
19
+ @public
20
+
21
+ def initialize
22
+ @repoCachePath = File.join(Dir.home,'.cocoapods/repos')
23
+ @pools = []
24
+ @tasks = []
25
+ super
26
+ end
27
+
28
+ #从配置中心读取
29
+ def self.loadConfig
30
+ checkConfigFile?
31
+ cc = Config::fromFile(@@configFilePath)
32
+ cc
33
+ end
34
+
35
+ #添加一个本地libPool
36
+ def addPool
37
+ pInfo = PoolInfo.new()
38
+
39
+ @pools.push(pInfo)
40
+
41
+ yield pInfo if block_given?
42
+ end
43
+
44
+ #添加一个workspace
45
+ def addTask
46
+ tInfo = TaskInfo.new()
47
+
48
+ @tasks.push(tInfo)
49
+
50
+ yield tInfo if block_given?
51
+ end
52
+
53
+ @private
54
+
55
+ #检测config.rb是否存在
56
+ def self.checkConfigFile?
57
+ path = File.join(@@configFilePath)
58
+ unless File.exist?(path)
59
+ creatConfigFile
60
+ puts "*** At first ,you should edit the config file at path<#{@@configFilePath}>!!"
61
+
62
+ `open #{@@configFilePath}`
63
+ end
64
+ end
65
+
66
+ #创建一个ConfigFile例子
67
+ def self.creatConfigFile
68
+
69
+ unless Dir.exist?(@@cachePath)
70
+ Dir.mkdir(@@cachePath,0777)
71
+ end
72
+
73
+ File.new(@@configFilePath,'w+')
74
+
75
+ f = File.open(@@configFilePath, "w+")
76
+ demo = <<-EOF
77
+ #stool 配置
78
+ Config.new do |c|
79
+
80
+ #添加一个本地lib pool
81
+ c.addPool do |p|
82
+ p.name = '本地lib池 - 凤凰'
83
+ p.path = '/Users/syswin/Documents/Siyuan/Libs/phenix'
84
+ end
85
+ #再添加一个本地lib pool
86
+ # c.addPool do |p|
87
+ # p.name = '本地lib池 - toon基线'
88
+ # p.path = '/Users/syswin/Documents/Siyuan/Libs/toon'
89
+ # end
90
+
91
+ #添加一个主工程
92
+ c.addTask do |t|
93
+ t.name = '凤凰主工程'
94
+ #必须配置一个tag,pod update时需要使用
95
+ t.tag = '1'
96
+ t.path = '/Users/syswin/Documents/Siyuan/Libs/phenix/tlauncher/TLauncher'
97
+ #项目使用的本地lib,默认都是源码
98
+ t.localLibs = ['tcardReader',
99
+ 'tcardLibrary',
100
+ 'tcardKit',
101
+ 'tcontentGroup',
102
+ 'tcontentCommon']
103
+ end
104
+
105
+ end
106
+ EOF
107
+
108
+ f.write(demo)
109
+ end
110
+
111
+ #Todo::
112
+ # def pools
113
+ # puts "*** pools === #{pools}"
114
+ # unless @pools
115
+ # @pools = []
116
+ # end
117
+ # @pools
118
+ # end
119
+ #
120
+ # def tasks
121
+ # unless @tasks
122
+ # @tasks = []
123
+ # end
124
+ # @tasks
125
+ # end
126
+
127
+ end
128
+ end
@@ -0,0 +1,48 @@
1
+ #update
2
+
3
+ module Stool
4
+ module Git_util
5
+
6
+ #状态
7
+ def git_st
8
+ puts "--- git status"
9
+ `git status`
10
+ end
11
+
12
+ def git_stash
13
+ puts "--- git stash"
14
+ `git stash`
15
+ end
16
+
17
+ def git_stash_pop
18
+ puts '--- git stash pop'
19
+ `git stash pop`
20
+ end
21
+
22
+ #提交
23
+ def git_commit_all(msg)
24
+
25
+ `git diff`
26
+
27
+ puts "--- 提交所有变更代码"
28
+ `git add .`
29
+
30
+ unless msg
31
+ msg = 'stool - auto commit'
32
+ end
33
+
34
+ `git commit -m"#{msg}"`
35
+ end
36
+
37
+ #update
38
+ def git_up
39
+ puts "--- git update"
40
+ `git pull`
41
+ end
42
+
43
+ def git_checkout(file)
44
+ `git checkout #{file}`
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,98 @@
1
+ require 'Core/BaseObj'
2
+ require 'Core/Git'
3
+
4
+ module Pod
5
+ class Ios
6
+ def method_missing(method_id, *arguments, &block)
7
+ # puts "***" + "method_id = #{method_id}"
8
+ end
9
+ end
10
+
11
+ class Spec
12
+ attr_accessor :name
13
+ attr_accessor :version
14
+ attr_accessor :ios
15
+ # attr_accessor :name
16
+ # attr_accessor :name
17
+
18
+ def method_missing(method_id, *arguments, &block)
19
+ # puts "***" + "method_id = #{method_id}"
20
+ end
21
+
22
+ @public
23
+
24
+ def initialize
25
+ @ios = Ios.new()
26
+ yield self if block_given?
27
+ end
28
+
29
+ def self.fromFile(path)
30
+ content = File.open(path, 'r:utf-8', &:read)
31
+ eval(content,nil,path.to_s)
32
+ end
33
+
34
+ end
35
+ end
36
+
37
+ #######################################
38
+
39
+ module Stool
40
+ class LibInfo < BaseObj
41
+
42
+ include Stool::Git_util
43
+
44
+ #本地路径
45
+ attr_accessor :path
46
+ #lib的name
47
+ attr_accessor :name
48
+ #lib的版本
49
+ attr_accessor :version
50
+ #本地缓存类型(Framework or code)
51
+ attr_accessor :cacheType
52
+
53
+ @public
54
+
55
+ def self.loadFromPath (path)
56
+ Dir.chdir(path)
57
+ podspec = Dir.glob('*.podspec')[0]
58
+ if podspec
59
+ info = LibInfo.new()
60
+ info.path = path
61
+ info.name = podspec.split('.')[0]
62
+ info.dsl_podspec(path + "/#{podspec}")
63
+ end
64
+
65
+ info
66
+ end
67
+
68
+ def info_tos
69
+ puts ''
70
+ puts "**lib info of <#{self.name}>"
71
+ puts "-- name: #{self.name}"
72
+ puts "-- path: #{self.path}"
73
+ puts "-- version: #{self.version}"
74
+ puts ''
75
+ end
76
+
77
+ def dsl_podspec(path)
78
+
79
+ spec = Pod::Spec.fromFile(path)
80
+
81
+ @name = spec.name
82
+ @version = spec.version
83
+
84
+ end
85
+
86
+ def gitUp
87
+ if @path
88
+ Dir.chdir(@path)
89
+ puts "*** git处理<#{@name}>"
90
+ git_st
91
+ git_stash
92
+ git_up
93
+ git_stash_pop
94
+ end
95
+ end
96
+
97
+ end
98
+ end
@@ -0,0 +1,41 @@
1
+ #本地lib池
2
+
3
+ require 'Core/BaseObj'
4
+ require 'Core/LibInfo'
5
+
6
+ module Stool
7
+ class PoolInfo < BaseObj
8
+ attr_accessor :name
9
+ attr_accessor :path
10
+
11
+ def info_tos
12
+ puts('--' + 'name:'+ self.name)
13
+ puts('--' + 'path:'+ self.path)
14
+ puts('--' + 'libs:')
15
+ subDirs.sort.each do |f|
16
+ unless f['.']
17
+ puts ' ' + f.to_s
18
+ end
19
+ end
20
+ puts('')
21
+ end
22
+
23
+ #本地搜索一个lib
24
+ def searchLib(name)
25
+ libInfo = nil
26
+ if subDirs.include?(name)
27
+ libInfo = LibInfo::loadFromPath(File.join(@path,name))
28
+ end
29
+ libInfo
30
+ end
31
+
32
+ def subDirs
33
+ arr = []
34
+ if @path
35
+ arr = Dir.entries(@path)
36
+ end
37
+ arr
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,131 @@
1
+ #本地lib池
2
+ require 'Core/BaseObj'
3
+ require 'Core/Git'
4
+ require 'Core/Config'
5
+
6
+ module Stool
7
+ class TaskInfo < BaseObj
8
+
9
+ include Stool::Git_util
10
+
11
+ attr_accessor :name
12
+ attr_accessor :path
13
+ attr_accessor :tag
14
+
15
+ #pod时,指定的本地lib name
16
+ attr_accessor :localLibs
17
+ #其他源码指定
18
+ attr_accessor :otherCode
19
+
20
+ #指定的repo
21
+ attr_accessor :repos
22
+
23
+ def initialize
24
+ @localLibs = []
25
+ @otherCode = []
26
+ @repos = []
27
+ super
28
+ end
29
+
30
+ def info_tos
31
+ puts('--' + 'name:'+ self.name)
32
+ puts('--' + 'tag:'+ self.tag)
33
+ puts('--' + 'path:'+ self.path)
34
+ puts('--' + 'localLibs:')
35
+ self.localLibs.sort.map do |lib|
36
+ puts(' ' + lib.to_s)
37
+ end
38
+ puts('')
39
+ end
40
+
41
+ def open_task
42
+ `open *.xcworkspace`
43
+ end
44
+
45
+ def resetPofile
46
+ git_checkout(File.join(@path,'Podfile'))
47
+ end
48
+
49
+ #更新主工程
50
+ def task_git_up
51
+ if @path
52
+ Dir.chdir(path)
53
+ git_up
54
+ end
55
+ end
56
+
57
+ #更新podfile,添加使用本地库
58
+ def edit_podfile_use_loaclLibs
59
+ podfilePath = File.join(@path,'Podfile')
60
+
61
+ if File.exist?(podfilePath)
62
+ arr = @localLibs
63
+ newStr = ''
64
+ lastMatch = ''
65
+ File.open(podfilePath, "r+") do |f|
66
+ f.each_line do |line|
67
+ lineNew = line
68
+ hasFound = []
69
+ arr.each do |libName|
70
+ regx = "pod '#{libName}'"
71
+ if line[/#{regx}/]
72
+ config = Config.loadConfig
73
+ libInfo = nil
74
+ config.pools.each do |pool|
75
+ result = pool.searchLib(libName)
76
+ if result
77
+ libInfo = result
78
+ end
79
+ end
80
+ if libInfo
81
+ lineNew = regx + ", :path => '#{libInfo.path}'" + "\n"
82
+ lastMatch = lineNew
83
+ hasFound.push(libName)
84
+ end
85
+ end
86
+ end
87
+ arr = arr - hasFound
88
+ newStr = newStr + lineNew
89
+ end
90
+ end
91
+
92
+ File.open(podfilePath, "w") do |file|
93
+ # puts newStr
94
+ file.write(newStr)
95
+ end
96
+
97
+ if arr.count > 0
98
+ newStr = ''
99
+ File.open(podfilePath, "r+") do |f|
100
+ f.each_line do |line|
101
+ lineNew = line
102
+ regx = "#{lastMatch}"
103
+ if line[/#{regx}/]
104
+ arr.map do |libName|
105
+ config = Config.loadConfig
106
+ libInfo = nil
107
+ config.pools.each do |pool|
108
+ result = pool.searchLib(libName)
109
+ if result
110
+ libInfo = result
111
+ end
112
+ end
113
+ if libInfo
114
+ lineNew = lineNew + "\n" + "pod '#{libName}'" + ", :path => '#{libInfo.path}'" + "\n"
115
+ end
116
+ end
117
+ end
118
+ newStr = newStr + lineNew
119
+ end
120
+ end
121
+
122
+ File.open(podfilePath, "w") do |file|
123
+ file.write(newStr)
124
+ end
125
+ end
126
+
127
+ end
128
+
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,52 @@
1
+ module StringUtile
2
+
3
+ #类似version = '3.2.01.01.01'格式的版本更新
4
+
5
+ def StringUtile.versionUpdate(version,value)
6
+
7
+ version = version.to_s
8
+
9
+ #要改变的版本
10
+ change = value.to_i
11
+
12
+ #更新后版本
13
+ newVersion = (version.gsub('.', '').to_i + change).to_s
14
+
15
+ while newVersion.length < version.gsub('.', '').length do
16
+ newVersion = "0"+ newVersion
17
+ end
18
+
19
+ #字符串反转
20
+
21
+ temV = version.reverse
22
+
23
+ temNv = newVersion.reverse
24
+
25
+ #新版本号int转string
26
+
27
+ appending = '.'
28
+
29
+ i = 0
30
+
31
+ while i < temV.size
32
+
33
+ if temV[i].eql?('.')
34
+
35
+ temNv = temNv.insert(i, appending)
36
+
37
+ end
38
+
39
+ i = i + 1
40
+
41
+ end
42
+
43
+ puts "#{version}更新版本(#{change})后是#{temNv.reverse}"
44
+
45
+ temNv.reverse
46
+
47
+ end
48
+
49
+ end
50
+
51
+ #examle
52
+ # StringUtile::versionUpdate('99.9.99','11')
@@ -0,0 +1,3 @@
1
+ module Stool
2
+ VERSION = "0.1.0"
3
+ end
data/lib/stool.rb ADDED
@@ -0,0 +1,7 @@
1
+
2
+ module Stool
3
+ require 'claide'
4
+ require 'colored2'
5
+
6
+ autoload :Command, 'stool/command'
7
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fiend
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: atomos
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: CFPropertyList
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.3
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '4.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.3.3
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '4.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: colored2
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.1'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.1'
61
+ - !ruby/object:Gem::Dependency
62
+ name: nanaimo
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.2.4
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.2.4
75
+ - !ruby/object:Gem::Dependency
76
+ name: cocoapods
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 1.5.0
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.5.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: bundler
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.16'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.16'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rake
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '10.0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '10.0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rspec
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3.0'
131
+ description: 对当前iOS相关操作,进行自动化整合,目前有对Cocoapods的自动化整合!
132
+ email:
133
+ - 784767574@qq.com
134
+ executables:
135
+ - sl
136
+ extensions: []
137
+ extra_rdoc_files: []
138
+ files:
139
+ - README.md
140
+ - bin/sl
141
+ - lib/VERSION.rb
142
+ - lib/stool.rb
143
+ - lib/stool/Command.rb
144
+ - lib/stool/Command/Lib.rb
145
+ - lib/stool/Command/Lib/VersionAdd.rb
146
+ - lib/stool/Command/LibPool.rb
147
+ - lib/stool/Command/LibPool/Add.rb
148
+ - lib/stool/Command/LibPool/List.rb
149
+ - lib/stool/Command/WorkSpace.rb
150
+ - lib/stool/Command/WorkSpace/list.rb
151
+ - lib/stool/Command/WorkSpace/update.rb
152
+ - lib/stool/Core/BaseObj.rb
153
+ - lib/stool/Core/Config.rb
154
+ - lib/stool/Core/Git.rb
155
+ - lib/stool/Core/LibInfo.rb
156
+ - lib/stool/Core/PoolInfo.rb
157
+ - lib/stool/Core/TaskInfo.rb
158
+ - lib/stool/Utils/StringUtil.rb
159
+ - lib/stool/version.rb
160
+ homepage: https://rubygems.org/gems/Stool
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ - lib/stool
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.6.12
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: A tool for workflow!
185
+ test_files: []