Skip to content
  • Sponsor
  • Notifications You must be signed in to change notification settings
  • Fork 8

Commit dd8d3da

Browse files
committedMar 11, 2022
docs: add code documentation
1 parent 6b1ea7a commit dd8d3da

File tree

12 files changed

+113
-38
lines changed

12 files changed

+113
-38
lines changed
 

‎.github/workflows/main.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
paths-ignore:
1111
- '*.md'
1212
workflow_dispatch:
13+
inputs:
14+
release:
15+
description: Create release
16+
required: false
17+
type: boolean
1318

1419
env:
1520
RUBY_VER: 2.6
@@ -62,7 +67,7 @@ jobs:
6267

6368
cd:
6469
name: Build and Publish
65-
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.ci.outputs.release
70+
if: (github.event_name == 'push' && needs.ci.outputs.release) || (github.event_name == 'workflow_dispatch' && github.event.inputs.release)
6671
needs: ci
6772
runs-on: ubuntu-latest
6873

@@ -118,7 +123,7 @@ jobs:
118123
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
119124
env:
120125
GITHUB_TOKEN: ${{ github.token }}
121-
OWNER: ${{ github.actor }}
126+
OWNER: ${{ github.repository_owner }}
122127

123128
- name: Publish to RubyGems
124129
if: steps.conventional_changelog.outputs.skipped == 'false'
@@ -139,7 +144,3 @@ jobs:
139144
tag: ${{ steps.conventional_changelog.outputs.tag }}
140145
body: ${{ steps.conventional_changelog.outputs.changelog }}
141146
artifacts: '*.gem'
142-
143-
- name: Publish to cocoapods plugins
144-
if: steps.conventional_changelog.outputs.skipped == 'false'
145-
run: bundle exec rake publish

‎Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GEM
1111
specs:
1212
CFPropertyList (3.0.5)
1313
rexml
14-
activesupport (6.1.4.7)
14+
activesupport (6.1.5)
1515
concurrent-ruby (~> 1.0, >= 1.0.2)
1616
i18n (>= 1.6, < 2)
1717
minitest (>= 5.1)

‎cocoapods-embed-flutter.gemspec

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
44
require 'cocoapods-embed-flutter/gem_version.rb'
55

66
Gem::Specification.new do |spec|
7+
repo = 'DartBuild/cocoapods-embed-flutter'
8+
repo_url = "https://github.com/#{repo}"
9+
710
spec.name = 'cocoapods-embed-flutter'
811
spec.version = CocoapodsEmbedFlutter::VERSION
912
spec.authors = ['Soumya Ranjan Mahunt']
@@ -13,7 +16,7 @@ Gem::Specification.new do |spec|
1316
Straight forward way of declaring flutter modules as dependency for targets,
1417
just like cocoapods does with pods.
1518
DESC
16-
spec.homepage = 'https://github.com/DartBuild/cocoapods-embed-flutter'
19+
spec.homepage = repo_url
1720
spec.license = 'MIT'
1821

1922
spec.files = `git ls-files`.split($/)
@@ -27,4 +30,11 @@ Gem::Specification.new do |spec|
2730

2831
spec.add_development_dependency 'bundler'
2932
spec.add_development_dependency 'rake'
33+
34+
spec.metadata = {
35+
'bug_tracker_uri' => "#{repo_url}/issues",
36+
'changelog_uri' => "#{repo_url}/blob/main/CHANGELOG.md",
37+
'source_code_uri' => repo_url,
38+
'github_repo' => "git@github.com:#{repo}.git"
39+
}
3040
end

‎example/ios_app/Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GEM
1111
specs:
1212
CFPropertyList (3.0.5)
1313
rexml
14-
activesupport (6.1.4.7)
14+
activesupport (6.1.5)
1515
concurrent-ruby (~> 1.0, >= 1.0.2)
1616
i18n (>= 1.6, < 2)
1717
minitest (>= 5.1)

