pixab 0.1.0

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
+ SHA256:
3
+ metadata.gz: 24860067840a1b6784ebde7e069f65f47eb42bb10c8c967b87b37c7d6d97ac4b
4
+ data.tar.gz: 51d0b8dc02d032b103640154b8a5387bbd658a803ac1ef894d34d9652e948f5c
5
+ SHA512:
6
+ metadata.gz: 39edad6bde0aecb0030f1f1944e356d0eba931c3217eb71f6a3baa26511e1cf9503d573cc06a2cd65fe243269faf9200455060de8271a7dee0c0a4459ac05059
7
+ data.tar.gz: b269bf421f0b4afb35c39242872cb5ab0639847946af250ab637f14b72b3d68e925a9092c2fe36885a48790ff7dc504372dd926d282cdeb24d811da3a4eefb33
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-12-20
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at lzr3@us.meitu.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in pixab.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 廖再润
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,37 @@
1
+ # Pixab
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/pixab`. 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
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add pixab
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install pixab
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ 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.
24
+
25
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pixab. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/pixab/blob/main/CODE_OF_CONDUCT.md).
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the Pixab project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pixab/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/exe/pixab ADDED
@@ -0,0 +1,30 @@
1
+
2
+ #!/usr/bin/env ruby
3
+ # encoding: UTF-8
4
+
5
+ require_relative '../lib/MergeRequest.rb'
6
+ require_relative '../lib/ComponentSynchronizer.rb'
7
+
8
+ case ARGV[0]
9
+ when 'merge'
10
+ Pixab::MergeRequest.new(Pixab::RepoManager.new, ARGV[1..-1]).run
11
+ when 'sync'
12
+ repo_manager = Pixab::RepoManager.new
13
+ Pixab::ComponentSynchronizer.new(repo_manager, ARGV[1..-1]).run
14
+
15
+ is_need_commit = Pixab::Utilities.display_default_dialog("是否需要提交代码")
16
+ if is_need_commit
17
+ commands = ["-m"]
18
+ if !synchronizer.updated_repo_names.empty?
19
+ default_commit_msg = "[Feature]Update"
20
+ updated_repo_names.each do |repo_name|
21
+ default_commit_msg += " #{repo_name}"
22
+ end
23
+ commands.push("--commit-m")
24
+ commands.push(default_commit_msg)
25
+ end
26
+ Pixab::MergeRequest.new(repo_manager, commands).run
27
+ end
28
+ else
29
+ puts "Invalid command".red
30
+ end
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require "fileutils"
5
+ require 'colored2'
6
+ require 'open3'
7
+ require_relative './Utilities.rb'
8
+ require_relative './RepoManager.rb'
9
+
10
+ module Pixab
11
+
12
+ class ComponentSynchronizer
13
+
14
+ attr_accessor :is_need_build
15
+ attr_reader :repo_manager, :repos, :main_repo_name, :updated_repo_names
16
+
17
+ def initialize(repo_manager = RepoManager.new, commands = nil)
18
+ @repo_manager = repo_manager
19
+ @is_need_build = false
20
+ if commands.nil?
21
+ return
22
+ end
23
+ commands.each_index do |index|
24
+ command = commands[index]
25
+ case command
26
+ when "--build"
27
+ @is_need_build = true
28
+ else
29
+ end
30
+ end
31
+ end
32
+
33
+ def run
34
+ read_repo_infos
35
+ puts "\n》》》》》正在将本地调试仓替换为远程仓 》》》》》》》》》》\n".green
36
+ active_repo_names = replace_local_to_remote
37
+ puts "\n》》》》》正在合并主工程代码 》》》》》》》》》》》》》》》\n".green
38
+ merge_and_check
39
+ puts "\n》》》》》正在读取最新提交,并更新pod 》》》》》》》》》》\n".green
40
+ replace_podfile
41
+ puts "\n》》》》》正在将远程仓复原为本地调试仓 》》》》》》》》》》\n".green
42
+ reset_remote_to_local(active_repo_names)
43
+ if is_need_build
44
+ puts "\n》》》》》正在进行Xcode编译 》》》》》》》》》》》》》》》\n".green
45
+ FileUtils.cd("#{repo_manager.root_path}/#{main_repo_name}")
46
+ build
47
+ end
48
+ end
49
+
50
+ # 读取组件信息
51
+ def read_repo_infos
52
+ @repos = repo_manager.sub_repos
53
+ @main_repo_name = repo_manager.main_repo["name"]
54
+ end
55
+
56
+ # 将本地调试仓修改为远程仓
57
+ def replace_local_to_remote
58
+ active_repo_names = ""
59
+ repos.each do |repo|
60
+ components = repo["components"]
61
+ is_avtive = true
62
+ components.each do |component|
63
+ if component["tool"] == "CocoaPods"
64
+ is_avtive = !component["active"].empty?
65
+ break
66
+ end
67
+ end
68
+ if is_avtive
69
+ active_repo_names += " #{repo["name"]}"
70
+ end
71
+ end
72
+
73
+ if !active_repo_names.empty?
74
+ system "mbox deactivate#{active_repo_names}"
75
+ system "mbox pod install"
76
+ Utilities.check_shell_result("Error: execute `mbox pod install` failed")
77
+ end
78
+ return active_repo_names
79
+ end
80
+
81
+ # 将远程仓重置为本地调试仓
82
+ def reset_remote_to_local(active_repo_names)
83
+ if active_repo_names.nil? || active_repo_names.empty?
84
+ return
85
+ end
86
+ system "mbox activate#{active_repo_names}"
87
+ end
88
+
89
+ # 合并代码并检查冲突
90
+ def merge_and_check
91
+ system "mbox merge --repo #{main_repo_name}"
92
+ FileUtils.cd("#{repo_manager.root_path}/#{main_repo_name}")
93
+ `git --no-pager diff --check`
94
+ conflict_hint = "Error: code conflict!\n"
95
+ conflict_hint += "step1: Resolve `#{main_repo_name}` code conflicts\n"
96
+ conflict_hint += "step2: Execute this script again"
97
+ Utilities.check_shell_result(conflict_hint)
98
+ end
99
+
100
+ # 替换主工程Podfile
101
+ def replace_podfile
102
+ # 获取每个子库最新的commit id
103
+ repo_commite_id = {}
104
+ repos.each do |repo|
105
+ repo_name = repo["name"]
106
+ repo_target_branch = repo["target_branch"]
107
+ FileUtils.cd("#{repo_manager.root_path}/#{repo_name}")
108
+ commit_id = `git log origin/#{repo_target_branch} -n 1 --pretty=format:"%H"`
109
+ if !commit_id.nil?
110
+ repo_commite_id[repo_name] = commit_id
111
+ end
112
+ end
113
+
114
+ podfile_path = "#{repo_manager.root_path}/#{main_repo_name}/AirBrushPodfiles/pix_ab_component.rb"
115
+ podfile_content = File.read(podfile_path)
116
+ updated_repo_names = []
117
+ repo_commite_id.each do |key, value|
118
+ reg = /#{key}.+:commit => '(.+)'/
119
+ podfile_content.match(reg)
120
+ if $1 != value
121
+ podfile_content.sub!($1,value)
122
+ updated_repo_names.push(key)
123
+ end
124
+ end
125
+
126
+ if !updated_repo_names.empty?
127
+ File.open(podfile_path, "w+") do |aFile|
128
+ aFile.syswrite(podfile_content)
129
+ end
130
+ end
131
+
132
+ system "mbox pod install --repo-update"
133
+ Utilities.check_shell_result("Error: execute `mbox pod install --repo-update` failed")
134
+
135
+ @updated_repo_names = updated_repo_names
136
+ end
137
+
138
+ # 编译
139
+ def build
140
+ workspace_name = nil
141
+ expect_ext = ".xcworkspace"
142
+ Dir.foreach(Dir.pwd) do |entry|
143
+ if File.extname(entry) == expect_ext
144
+ workspace_name = entry
145
+ break
146
+ end
147
+ end
148
+
149
+ if workspace_name.nil?
150
+ puts "Error: no workspace available for build".red
151
+ exit(1)
152
+ end
153
+
154
+ scheme = File.basename(workspace_name, expect_ext)
155
+
156
+ stdout, stderr, status = Open3.capture3("xcodebuild -workspace #{workspace_name} -scheme #{scheme} -showdestinations")
157
+ reg = /{ platform:iOS,.+name:(?!Any iOS Devic)(.*) }/
158
+ destinations = []
159
+ stdout.scan(reg) do |match|
160
+ destinations.push(match.first)
161
+ end
162
+ selected_item_name = nil
163
+ if destinations.empty?
164
+ puts "Error: no devices available for build".red
165
+ exit(1)
166
+ elsif destinations.length == 1
167
+ selected_item_name = destinations.first
168
+ else
169
+ selected_item_name = Utilities.display_choose_list(destinations, [destinations.last],"设备","请选择编译设备").first
170
+ end
171
+ if selected_item_name.nil?
172
+ exit(1)
173
+ end
174
+
175
+ system("xcodebuild -workspace #{workspace_name} -scheme #{scheme} -configuration Debug -destination 'platform=iOS,name=#{selected_item_name}'")
176
+ Utilities.check_shell_result("Error: xcode build failed")
177
+ end
178
+
179
+ end
180
+
181
+ end
182
+
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require "fileutils"
5
+ require 'colored2'
6
+ require_relative './Utilities.rb'
7
+ require_relative './RepoManager.rb'
8
+
9
+ module Pixab
10
+
11
+ class MergeRequest
12
+
13
+ attr_accessor :repo_type, :default_commit_msg
14
+ attr_reader :repo_manager, :repos, :command_options
15
+
16
+ def initialize(repo_manager = RepoManager.new, commands = nil)
17
+ @repo_manager = repo_manager
18
+ @repo_type = 2
19
+ @default_commit_msg = "[Feature]"
20
+ if commands.nil?
21
+ return
22
+ end
23
+ commands.each_index do |index|
24
+ command = commands[index]
25
+ case command
26
+ when "-a"
27
+ @repo_type = 0
28
+ when "-m"
29
+ @repo_type = 1
30
+ when "--commit-m"
31
+ @default_commit_msg = commands[index + 1]
32
+ else
33
+ end
34
+ end
35
+ end
36
+
37
+ def run
38
+ read_repo_infos
39
+ commit
40
+ merge
41
+ push_and_create_mr
42
+ end
43
+
44
+ # 读取组件信息
45
+ def read_repo_infos()
46
+ main_repo = repo_manager.main_repo
47
+ @command_options = ""
48
+ case repo_type
49
+ when 0
50
+ when 1
51
+ @repos = [main_repo]
52
+ @command_options = " --repo #{main_repo["name"]}"
53
+ else
54
+ @repos = repo_manager.sub_repos
55
+ @command_options = " --no-repo #{main_repo["name"]}"
56
+ end
57
+ end
58
+
59
+ # 提交代码
60
+ def commit()
61
+ should_commit = false
62
+ repos.each do |repo|
63
+ repo_name = repo["name"]
64
+ FileUtils.cd("#{repo_manager.root_path}/#{repo_name}")
65
+ git_status = `git status --porcelain`
66
+ if !git_status.empty?
67
+ should_commit = true
68
+ break
69
+ end
70
+ end
71
+
72
+ if should_commit
73
+ input_msg = Utilities.display_dialog("请输入提交信息:", default_commit_msg.nil? ? "" : default_commit_msg)
74
+ reg = /\[(Feature|Bugfix|Optimization|Debug)\][a-z_A-Z0-9\-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'<>~\·`\?:;|\s]+$/
75
+ commit_msg = input_msg.match(reg)
76
+ if commit_msg.nil?
77
+ puts "Error: commit message is malformed".red
78
+ exit(1)
79
+ end
80
+
81
+ system "mbox git add .#{command_options}"
82
+ system "mbox git commit -m \"#{commit_msg}\"#{command_options}"
83
+ end
84
+ end
85
+
86
+ # 合并代码
87
+ def merge()
88
+ is_need_merge = Utilities.display_default_dialog("是否需要合并远程代码到本地?")
89
+ if is_need_merge
90
+ repos.each do |repo|
91
+ system "mbox merge --repo #{repo["name"]}"
92
+ end
93
+ end
94
+ end
95
+
96
+ # 推送MR
97
+ def push_and_create_mr()
98
+ is_need_creat_mr = Utilities.display_default_dialog("是否需要推送到远程并创建MR?")
99
+ if is_need_creat_mr
100
+ reviewers = Utilities.display_dialog("请输入审核人员ID:\n子琰(979) 丕臻(1385) 再润(1569) 思保(1922)", "979 1385").split()
101
+ mr_request_assign = ""
102
+ reviewers.each do |reviewer|
103
+ mr_request_assign += " -o merge_request.assign=#{reviewer}"
104
+ end
105
+
106
+ mr_source_branch = "-o merge_request.remove_source_branch"
107
+ repos.each do |repo|
108
+ repo_name = repo["name"]
109
+ puts repo_name
110
+ repo_target_branch = repo["target_branch"]
111
+ repo_last_branch = repo["last_branch"]
112
+
113
+ FileUtils.cd("#{repo_manager.root_path}/#{repo_name}")
114
+ log_content = `git log origin/#{repo_target_branch}..#{repo_last_branch} --pretty=format:"%H"`
115
+ if log_content.empty?
116
+ next
117
+ end
118
+ mr_target = "-o merge_request.target=#{repo_target_branch}"
119
+ # mr_title = "-o merge_request.title=#{repo_last_branch}"
120
+ `git push -o merge_request.create #{mr_target} #{mr_source_branch} #{mr_request_assign}`
121
+ end
122
+ end
123
+ end
124
+
125
+ end
126
+
127
+ end
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require 'json'
5
+ require "fileutils"
6
+
7
+ module Pixab
8
+
9
+ class RepoManager
10
+
11
+ attr_reader :root_path, :repos
12
+
13
+ def initialize()
14
+ read_repo_infos
15
+ end
16
+
17
+ def read_repo_infos
18
+ mbox_root = `mbox status --only root`
19
+ Utilities.check_shell_result('Error: This is not `Mbox` directory')
20
+ @root_path = mbox_root.split().last
21
+
22
+ FileUtils.cd(root_path)
23
+ json = File.read(".mbox/config.json")
24
+ obj = JSON.parse(json)
25
+ current_feature_name = obj["current_feature_name"]
26
+ if current_feature_name.empty?
27
+ puts "Error: You are currently in Free Mode".red
28
+ exit(1)
29
+ end
30
+ feature = obj["features"][current_feature_name.downcase]
31
+ @repos = feature["repos"]
32
+ end
33
+
34
+ def main_repo
35
+ repos.first
36
+ end
37
+
38
+ def sub_repos
39
+ if repos.length > 1
40
+ sub_repos = repos.dup
41
+ sub_repos.delete_at(0)
42
+ return sub_repos
43
+ end
44
+ return []
45
+ end
46
+
47
+ end
48
+
49
+ end
data/lib/Utilities.rb ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require 'colored2'
5
+
6
+ module Pixab
7
+
8
+ class Utilities
9
+
10
+ end
11
+
12
+ class << Utilities
13
+
14
+ def check_shell_result(error_msg = nil, success = nil)
15
+ is_success = success.nil? ? $?.to_i == 0 : success
16
+ if is_success
17
+ return
18
+ end
19
+ if !error_msg.nil?
20
+ puts error_msg.red
21
+ end
22
+ exit(1)
23
+ end
24
+
25
+ def display_default_dialog(default_text)
26
+ input_msg = `osascript -e 'display dialog "#{default_text}"'`.chomp
27
+ reg = /button returned:(.+)/
28
+ input_msg.match(reg)
29
+ !$1.nil?
30
+ end
31
+
32
+ def display_dialog(default_text, default_answer = "")
33
+ input_msg = `osascript -e 'display dialog "#{default_text}" default answer "#{default_answer}"'`.chomp
34
+ reg = /text returned:(.+)/
35
+ input_msg.match(reg)
36
+ $1.nil? ? "" : $1
37
+ end
38
+
39
+ def display_choose_list(items, default_items = nil, title = nil, prompt = nil, ok_button_name = nil, cancel_button_name = nil, is_multiple_selections = false)
40
+ shell = "osascript -e 'choose from list #{items}"
41
+ if !title.nil?
42
+ shell += " with title \"#{title}\""
43
+ end
44
+ if !prompt.nil?
45
+ shell += " with prompt \"#{prompt}\""
46
+ end
47
+ if !ok_button_name.nil?
48
+ shell += " OK button name \"#{ok_button_name}\""
49
+ end
50
+ if !cancel_button_name.nil?
51
+ shell += " cancel button name \"#{cancel_button_name}\""
52
+ end
53
+ if !default_items.nil?
54
+ shell += " default items #{default_items}"
55
+ end
56
+ if is_multiple_selections
57
+ shell += " with multiple selections allowed"
58
+ end
59
+ shell += "'"
60
+ selected_item_string = `#{shell}`.chomp
61
+ if selected_item_string == "false"
62
+ return []
63
+ else
64
+ return selected_item_string.split(",")
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pixab
4
+ VERSION = "0.1.0"
5
+ end
data/lib/pixab.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "pixab/version"
4
+
5
+ module Pixab
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
data/pixab.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/pixab/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "pixab"
7
+ spec.version = Pixab::VERSION
8
+ spec.authors = ["廖再润"]
9
+ spec.email = ["lzr3@us.meitu.com"]
10
+
11
+ spec.summary = "Write a short summary, because RubyGems requires one."
12
+ spec.description = "Write a longer description or delete this line."
13
+ spec.homepage = "https://github.com/LZRun"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ # spec.metadata["allowed_push_host"] = "Set to your gem server 'https://example.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/LZRun/multiple_project_tools"
21
+ spec.metadata["changelog_uri"] = "https://github.com/LZRun/multiple_project_tools"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ # Uncomment to register a new dependency of your gem
36
+ # spec.add_dependency "example-gem", "~> 1.0"
37
+
38
+ # For more information and examples about making a new gem, check out our
39
+ # guide at: https://bundler.io/guides/creating_gem.html
40
+ end
data/sig/pixab.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Pixab
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pixab
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - 廖再润
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Write a longer description or delete this line.
14
+ email:
15
+ - lzr3@us.meitu.com
16
+ executables:
17
+ - pixab
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - exe/pixab
28
+ - lib/ComponentSynchronizer.rb
29
+ - lib/MergeRequest.rb
30
+ - lib/RepoManager.rb
31
+ - lib/Utilities.rb
32
+ - lib/pixab.rb
33
+ - lib/pixab/version.rb
34
+ - pixab.gemspec
35
+ - sig/pixab.rbs
36
+ homepage: https://github.com/LZRun
37
+ licenses:
38
+ - MIT
39
+ metadata:
40
+ homepage_uri: https://github.com/LZRun
41
+ source_code_uri: https://github.com/LZRun/multiple_project_tools
42
+ changelog_uri: https://github.com/LZRun/multiple_project_tools
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 2.6.0
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.1.2
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Write a short summary, because RubyGems requires one.
62
+ test_files: []