appium_thor 1.1.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -27
- data/Thorfile +1 -4
- data/appium_thor.gemspec +1 -3
- data/docs/helpers_docs.md +11 -11
- data/lib/appium_thor/commands/commands.rb +6 -6
- data/lib/appium_thor/commands/init.rb +0 -1
- data/lib/appium_thor/config.rb +5 -9
- data/lib/appium_thor/helpers.rb +10 -10
- data/lib/appium_thor/version.rb +2 -2
- data/lib/appium_thor.rb +1 -3
- data/release_notes.md +14 -0
- metadata +7 -42
- data/lib/appium_thor/docs.rb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf2076f3692848707a188c8fd4894f6db4be3e9a3846c7ec968956bcff35996d
|
4
|
+
data.tar.gz: 9f7ae671336d09075b901b9d156d2472950ef6bf7bd576895aeb4e85600b83eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cecba2f6985427e8c22512f1111a01d84f981e1ddb290d07af18e3a3aa91b5b9024e93742fa9ee9a61672b84a4022f9b587f5251c5251153630036f7d68fbec4
|
7
|
+
data.tar.gz: 63fe0809f01b8d8dc6ea4db7dd340a4644299199b7e673df187cccd748f88b1cb769637a32f75c3738bd6a9bdd9dacf96f161f373fd567d9d3fdb40a98306327
|
data/README.md
CHANGED
@@ -14,10 +14,8 @@ Appium::Thor::Config.set do
|
|
14
14
|
gem_name 'appium_thor'
|
15
15
|
github_owner 'appium'
|
16
16
|
github_name 'appium_thor'
|
17
|
+
branch 'master'
|
17
18
|
version_file 'lib/appium_thor/version.rb'
|
18
|
-
docs_block do
|
19
|
-
run 'docs/helpers_docs.md', globs('/lib/appium_thor/helpers.rb')
|
20
|
-
end
|
21
19
|
end
|
22
20
|
|
23
21
|
# Must use '::' otherwise Default will point to Thor::Sandbox::Default
|
@@ -35,14 +33,16 @@ end
|
|
35
33
|
|
36
34
|
# Defaults
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
gem_name | must be provided
|
41
|
-
github_owner | `appium
|
42
|
-
github_name | `#{gem_name}
|
43
|
-
|
44
|
-
|
36
|
+
|Option | Default|
|
37
|
+
|---:|:---|
|
38
|
+
|gem_name | must be provided|
|
39
|
+
|github_owner | `appium`|
|
40
|
+
|github_name | `#{gem_name}`|
|
41
|
+
|branch | `master`|
|
42
|
+
|version_file | `lib/#{gem_name}/version.rb`|
|
45
43
|
|
44
|
+
`branch` customises the target branch to push changes.
|
45
|
+
Defaults to `master`
|
46
46
|
|
47
47
|
--
|
48
48
|
|
@@ -56,7 +56,6 @@ thor bump # Bump the z version number and update the date.
|
|
56
56
|
thor bumpx # Bump the x version number, set y & z to zero, update the date.
|
57
57
|
thor bumpy # Bump the y version number, set z to zero, update the date.
|
58
58
|
thor byte # Remove non-ascii bytes from all *.rb files in the current dir
|
59
|
-
thor docs # Update docs
|
60
59
|
thor gem_install # Install gem
|
61
60
|
thor gem_uninstall # Uninstall gem
|
62
61
|
thor info # prints config info for this gem
|
@@ -64,19 +63,3 @@ thor notes # Update release notes
|
|
64
63
|
thor publish # Build and release a new gem to rubygems.org
|
65
64
|
thor release # Build and release a new gem to rubygems.org (same as publish)
|
66
65
|
```
|
67
|
-
|
68
|
-
--
|
69
|
-
|
70
|
-
# docs_block
|
71
|
-
|
72
|
-
The `docs_block` method runs within the `docs.rb` context. Here's a more complex example:
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
common_globs = '/lib/appium_lib/*.rb', '/lib/appium_lib/device/*.rb', '/lib/appium_lib/common/**/*.rb'
|
76
|
-
android_globs = common_globs + ['/lib/appium_lib/android/**/*.rb']
|
77
|
-
ios_globs = common_globs + ['/lib/appium_lib/ios/**/*.rb']
|
78
|
-
|
79
|
-
run 'docs/android_docs.md', globs(android_globs)
|
80
|
-
|
81
|
-
run 'docs/ios_docs.md', globs(ios_globs)
|
82
|
-
```
|
data/Thorfile
CHANGED
data/appium_thor.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative 'lib/appium_thor/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.required_ruby_version = '>=
|
4
|
+
s.required_ruby_version = '>= 3.0'
|
5
5
|
|
6
6
|
s.name = 'appium_thor'
|
7
7
|
s.version = Appium::Thor::VERSION
|
@@ -13,8 +13,6 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.require_paths = ['lib']
|
14
14
|
|
15
15
|
s.add_runtime_dependency 'redcarpet', '~> 3.1', '>= 3.1.2'
|
16
|
-
s.add_runtime_dependency 'posix-spawn', '~> 0.3', '>= 0.3.8'
|
17
|
-
s.add_runtime_dependency 'yard', '~> 0.9.11'
|
18
16
|
|
19
17
|
s.files = `git ls-files`.split "\n"
|
20
18
|
end
|
data/docs/helpers_docs.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##### [_build_gem](https://github.com/appium/appium_thor/blob/
|
1
|
+
##### [_build_gem](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L6) common
|
2
2
|
|
3
3
|
> def _build_gem
|
4
4
|
|
@@ -7,7 +7,7 @@ Runs gem build gemspec
|
|
7
7
|
|
8
8
|
--
|
9
9
|
|
10
|
-
##### [tag_exists](https://github.com/appium/appium_thor/blob/
|
10
|
+
##### [tag_exists](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L12) common
|
11
11
|
|
12
12
|
> def tag_exists(tag_name)
|
13
13
|
|
@@ -15,7 +15,7 @@ Returns true if the tag exists on the master branch.
|
|
15
15
|
|
16
16
|
--
|
17
17
|
|
18
|
-
##### [sh](https://github.com/appium/appium_thor/blob/
|
18
|
+
##### [sh](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L18) common
|
19
19
|
|
20
20
|
> def sh(command)
|
21
21
|
|
@@ -23,7 +23,7 @@ Runs command. Raises an exception if the command doesn't execute successfully.
|
|
23
23
|
|
24
24
|
--
|
25
25
|
|
26
|
-
##### [version_rgx](https://github.com/appium/appium_thor/blob/
|
26
|
+
##### [version_rgx](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L30) common
|
27
27
|
|
28
28
|
> def version_rgx
|
29
29
|
|
@@ -31,7 +31,7 @@ Used to parse the version number from version_file
|
|
31
31
|
|
32
32
|
--
|
33
33
|
|
34
|
-
##### [version](https://github.com/appium/appium_thor/blob/
|
34
|
+
##### [version](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L35) common
|
35
35
|
|
36
36
|
> def version
|
37
37
|
|
@@ -39,7 +39,7 @@ Returns the version number from version_file as a string
|
|
39
39
|
|
40
40
|
--
|
41
41
|
|
42
|
-
##### [_bump](https://github.com/appium/appium_thor/blob/
|
42
|
+
##### [_bump](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L46) common
|
43
43
|
|
44
44
|
> def _bump(value)
|
45
45
|
|
@@ -55,7 +55,7 @@ __Parameters:__
|
|
55
55
|
|
56
56
|
--
|
57
57
|
|
58
|
-
##### [update_release_notes](https://github.com/appium/appium_thor/blob/
|
58
|
+
##### [update_release_notes](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L86) common
|
59
59
|
|
60
60
|
> def update_release_notes
|
61
61
|
|
@@ -64,7 +64,7 @@ Note that the first tag won't contain notes.
|
|
64
64
|
|
65
65
|
--
|
66
66
|
|
67
|
-
##### [_install](https://github.com/appium/appium_thor/blob/
|
67
|
+
##### [_install](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L150) common
|
68
68
|
|
69
69
|
> def _install
|
70
70
|
|
@@ -76,7 +76,7 @@ Installs the local gem. It's fast due to the flags
|
|
76
76
|
|
77
77
|
--
|
78
78
|
|
79
|
-
##### [_uninstall](https://github.com/appium/appium_thor/blob/
|
79
|
+
##### [_uninstall](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L157) common
|
80
80
|
|
81
81
|
> def _uninstall
|
82
82
|
|
@@ -84,7 +84,7 @@ Uninstalls all versions of the gem
|
|
84
84
|
|
85
85
|
--
|
86
86
|
|
87
|
-
##### [_publish](https://github.com/appium/appium_thor/blob/
|
87
|
+
##### [_publish](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L168) common
|
88
88
|
|
89
89
|
> def _publish
|
90
90
|
|
@@ -96,7 +96,7 @@ Publishes the gem to rubygems
|
|
96
96
|
|
97
97
|
--
|
98
98
|
|
99
|
-
##### [remove_non_ascii_from_cwd](https://github.com/appium/appium_thor/blob/
|
99
|
+
##### [remove_non_ascii_from_cwd](https://github.com/appium/appium_thor/blob/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee/lib/appium_thor/helpers.rb#L200) common
|
100
100
|
|
101
101
|
> def remove_non_ascii_from_cwd
|
102
102
|
|
@@ -6,6 +6,7 @@ class Default < Thor
|
|
6
6
|
gem_name: #{gem_name}
|
7
7
|
github_name: #{github_name}
|
8
8
|
github_owner: #{github_owner}
|
9
|
+
branch: #{branch}
|
9
10
|
version_file: #{version_file}
|
10
11
|
MSG
|
11
12
|
end
|
@@ -54,11 +55,6 @@ version_file: #{version_file}
|
|
54
55
|
_install
|
55
56
|
end
|
56
57
|
|
57
|
-
desc 'docs', 'Update docs'
|
58
|
-
def docs
|
59
|
-
instance_eval &docs_block if docs_block
|
60
|
-
end
|
61
|
-
|
62
58
|
desc 'notes', 'Update release notes'
|
63
59
|
def notes
|
64
60
|
update_release_notes
|
@@ -68,4 +64,8 @@ version_file: #{version_file}
|
|
68
64
|
def byte
|
69
65
|
remove_non_ascii_from_cwd
|
70
66
|
end
|
71
|
-
|
67
|
+
|
68
|
+
def self.exit_on_failure?
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
data/lib/appium_thor/config.rb
CHANGED
@@ -11,6 +11,8 @@ module Appium
|
|
11
11
|
@version_file ||= "lib/#{@gem_name}/version.rb"
|
12
12
|
end
|
13
13
|
|
14
|
+
@branch ||= 'master'
|
15
|
+
|
14
16
|
@github_owner ||= 'appium'
|
15
17
|
|
16
18
|
# ensure all options are set
|
@@ -19,21 +21,14 @@ module Appium
|
|
19
21
|
raise "version file doesn't exist #{@version_file}" unless File.exist?(@version_file)
|
20
22
|
end
|
21
23
|
|
22
|
-
# block of code to execute that contains documentation
|
23
|
-
# generation logic
|
24
|
-
def docs_block(&block)
|
25
|
-
return @docs_block if @docs_block
|
26
|
-
@docs_block = block
|
27
|
-
end
|
28
|
-
|
29
24
|
# Returns all options as symbols. Required for defining delegators in init.rb
|
30
25
|
def self.options
|
31
|
-
string_options
|
26
|
+
string_options
|
32
27
|
end
|
33
28
|
|
34
29
|
# the subset of options that operate on strings
|
35
30
|
def self.string_options
|
36
|
-
%w[gem_name github_name github_owner version_file].map(&:to_sym)
|
31
|
+
%w[gem_name github_name github_owner branch version_file].map(&:to_sym)
|
37
32
|
end
|
38
33
|
|
39
34
|
string_options.each do |option|
|
@@ -51,6 +46,7 @@ module Appium
|
|
51
46
|
# gem_name 'appium_thor'
|
52
47
|
# github_owner 'appium'
|
53
48
|
# github_name 'appium_thor'
|
49
|
+
# branch 'master'
|
54
50
|
# version_file 'path/to/version.rb'
|
55
51
|
# end
|
56
52
|
def self.set(&block)
|
data/lib/appium_thor/helpers.rb
CHANGED
@@ -11,19 +11,20 @@ module Appium
|
|
11
11
|
# Returns true if the tag exists on the master branch.
|
12
12
|
def tag_exists(tag_name)
|
13
13
|
cmd = %Q(git branch -a --contains "#{tag_name}")
|
14
|
-
|
14
|
+
stdout, status = Open3.capture2(cmd)
|
15
|
+
stdout.include? "* #{branch}"
|
16
|
+
|
15
17
|
end
|
16
18
|
|
17
19
|
# Runs command. Raises an exception if the command doesn't execute successfully.
|
18
20
|
def sh(command)
|
19
|
-
|
21
|
+
stdout, stderr, status = Open3.capture3(command)
|
20
22
|
|
21
|
-
unless
|
22
|
-
raise "Command #{command} failed. out: #{
|
23
|
+
unless status.success?
|
24
|
+
raise "Command #{command} failed. out: #{stdout}\nerr: #{stderr}"
|
23
25
|
end
|
24
26
|
|
25
|
-
|
26
|
-
out ? out.strip : out
|
27
|
+
stdout.strip
|
27
28
|
end
|
28
29
|
|
29
30
|
# Used to parse the version number from version_file
|
@@ -166,8 +167,8 @@ module Appium
|
|
166
167
|
# Builds the gem
|
167
168
|
# Publishes the gem to rubygems
|
168
169
|
def _publish
|
169
|
-
unless `git branch`.include?
|
170
|
-
puts '
|
170
|
+
unless `git branch`.include? "* #{branch}"
|
171
|
+
puts "'#{branch}' branch required to release."
|
171
172
|
exit!
|
172
173
|
end
|
173
174
|
|
@@ -187,9 +188,8 @@ module Appium
|
|
187
188
|
|
188
189
|
# update notes now that there's a new tag
|
189
190
|
notes rescue notes_failed = true
|
190
|
-
docs
|
191
191
|
sh "git commit --allow-empty -am 'Update release notes'" unless notes_failed
|
192
|
-
sh
|
192
|
+
sh "git push origin #{branch}"
|
193
193
|
sh "git push origin #{tag_name}"
|
194
194
|
_build_gem
|
195
195
|
puts "Please run 'gem push #{gem_name}-#{version}.gem'"
|
data/lib/appium_thor/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Appium
|
2
2
|
module Thor
|
3
|
-
VERSION = '
|
4
|
-
DATE = '
|
3
|
+
VERSION = '2.0.0' unless defined? ::Appium::Thor::VERSION
|
4
|
+
DATE = '2024-04-26' unless defined? ::Appium::Thor::DATE
|
5
5
|
end
|
6
6
|
end
|
data/lib/appium_thor.rb
CHANGED
@@ -2,15 +2,13 @@
|
|
2
2
|
require 'forwardable' # commands.rb
|
3
3
|
require 'singleton' # config.rb
|
4
4
|
require 'fileutils'
|
5
|
+
require 'open3'
|
5
6
|
|
6
7
|
# gems
|
7
8
|
require 'rubygems'
|
8
|
-
require 'yard' # docs.rb
|
9
|
-
require 'posix-spawn' # helpers.rb
|
10
9
|
require 'date' # helpers.rb Date.today
|
11
10
|
|
12
11
|
# internal
|
13
|
-
require_relative 'appium_thor/docs'
|
14
12
|
require_relative 'appium_thor/helpers'
|
15
13
|
require_relative 'appium_thor/version'
|
16
14
|
require_relative 'appium_thor/config'
|
data/release_notes.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
#### v2.0.0 2024-04-26
|
2
|
+
|
3
|
+
- [e83d36e](https://github.com/appium/appium_thor/commit/e83d36e65c48dcfc71b00d28837a4c57517cc6b2) Release 2.0.0
|
4
|
+
- [021199b](https://github.com/appium/appium_thor/commit/021199b3bb179432cac93709292a275470f4bca7) chore: remove posix-spawn
|
5
|
+
- [11848db](https://github.com/appium/appium_thor/commit/11848db549003ba9b267622eb3e2677c4b9a004d) chore: use ruby 3+
|
6
|
+
- [3b3cf1d](https://github.com/appium/appium_thor/commit/3b3cf1d278ec18923875c5469e4e1da31df92472) feat: remove docs (#8)
|
7
|
+
|
8
|
+
|
9
|
+
#### v1.2.0 2020-06-14
|
10
|
+
|
11
|
+
- [5c7025a](https://github.com/appium/appium_thor/commit/5c7025a14e9a6dba1ff0f69b733983d965e9c2ee) Release 1.2.0
|
12
|
+
- [d334d3a](https://github.com/appium/appium_thor/commit/d334d3af298f2bde9dd828d015ac8fd6a096a8e4) feat: Allow to customise the target branch (#7)
|
13
|
+
|
14
|
+
|
1
15
|
#### v1.1.6 2019-11-08
|
2
16
|
|
3
17
|
- [014fa19](https://github.com/appium/appium_thor/commit/014fa19e5a2cf8d2d8d85fbd3d139b9c7d67fb50) Release 1.1.6
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appium_thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- code@bootstraponline.com
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -30,40 +30,6 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.1.2
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: posix-spawn
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0.3'
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 0.3.8
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '0.3'
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 0.3.8
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: yard
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: 0.9.11
|
60
|
-
type: :runtime
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.9.11
|
67
33
|
description: Thor tasks for Appium gems.
|
68
34
|
email:
|
69
35
|
- code@bootstraponline.com
|
@@ -82,7 +48,6 @@ files:
|
|
82
48
|
- lib/appium_thor/commands/commands.rb
|
83
49
|
- lib/appium_thor/commands/init.rb
|
84
50
|
- lib/appium_thor/config.rb
|
85
|
-
- lib/appium_thor/docs.rb
|
86
51
|
- lib/appium_thor/helpers.rb
|
87
52
|
- lib/appium_thor/version.rb
|
88
53
|
- release_notes.md
|
@@ -90,7 +55,7 @@ homepage: https://github.com/appium/appium_thor
|
|
90
55
|
licenses:
|
91
56
|
- http://www.apache.org/licenses/LICENSE-2.0.txt
|
92
57
|
metadata: {}
|
93
|
-
post_install_message:
|
58
|
+
post_install_message:
|
94
59
|
rdoc_options: []
|
95
60
|
require_paths:
|
96
61
|
- lib
|
@@ -98,15 +63,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
63
|
requirements:
|
99
64
|
- - ">="
|
100
65
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
66
|
+
version: '3.0'
|
102
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
68
|
requirements:
|
104
69
|
- - ">="
|
105
70
|
- !ruby/object:Gem::Version
|
106
71
|
version: '0'
|
107
72
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
109
|
-
signing_key:
|
73
|
+
rubygems_version: 3.5.9
|
74
|
+
signing_key:
|
110
75
|
specification_version: 4
|
111
76
|
summary: Thor tasks for Appium gems.
|
112
77
|
test_files: []
|
data/lib/appium_thor/docs.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
module Appium
|
2
|
-
module Thor
|
3
|
-
module Docs
|
4
|
-
def space amount
|
5
|
-
' ' * amount
|
6
|
-
end
|
7
|
-
|
8
|
-
def last_sha
|
9
|
-
`git rev-parse --verify HEAD`.strip
|
10
|
-
end
|
11
|
-
|
12
|
-
def mobj_to_md obj
|
13
|
-
out = ''
|
14
|
-
# skip objects without method signatures
|
15
|
-
sig = obj.signature
|
16
|
-
return out unless sig
|
17
|
-
|
18
|
-
# skip class vars
|
19
|
-
if sig.start_with?('@@') ||
|
20
|
-
# skip methods marked private
|
21
|
-
obj.tag('private') ||
|
22
|
-
# skip date and version from version.rb
|
23
|
-
obj.name.match(/DATE|VERSION/)
|
24
|
-
|
25
|
-
return out
|
26
|
-
end
|
27
|
-
|
28
|
-
method_path = obj.file.split('/lib/').last
|
29
|
-
os = method_path.downcase.match(/ios|android/) || 'common'
|
30
|
-
out.concat("##### [#{obj.name.to_s}](https://github.com/#{github_owner}/#{github_name}/blob/#{last_sha}/lib/#{method_path}#L#{obj.line}) #{os}\n\n")
|
31
|
-
out.concat("> #{obj.signature}\n\n")
|
32
|
-
out.concat("#{obj.docstring}\n\n")
|
33
|
-
|
34
|
-
|
35
|
-
indent = space 5
|
36
|
-
params = obj.tags.select { |tag| tag.tag_name == 'param' }
|
37
|
-
unless params.empty?
|
38
|
-
out.concat("__Parameters:__\n\n")
|
39
|
-
params.each do |param|
|
40
|
-
out.concat("#{indent}[#{param.types.join(', ') unless param.types.nil?}] ")
|
41
|
-
out.concat("#{param.name} - #{param.text}\n\n")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
ret = obj.tag 'return'
|
46
|
-
if ret
|
47
|
-
out.concat("__Returns:__\n\n")
|
48
|
-
out.concat("#{indent}[#{ret.types.join(', ') unless ret.types.nil?}] #{ret.text}\n\n")
|
49
|
-
end
|
50
|
-
out.concat("--\n\n")
|
51
|
-
|
52
|
-
out
|
53
|
-
end
|
54
|
-
|
55
|
-
def run(out_file, globs)
|
56
|
-
YARD::Registry.clear
|
57
|
-
puts "Globbing: #{globs}"
|
58
|
-
puts "Writing: #{out_file}"
|
59
|
-
FileUtils.mkdir_p File.dirname out_file
|
60
|
-
YARD::Parser::SourceParser.parse globs
|
61
|
-
File.open(out_file, 'w') do |file|
|
62
|
-
entries = YARD::Registry.entries
|
63
|
-
entries_length = entries.length
|
64
|
-
puts "Processing: #{entries_length} entries"
|
65
|
-
raise 'No entries to process' if entries_length <= 0
|
66
|
-
YARD::Registry.entries.each do |entry|
|
67
|
-
file.write mobj_to_md entry
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
raise 'Empty file generated' if File.size(out_file) <= 0
|
72
|
-
end
|
73
|
-
|
74
|
-
def globs(paths)
|
75
|
-
# Convert single string to array for map
|
76
|
-
paths = [paths] unless paths.kind_of? Array
|
77
|
-
# Adjust path based on system
|
78
|
-
paths.map! { |path| "#{Dir.pwd}#{path}" }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|