‎lib/cocoapods-embed-flutter.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
require 'cocoapods-embed-flutter/gem_version'
22
require 'cocoapods-embed-flutter/source'
33
require 'cocoapods-embed-flutter/hooks'
4+
require 'cocoapods-embed-flutter/flutter'
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# The Flutter modules name-spaces all the classes for Flutter.
2+
#
3+
module Flutter
4+
# The flutter command name.
5+
#
6+
NAME = 'flutter'.freeze
7+
# The directory name for flutter specific
8+
# files in a flutter project.
9+
#
10+
DIR_NAME = 'Flutter'.freeze
11+
# The Pub modules name-spaces all the classes for Flutter Pub.
12+
#
13+
module Pub
14+
# The file name for flutter specification declaration.
15+
#
16+
SPEC_FILE = 'pubspec.yaml'.freeze
17+
# The folder name containing flutter dependencies cache files.
18+
#
19+
TOOL_DIR = '.dart_tool'.freeze
20+
# The cache file name for flutter projects.
21+
#
22+
CACHE_FILE = 'package_config.json'.freeze
23+
24+
require 'cocoapods-embed-flutter/flutter/downloader'
25+
require 'cocoapods-embed-flutter/flutter/external_sources'
26+
27+
autoload :Dependency, 'cocoapods-embed-flutter/flutter/dependency'
28+
autoload :Spec, 'cocoapods-embed-flutter/flutter/pubspec'
29+
end
30+
end

‎lib/cocoapods-embed-flutter/flutter/dependency.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'cocoapods-embed-flutter/flutter/pubspec'
1+
require 'cocoapods-embed-flutter/flutter'
22

33
module Flutter
44
module Pub
@@ -76,7 +76,7 @@ def spec
7676

7777
# Install this dependency for the parent project.
7878
#
79-
# @return void
79+
# @return [void]
8080
#
8181
def install
8282
spec.setup if local?

‎lib/cocoapods-embed-flutter/flutter/downloader.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ module Downloader
99
# @return [Response] The download response for this download.
1010
#
1111
# @param [Request] request
12-
# the request that describes this pod download.
12+
# the request that describes the flutter project download.
1313
#
1414
# @param [Pathname,Nil] target
15-
# the location to which this pod should be downloaded. If `nil`,
16-
# then the pod will only be cached.
15+
# the location to which the flutter project should be downloaded.
1716
#
1817
# @param [Boolean] can_cache
1918
# whether caching is allowed.
2019
#
2120
# @param [Pathname,Nil] cache_path
22-
# the path used to cache pod downloads.
21+
# the path used to cache flutter project downloads.
2322
#
2423
# @todo Implement caching for remote sources.
2524
#

‎lib/cocoapods-embed-flutter/flutter/external_sources.rb

+29-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Similar to:
22
# https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/external_sources/abstract_external_source.rb
3-
require 'cocoapods-embed-flutter/flutter/downloader'
3+
require 'cocoapods-embed-flutter/flutter'
44
require 'cocoapods'
55

