fir-cli 1.1.5 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +8 -0
- data/.gitignore +1 -0
- data/CHANGELOG +10 -0
- data/README.md +43 -11
- data/Rakefile +3 -3
- data/fir-cli.gemspec +7 -3
- data/lib/fir/api.yml +11 -5
- data/lib/fir/cli.rb +39 -8
- data/lib/fir/patches/concern.rb +144 -0
- data/lib/fir/patches/native_patch.rb +19 -0
- data/lib/fir/patches.rb +1 -1
- data/lib/fir/util/build.rb +101 -60
- data/lib/fir/util/config.rb +35 -0
- data/lib/fir/util/http.rb +49 -0
- data/lib/fir/util/info.rb +6 -3
- data/lib/fir/util/login.rb +1 -0
- data/lib/fir/util/mapping.rb +65 -0
- data/lib/fir/util/me.rb +7 -6
- data/lib/fir/util/parser.rb +157 -0
- data/lib/fir/util/publish.rb +83 -64
- data/lib/fir/util.rb +34 -12
- data/lib/fir/version.rb +1 -1
- data/lib/fir.rb +0 -78
- data/test/build_ipa_test.rb +9 -0
- data/test/cases/test_apk.apk +0 -0
- data/test/cases/test_apk_txt +1 -0
- data/test/cases/test_ipa_dsym +0 -0
- data/test/info_test.rb +39 -0
- data/test/login_test.rb +12 -0
- data/test/mapping_test.rb +15 -0
- data/test/me_test.rb +17 -0
- data/test/publish_test.rb +14 -0
- data/test/test_helper.rb +49 -0
- metadata +48 -9
- data/lib/fir/patches/bin/pngcrush +0 -0
- data/lib/fir/patches/parser_patch.rb +0 -169
- data/test/fir_cli_test.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 246352dde6de24af1e32a1e0128bcb520526537f
|
4
|
+
data.tar.gz: 5321f7bfdf10cb2863cdeefd6bc01c898e7e9b7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f94e52edcbd93b3f2f9e75368722bc40ff64f54a3b07bf1bf9040e721cd2ec98beedbaa1fc959b60b63eef76126b3482509e3b9d2d2b5d2a95154a2bc5c984a
|
7
|
+
data.tar.gz: 8a4e0a531bdb8a1e32a4724838479f7cf613198d1cb86e24826cb2a16b02125f04080bf7f5950f87706ef0eb80579fb4a503bc3d01c464c5b25a7468a184cf46
|
data/.codeclimate.yml
ADDED
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## 更新记录
|
2
2
|
|
3
|
+
### FIR-CLI 1.1.7
|
4
|
+
- 增加符号表上传指令, `fir mapping(alias m)`
|
5
|
+
- 有一下三种方式上传符号表(目前已经支持 dSYM 和 txt 两种格式的符号表文件上传)
|
6
|
+
- 1. 指定 version 和 build 上传: `fir m <mapping file path> -P <bughd project id> -v <app version> -b <app build> -T <your api token>`
|
7
|
+
- 2. 在 publish 的时候自动上传: `fir p <app file path> -m <mapping file path> -P <bughd project id> -T <your api token>`
|
8
|
+
- 3. 在 build_ipa 的时候自动上传: `fir b <project dir> -P <bughd project id> -M -p -T <your api token>`
|
9
|
+
|
10
|
+
### FIR-CLI 1.1.6
|
11
|
+
- 不再转换 icon
|
12
|
+
|
3
13
|
### FIR-CLI 1.1.5
|
4
14
|
- 增加团队成员直接上传 app
|
5
15
|
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
FIR.im CLI
|
2
2
|
---
|
3
3
|
|
4
|
-
[![Join the chat at https://gitter.im/FIRHQ/fir-cli](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/FIRHQ/fir-cli?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
4
|
![Build Status Images](https://travis-ci.org/FIRHQ/fir-cli.svg)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/FIRHQ/fir-cli/badges/gpa.svg)](https://codeclimate.com/github/FIRHQ/fir-cli)
|
6
6
|
|
7
7
|
> FIR.im CLI 可以通过指令查看, 上传, 编译应用
|
8
8
|
|
@@ -15,16 +15,19 @@ FIR.im CLI 使用 Ruby 构建,只要安装相应 ruby gem 即可:
|
|
15
15
|
$ sudo gem install fir-cli
|
16
16
|
```
|
17
17
|
|
18
|
-
如果出现无法安装的现象,
|
18
|
+
如果出现无法安装的现象, 请先更换 Ruby 的淘宝源(由于国内网络原因, 你懂的), 并升级下系统自带的 gem
|
19
19
|
|
20
20
|
```shell
|
21
|
-
sudo gem
|
22
|
-
|
21
|
+
sudo gem sources --remove https://rubygems.org/
|
22
|
+
sudo gem sources -a https://ruby.taobao.org/
|
23
|
+
sudo gem sources -l
|
24
|
+
*** CURRENT SOURCES ***
|
23
25
|
|
24
|
-
|
26
|
+
https://ruby.taobao.org
|
27
|
+
# 请确保只有 ruby.taobao.org, 如果有其他的源, 请 remove 掉
|
25
28
|
|
26
|
-
```shell
|
27
29
|
sudo gem update --system
|
30
|
+
sudo gem install fir-cli
|
28
31
|
```
|
29
32
|
|
30
33
|
安装后,你可以在命令行执行指令
|
@@ -36,6 +39,8 @@ Commands:
|
|
36
39
|
fir help # Describe available commands or one specific command.
|
37
40
|
fir info APP_FILE_PATH # Show iOS/Android app's info, support ipa/apk file (aliases: 'i').
|
38
41
|
fir login # Login FIR.im (aliases: 'l').
|
42
|
+
fir mapping MAPPING_FILE_PATH # Upload app's mapping file to BugHD.com (aliases: 'm').
|
43
|
+
fir me # Show current user info if user is logined (aliases: 'm').
|
39
44
|
fir publish APP_FILE_PATH # Publish iOS/Android app to FIR.im, support ipa/apk file (aliases: 'p').
|
40
45
|
fir upgrade # Upgrade FIR-CLI and quit (aliases: u).
|
41
46
|
fir version # Show FIR-CLI version number and quit (aliases: v)
|
@@ -52,7 +57,7 @@ Options:
|
|
52
57
|
### 参数说明
|
53
58
|
|
54
59
|
- `alias <short command>` 意味着可以用 alias 别名来代替该指令, 例如 `fir b`
|
55
|
-
- `-T` 用户在 FIR.im 上的
|
60
|
+
- `-T` 用户在 FIR.im 上的 api_token, `publish` 需要使用此参数
|
56
61
|
- `-L` 指定 FIR-CLI 的输出 log, 默认为 STDOUT
|
57
62
|
- `-V` Verbose, 默认为输出所有信息( INFO 和 ERROR), 如果设置 `--no-verbose`, 则只输出 ERROR 信息
|
58
63
|
- `-q` 静默模式, 默认关闭
|
@@ -87,7 +92,7 @@ $ fir p path/to/application -T YOUR_FIR_TOKEN
|
|
87
92
|
$ fir l
|
88
93
|
```
|
89
94
|
|
90
|
-
这时系统会提示输入用户 token, 用户 token 可在[这里](http://fir.im/user/info)查看
|
95
|
+
这时系统会提示输入用户 token, 用户 token 可在 **[这里](http://fir.im/user/info)** 查看
|
91
96
|
|
92
97
|
```shell
|
93
98
|
> Please enter your FIR.im token:
|
@@ -108,16 +113,22 @@ $ fir build_ipa path/to/project -o path/to/output
|
|
108
113
|
```
|
109
114
|
|
110
115
|
### 复杂一点
|
111
|
-
|
116
|
+
|
117
|
+
```shell
|
112
118
|
$ fir b path/to/workspace -o path/to/output -w -C Release -t allTargets GCC_PREPROCESSOR_DEFINITIONS="FOO=bar"
|
113
119
|
```
|
114
120
|
|
115
121
|
该指令在指向的目录中,找到第一个 workspace 文件,对其进行编译。使用 `Release` 设置,编译策略为 `allTargets`,同时设置了预编译参数 `FOO`。
|
116
122
|
|
123
|
+
### 编译用 CocoaPods 做依赖管理的 .ipa包
|
124
|
+
|
125
|
+
```shell
|
126
|
+
$ fir b path/to/workspace -w -S <scheme name>
|
127
|
+
```
|
117
128
|
### 一步, 从源代码到 FIR.im
|
118
129
|
> 只需要输入 -p -T
|
119
130
|
|
120
|
-
```
|
131
|
+
```shell
|
121
132
|
$ fir build_ipa path/to/project -o path/to/output -p -T YOUR_FIR_TOKEN
|
122
133
|
> I, [2015-02-28T23:14:33.501293 #36861] INFO -- : Building......
|
123
134
|
> I, [2015-02-28T23:14:33.501400 #36861] INFO -- : ✈ -------------------------------------------- ✈
|
@@ -131,6 +142,27 @@ $ fir build_ipa path/to/project -o path/to/output -p -T YOUR_FIR_TOKEN
|
|
131
142
|
> I, [2015-02-28T23:14:48.311900 #36861] INFO -- : Published succeed: http://fir.im/xxx
|
132
143
|
```
|
133
144
|
|
145
|
+
### 上传符号表
|
146
|
+
|
147
|
+
有以下三种方式上传符号表至 [BugHD.com](http://bughd.com) 所对应的项目, 目前已经支持 dSYM 和 txt 两种格式的符号表文件上传
|
148
|
+
|
149
|
+
> 指定 version 和 build 上传:
|
150
|
+
|
151
|
+
```shell
|
152
|
+
$ fir m <mapping file path> -P <bughd project id> -v <app version> -b <app build> -T <your api token>
|
153
|
+
```
|
154
|
+
|
155
|
+
> 在 publish 的时候自动上传:
|
156
|
+
|
157
|
+
```shell
|
158
|
+
$ fir p <app file path> -m <mapping file path> -P <bughd project id> -T <your api token>
|
159
|
+
```
|
160
|
+
> 在 build_ipa 的时候自动上传:
|
161
|
+
|
162
|
+
```shell
|
163
|
+
$ fir b <project dir> -P <bughd project id> -M -p -T <your api token>
|
164
|
+
```
|
165
|
+
|
134
166
|
## 需要帮助?
|
135
167
|
|
136
168
|
输入以下指令获取全面功能介绍
|
@@ -140,7 +172,7 @@ $ fir -h
|
|
140
172
|
$ fir publish -h
|
141
173
|
```
|
142
174
|
|
143
|
-
如果还有疑问随时发邮件至[fir-cli](mailto:
|
175
|
+
如果还有疑问随时发邮件至 [fir-cli](mailto: dev@fir.im)
|
144
176
|
|
145
177
|
## 永远使用最新功能
|
146
178
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require File.expand_path('../test/test_helper', __FILE__)
|
2
3
|
|
3
4
|
desc "Run the tests."
|
4
5
|
task :test do
|
5
6
|
$: << "lib" << "test"
|
6
|
-
Dir["test/*_test.rb"].each { |f| require f[5..-
|
7
|
+
Dir["test/*_test.rb"].each { |f| require f[5..-4] }
|
7
8
|
end
|
8
9
|
|
9
|
-
task :
|
10
|
-
|
10
|
+
task default: :test
|
data/fir-cli.gemspec
CHANGED
@@ -28,18 +28,22 @@ Gem::Specification.new do |spec|
|
|
28
28
|
/_/ /___/_/ |_| \____/_____/___/
|
29
29
|
|
30
30
|
## 更新记录
|
31
|
-
### FIR-CLI 1.1.
|
31
|
+
### FIR-CLI 1.1.7
|
32
32
|
- 完全兼容新版 API ✔
|
33
33
|
- 请使用新版 API Token
|
34
34
|
- 新版 API Token 查看地址: `http://fir.im/user/info`
|
35
|
-
-
|
36
|
-
-
|
35
|
+
- 增加符号表上传指令, `fir mapping(alias m)`
|
36
|
+
- 有以下三种方式上传符号表(目前已经支持 dSYM 和 txt 两种格式的符号表文件上传)
|
37
|
+
- 1. 指定 version 和 build 上传: `fir m <mapping file path> -P <bughd project id> -v <app version> -b <app build> -T <your api token>`
|
38
|
+
- 2. 在 publish 的时候自动上传: `fir p <app file path> -m <mapping file path> -P <bughd project id> -T <your api token>`
|
39
|
+
- 3. 在 build_ipa 的时候自动上传: `fir b <project dir> -P <bughd project id> -M -p -T <your api token>`
|
37
40
|
- https://github.com/FIRHQ/fir-cli
|
38
41
|
)
|
39
42
|
|
40
43
|
spec.add_development_dependency "bundler", "~> 1.7"
|
41
44
|
spec.add_development_dependency "rake", "~> 10.0"
|
42
45
|
spec.add_development_dependency "minitest", "~> 5.7"
|
46
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
43
47
|
|
44
48
|
spec.add_dependency "thor", "~> 0.19"
|
45
49
|
spec.add_dependency "CFPropertyList", "~> 2.3"
|
data/lib/fir/api.yml
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
fir:
|
2
|
+
domain: 'http://fir.im'
|
3
|
+
base_url: 'http://api.fir.im'
|
4
|
+
user_url: 'http://api.fir.im/user'
|
5
|
+
app_url: 'http://api.fir.im/apps'
|
6
|
+
udids_url: 'http://api.fir.im/devices/multi_udid'
|
7
|
+
bughd:
|
8
|
+
domain: 'http://bughd.com'
|
9
|
+
base_url: 'http://api.bughd.com'
|
10
|
+
project_url: 'http://api.bughd.com/projects'
|
11
|
+
full_version_url: 'http://api.bughd.com/full_versions'
|
data/lib/fir/cli.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module FIR
|
4
4
|
class CLI < Thor
|
5
|
-
class_option :token, type: :string, aliases: "-T", desc: "User's
|
5
|
+
class_option :token, type: :string, aliases: "-T", desc: "User's API Token at FIR.im"
|
6
6
|
class_option :logfile, type: :string, aliases: "-L", desc: "Path to writable logfile"
|
7
7
|
class_option :verbose, type: :boolean, aliases: "-V", desc: "Show verbose", default: true
|
8
8
|
class_option :quiet, type: :boolean, aliases: "-q", desc: "Silence commands"
|
@@ -16,9 +16,11 @@ module FIR
|
|
16
16
|
|
17
17
|
Example:
|
18
18
|
|
19
|
-
$ fir b <project dir> [-C <configuration>] [-t <target name>] [-o <ipa output dir>] [settings] [-c <changelog>] [-p -T <your token>]
|
19
|
+
$ fir b <project dir> [-C <configuration>] [-t <target name>] [-o <ipa output dir>] [settings] [-c <changelog>] [-p -T <your api token>]
|
20
20
|
|
21
|
-
$ fir b <
|
21
|
+
$ fir b <project dir> [-c <changelog> -P <bughd project id> -M -p -T <your api token>]
|
22
|
+
|
23
|
+
$ fir b <workspace dir> -w -S <scheme name> [-C <configuration>] [-t <target name>] [-o <ipa output dir>] [settings] [-c <changelog>] [-p -T <your api token>]
|
22
24
|
LONGDESC
|
23
25
|
map ["b", "build"] => :build_ipa
|
24
26
|
method_option :workspace, type: :boolean, aliases: "-w", desc: "true/false if build workspace"
|
@@ -30,6 +32,8 @@ module FIR
|
|
30
32
|
method_option :publish, type: :boolean, aliases: "-p", desc: "true/false if publish to FIR.im"
|
31
33
|
method_option :short, type: :string, aliases: "-s", desc: "Set custom short link if publish to FIR.im"
|
32
34
|
method_option :changelog, type: :string, aliases: "-c", desc: "Set changelog if publish to FIR.im"
|
35
|
+
method_option :mapping, type: :boolean, aliases: "-M", desc: "true/false if upload app's mapping file to BugHD.com"
|
36
|
+
method_option :proj, type: :string, aliases: "-P", desc: "Project id in BugHD.com if upload app's mapping file"
|
33
37
|
def build_ipa *args
|
34
38
|
prepare :build_ipa
|
35
39
|
|
@@ -46,9 +50,19 @@ module FIR
|
|
46
50
|
end
|
47
51
|
|
48
52
|
desc "publish APP_FILE_PATH", "Publish iOS/Android app to FIR.im, support ipa/apk file (aliases: 'p')."
|
53
|
+
long_desc <<-LONGDESC
|
54
|
+
`publish` command will publish your app file to FIR.im, also the command support to publish app's short & changelog.
|
55
|
+
|
56
|
+
Example:
|
57
|
+
|
58
|
+
$ fir p <app file path> [-c <changelog> -s <custom short link> -T <your api token>]
|
59
|
+
$ fir p <app file path> [-c <changelog> -s <custom short link> -m <mapping file path> -P <bughd project id> -T <your api token>]
|
60
|
+
LONGDESC
|
49
61
|
map "p" => :publish
|
50
|
-
method_option :short,
|
51
|
-
method_option :changelog,
|
62
|
+
method_option :short, type: :string, aliases: "-s", desc: "Set custom short link"
|
63
|
+
method_option :changelog, type: :string, aliases: "-c", desc: "Set changelog"
|
64
|
+
method_option :mappingfile, type: :string, aliases: "-m", desc: "App's mapping file"
|
65
|
+
method_option :proj, type: :string, aliases: "-P", desc: "Project id in BugHD.com if upload app's mapping file"
|
52
66
|
def publish *args
|
53
67
|
prepare :publish
|
54
68
|
|
@@ -60,18 +74,35 @@ module FIR
|
|
60
74
|
def login *args
|
61
75
|
prepare :login
|
62
76
|
|
63
|
-
token = options[:token] || args.first || ask("Please enter your FIR.im
|
77
|
+
token = options[:token] || args.first || ask("Please enter your FIR.im API Token:", :white, echo: true)
|
64
78
|
FIR.login(token)
|
65
79
|
end
|
66
80
|
|
67
|
-
desc "me", "Show current user info if user is logined
|
68
|
-
map "m" => :me
|
81
|
+
desc "me", "Show current user info if user is logined."
|
69
82
|
def me *args
|
70
83
|
prepare :me
|
71
84
|
|
72
85
|
FIR.me
|
73
86
|
end
|
74
87
|
|
88
|
+
desc "mapping MAPPING_FILE_PATH", "Upload app's mapping file to BugHD.com (aliases: 'm')."
|
89
|
+
long_desc <<-LONGDESC
|
90
|
+
`mapping` command will upload your app's mapping file to BugHD.com if you have the same app/project in BugHD.com.
|
91
|
+
|
92
|
+
Example:
|
93
|
+
|
94
|
+
$ fir m <mapping file path> -P <bughd project id> -v <app version> -b <app build> -T <your fir api token>
|
95
|
+
LONGDESC
|
96
|
+
map "m" => :mapping
|
97
|
+
method_option :proj, type: :string, aliases: "-P", desc: "Project id in BugHD.com"
|
98
|
+
method_option :version, type: :string, aliases: "-v", desc: "App version"
|
99
|
+
method_option :build, type: :string, aliases: "-b", desc: "App build"
|
100
|
+
def mapping *args
|
101
|
+
prepare :mapping
|
102
|
+
|
103
|
+
FIR.mapping(*args, options)
|
104
|
+
end
|
105
|
+
|
75
106
|
desc "upgrade", "Upgrade FIR-CLI and quit (aliases: u)."
|
76
107
|
map "u" => :upgrade
|
77
108
|
def upgrade
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module ActiveSupport
|
4
|
+
# A typical module looks like this:
|
5
|
+
#
|
6
|
+
# module M
|
7
|
+
# def self.included(base)
|
8
|
+
# base.extend ClassMethods
|
9
|
+
# base.class_eval do
|
10
|
+
# scope :disabled, -> { where(disabled: true) }
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# module ClassMethods
|
15
|
+
# ...
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# By using <tt>ActiveSupport::Concern</tt> the above module could instead be
|
20
|
+
# written as:
|
21
|
+
#
|
22
|
+
# require 'active_support/concern'
|
23
|
+
#
|
24
|
+
# module M
|
25
|
+
# extend ActiveSupport::Concern
|
26
|
+
#
|
27
|
+
# included do
|
28
|
+
# scope :disabled, -> { where(disabled: true) }
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# class_methods do
|
32
|
+
# ...
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# Moreover, it gracefully handles module dependencies. Given a +Foo+ module
|
37
|
+
# and a +Bar+ module which depends on the former, we would typically write the
|
38
|
+
# following:
|
39
|
+
#
|
40
|
+
# module Foo
|
41
|
+
# def self.included(base)
|
42
|
+
# base.class_eval do
|
43
|
+
# def self.method_injected_by_foo
|
44
|
+
# ...
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# module Bar
|
51
|
+
# def self.included(base)
|
52
|
+
# base.method_injected_by_foo
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# class Host
|
57
|
+
# include Foo # We need to include this dependency for Bar
|
58
|
+
# include Bar # Bar is the module that Host really needs
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# But why should +Host+ care about +Bar+'s dependencies, namely +Foo+? We
|
62
|
+
# could try to hide these from +Host+ directly including +Foo+ in +Bar+:
|
63
|
+
#
|
64
|
+
# module Bar
|
65
|
+
# include Foo
|
66
|
+
# def self.included(base)
|
67
|
+
# base.method_injected_by_foo
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# class Host
|
72
|
+
# include Bar
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
# Unfortunately this won't work, since when +Foo+ is included, its <tt>base</tt>
|
76
|
+
# is the +Bar+ module, not the +Host+ class. With <tt>ActiveSupport::Concern</tt>,
|
77
|
+
# module dependencies are properly resolved:
|
78
|
+
#
|
79
|
+
# require 'active_support/concern'
|
80
|
+
#
|
81
|
+
# module Foo
|
82
|
+
# extend ActiveSupport::Concern
|
83
|
+
# included do
|
84
|
+
# def self.method_injected_by_foo
|
85
|
+
# ...
|
86
|
+
# end
|
87
|
+
# end
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# module Bar
|
91
|
+
# extend ActiveSupport::Concern
|
92
|
+
# include Foo
|
93
|
+
#
|
94
|
+
# included do
|
95
|
+
# self.method_injected_by_foo
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
#
|
99
|
+
# class Host
|
100
|
+
# include Bar # It works, now Bar takes care of its dependencies
|
101
|
+
# end
|
102
|
+
module Concern
|
103
|
+
class MultipleIncludedBlocks < StandardError #:nodoc:
|
104
|
+
def initialize
|
105
|
+
super "Cannot define multiple 'included' blocks for a Concern"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.extended(base) #:nodoc:
|
110
|
+
base.instance_variable_set(:@_dependencies, [])
|
111
|
+
end
|
112
|
+
|
113
|
+
def append_features(base)
|
114
|
+
if base.instance_variable_defined?(:@_dependencies)
|
115
|
+
base.instance_variable_get(:@_dependencies) << self
|
116
|
+
return false
|
117
|
+
else
|
118
|
+
return false if base < self
|
119
|
+
@_dependencies.each { |dep| base.send(:include, dep) }
|
120
|
+
super
|
121
|
+
base.extend const_get(:ClassMethods) if const_defined?(:ClassMethods)
|
122
|
+
base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def included(base = nil, &block)
|
127
|
+
if base.nil?
|
128
|
+
raise MultipleIncludedBlocks if instance_variable_defined?(:@_included_block)
|
129
|
+
|
130
|
+
@_included_block = block
|
131
|
+
else
|
132
|
+
super
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def class_methods(&class_methods_module_definition)
|
137
|
+
mod = const_defined?(:ClassMethods, false) ?
|
138
|
+
const_get(:ClassMethods) :
|
139
|
+
const_set(:ClassMethods, Module.new)
|
140
|
+
|
141
|
+
mod.module_eval(&class_methods_module_definition)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -197,3 +197,22 @@ class Hash
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
200
|
+
|
201
|
+
class File
|
202
|
+
|
203
|
+
class << self
|
204
|
+
# A binary file is Mach-O dSYM
|
205
|
+
#
|
206
|
+
# @return [true, false]
|
207
|
+
def is_dsym? file_path
|
208
|
+
!!(`file -b #{file_path}` =~ /dSYM/)
|
209
|
+
end
|
210
|
+
|
211
|
+
# A file is ASCII text
|
212
|
+
#
|
213
|
+
# @return [true, false]
|
214
|
+
def is_txt? file_path
|
215
|
+
!!(`file -b #{file_path}` =~ /text/)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|