66
module Flutter
77
module Pub
8+
# The ExternalSources modules name-spaces all the classes
9+
# for accessing remote Flutter projects.
10+
#
811
module ExternalSources
12+
# The keys accepted by the hash of the source attribute.
13+
#
914
SOURCE_KEYS = {
1015
:git => [:tag, :branch, :commit, :submodules].freeze,
1116
:svn => [:folder, :tag, :revision].freeze,
@@ -97,11 +102,9 @@ def ==(other)
97102

98103
public
99104

100-
# @!group Subclasses hooks
101-
102105
# Fetches the external source from the remote according to the params.
103106
#
104-
# @param [Sandbox] sandbox
107+
# @param [Pod::Sandbox] sandbox
105108
# the sandbox where the specification should be stored.
106109
#
107110
# @return [void]
@@ -138,6 +141,12 @@ def normalized_pupspec_path(declared_path)
138141
Spec.find_file(name, declared_path)
139142
end
140143

144+
# Return the normalized path for a pubspec assuming sandbox
145+
# pod folder as location.
146+
#
147+
# @return [String] The uri of the pubspec appending the name of the file
148+
# and expanding it if necessary.
149+
#
141150
def normalized_pupspec_path
142151
Spec.find_file(name, target)
143152
end
@@ -146,21 +155,24 @@ def normalized_pupspec_path
146155

147156
# @! Subclasses helpers
148157

149-
# Pre-downloads a Pod passing the options to the downloader and informing
150-
# the sandbox.
158+
# Pre-downloads a flutter project passing the options to the downloader
159+
# and informing the sandbox.
151160
#
152-
# @param [Sandbox] sandbox
153-
# The sandbox where the Pod should be downloaded.
161+
# @param [Pod::Sandbox] sandbox
162+
# The sandbox where the flutter project should be downloaded.
154163
#
155-
# @note To prevent a double download of the repository the pod is
156-
# marked as pre-downloaded indicating to the installer that only
164+
# @note To prevent a double download of the repository the flutter project
165+
# is marked as pre-downloaded indicating to the installer that only
157166
# clean operations are needed.
158167
#
159168
# @todo The downloader configuration is the same of the
160-
# #{PodSourceInstaller} and it needs to be kept in sync.
169+
# #{Pod::Installer::PodSourceInstaller}
170+
# and it needs to be kept in sync.
161171
#
162172
# @return [void]
163173
#
174+
# @todo Implement caching for remote sources.
175+
#
164176
def pre_download(sandbox)
165177
title = "Pre-downloading: `#{name}` #{description}"
166178
Pod::UI.titled_section(title, :verbose_prefix => '-> ') do
@@ -185,13 +197,19 @@ def pre_download(sandbox)
185197
end
186198
end
187199

200+
# @return [Pod::Downloader::Request] the request to remote
201+
# flutter project source.
202+
#
188203
def download_request
189204
Pod::Downloader::Request.new(
190205
:name => name,
191206
:params => params,
192207
)
193208
end
194209

210+
# @return [String] the path where this flutter project
211+
# will be downloaded relative paths.
212+
#
195213
def target
196214
return Pod::Config.instance.sandbox.pod_dir(name)
197215
end

‎lib/cocoapods-embed-flutter/flutter/pubspec.rb

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
require 'cocoapods-embed-flutter/flutter/dependency'
1+
require 'cocoapods-embed-flutter/flutter'
22
require 'yaml'
33

44
module Flutter
5-
NAME = 'flutter'.freeze
6-
DIR_NAME = 'Flutter'.freeze
7-
85
module Pub
9-
SPEC_FILE = 'pubspec.yaml'.freeze
10-
TOOL_DIR = '.dart_tool'.freeze
11-
CACHE_FILE = 'package_config.json'.freeze
12-
136
# The Specification provides a DSL to describe a flutter project.
147
# A project is defined as a library originating from a source.
158
# A specification can support detailed attributes for modules of code
@@ -139,7 +132,7 @@ def setup?
139132

140133
# Sets up the project installing all specified dependencies.
141134
#
142-
# @return void
135+
# @return [void]
143136
#
144137
def setup
145138
return if setup?
@@ -149,7 +142,7 @@ def setup
149142

150143
# Runs `flutter pub get` on project directory.
151144
#
152-
# @return void
145+
# @return [void]
153146
#
154147
def pup_get
155148
Dir.chdir(project_path) { |path| system('flutter pub get', exception: true) }
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# The CocoapodsEmbedFlutter modules name-spaces
2+
# all the plugin specific classes.
3+
#
14
module CocoapodsEmbedFlutter
5+
# The version of the cocoapods-embed-flutter.
6+
#
27
VERSION = '0.5.0'.freeze
38
end

‎lib/cocoapods-embed-flutter/src/pub.rb

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
require 'cocoapods-embed-flutter/gem_version'
2-
require 'cocoapods-embed-flutter/flutter/pubspec'
3-
require 'cocoapods-embed-flutter/flutter/external_sources'
2+
require 'cocoapods-embed-flutter/flutter'
43

4+
# The Pod modules name-spaces all the classes and methods
5+
# providing flutter specific functionality to podfile.
6+
#
57
module Pod
8+
# The Podfile is a specification that describes the dependencies of the
9+
# targets of an Xcode project.
10+
#
11+
# It supports its own DSL and is stored in a file named `Podfile`.
12+
#
13+
# The Podfile creates a hierarchy of target definitions that store the
14+
# information necessary to generate the CocoaPods libraries.
15+
#
616
class Podfile
717
# The Podfile is a specification that describes the dependencies of the
818
# targets of one or more Xcode projects. With Embed Flutter
@@ -104,6 +114,14 @@ def pub(name = nil, *requirements)
104114
install_flutter_pods_for_pubspec(pubspec)
105115
end
106116

117+
# Integrates flutter module provided in `pubspec`
118+
# to an Xcode project target.
119+
#
120+
# @param [Flutter::Pub::Spec] pubspec
121+
# the flutter module project specification.
122+
#
123+
# @return [void]
124+
#
107125
def install_flutter_pods_for_pubspec(pubspec)
108126
raise ArgumentError, "Invalid `pubspec` argument." unless pubspec.is_a?(Flutter::Pub::Spec)
109127
load pubspec.pod_helper_path

0 commit comments

Comments
 (0)
Please sign in to comment.