cocoapods-acknowledgements 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab57b2637b279669a7dd0b4db49d6998da1ed244
4
+ data.tar.gz: e982c6d053c1cc0b24c73bf96fde9b49054377d6
5
+ SHA512:
6
+ metadata.gz: 25e5b279dcb470db443765d10eb684ad2b65f5952dbc410ee82eaafb7eee06f6641ce64d4050d10f7a2c59181f3d8c69c51c46515ed104bb78c2cf0daedf61b0
7
+ data.tar.gz: e3c1fdead333ccd712641ca6f0209f7c89ab2bc4be92afa75a03d77f4e9c31d563a0f9e8a49ea8e07aeee06ae973e3933dbc7c9b5b87ac74d207544e33a11742
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,10 @@
1
+ language: objective-c
2
+ env:
3
+ # This is what 10.8.x comes with and we want to support that.
4
+ - RVM_RUBY_VERSION=system NOEXEC_DISABLE=1 RUBY_VERSION_SPECIFIC='sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2' SSL_CERT_FILE=/usr/local/share/cacert.pem GIT_AUTHOR_NAME=CocoaPods GIT_AUTHOR_EMAIL=cocoapods@example.com PYTHONPATH=/usr/local/lib/python2.7/site-packages
5
+ - RVM_RUBY_VERSION=2.0.0-p247 NOEXEC_DISABLE=1 RUBY_VERSION_SPECIFIC='sudo gem install bundler --no-ri --no-rdoc' GIT_AUTHOR_NAME=CocoaPods GIT_AUTHOR_EMAIL=cocoapods@example.com PYTHONPATH=/usr/local/lib/python2.7/site-packages
6
+ before_install:
7
+ - curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem
8
+ - source ~/.rvm/scripts/rvm && rvm use $RVM_RUBY_VERSION
9
+ install: eval $RUBY_VERSION_SPECIFIC && rake bootstrap[use_bundle_dir]
10
+ script: bundle exec rake spec:ci
@@ -0,0 +1,12 @@
1
+ # CocoaPods::Metadata Changelog
2
+
3
+ ## Master
4
+
5
+ ##### Enhancements
6
+
7
+ * Support Settings bundle style plists.
8
+ [Marcelo Fabri](https://github.com/marcelofabri)
9
+
10
+ * Support full Podspec metadata style.
11
+ [Fabio Pelosin](https://github.com/fabiopelosin)
12
+ [Orta Therox](https://github.com/orta)
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'cocoapods'
7
+ gem 'bacon'
8
+ gem 'mocha-on-bacon'
9
+ gem 'mocha', '~> 0.11.4'
10
+ gem 'rake'
11
+ gem 'prettybacon', :git => 'https://github.com/irrationalfab/PrettyBacon.git', :branch => 'master'
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Fabio Pelosin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # CocoaPods Acknowledgements
2
+
3
+ A CocoaPods plugin that generates a plist which includes the installation metadata. It supports generating two styles of dependency information.
4
+
5
+ * **Settings.bundle compatible plist** - This format is supported by a [large amount of pods](https://cocoapods.org/?q=acknow) and works with Apple's Settings.app.
6
+
7
+ * **Full Podspec metadata plist** - This format provides more information to the app allowing for deeper introspection, currently only [CPDAcknowledgements](https://github.com/cocoapods/CPDAcknowledgements) works with this format.
8
+
9
+ ### Installation
10
+
11
+ Install via `gem install cocoapods-acknowledgements` you need to be using at least CocoaPods `0.36` and add `plugin 'cocoapods-acknowledgements'` to your `Podfile`. See below for examples:
12
+
13
+ ### Example usage
14
+
15
+ For showing your own UI inside your application:
16
+
17
+ ``` ruby
18
+ plugin 'cocoapods-acknowledgements'
19
+ ```
20
+
21
+ For embedding a `Settings.bundle` compatible plist
22
+
23
+ ``` ruby
24
+ plugin 'cocoapods-acknowledgements', :settings_bundle => true
25
+ ```
26
+
27
+ With a Settings.bundle compatible plist, offering the chance to run post-processing on the plist ( to add non-CocoaPods dependencies for example )
28
+
29
+ ``` ruby
30
+ plugin 'cocoapods-acknowledgements', :settings_bundle => true , :settings_post_process => Proc.new { |settings_plist_path, umbrella_target|
31
+ puts settings_plist_path
32
+ puts umbrella_target.cocoapods_target_label
33
+ }
34
+ ```
35
+
36
+ The plugin will search through the first two levels of your project to find a `Settings.bundle` file, and add the file to the bundle. If this is not enough for you, we'd love a PR.
@@ -0,0 +1,22 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ task :bootstrap, :use_bundle_dir? do |t, args|
8
+ if args[:use_bundle_dir?]
9
+ sh "bundle install --path ./travis_bundle_dir"
10
+ else
11
+ sh "bundle install"
12
+ end
13
+ end
14
+
15
+ namespace :spec do
16
+ desc "Runs all the specs"
17
+ task :ci do
18
+ sh "bundle exec bacon #{specs('**')}"
19
+ end
20
+ end
21
+
22
+ task :default => "spec:ci"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods_acknowledgements/version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cocoapods-acknowledgements"
8
+ spec.version = CocoaPodsAcknowledgements::VERSION
9
+ spec.authors = ["Fabio Pelosin", "Orta Therox", "Marcelo Fabri"]
10
+ spec.summary = %q{CocoaPods plugin that generates an acknowledgements plist to make it easy to create tools to use in apps.}
11
+ spec.homepage = "https://github.com/CocoaPods/cocoapods-acknowledgements"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "redcarpet", "~> 3.3"
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,98 @@
1
+ module CocoaPodsAcknowledgements
2
+ require 'cocoapods_acknowledgements/plist_generator'
3
+ require 'cocoapods_acknowledgements/settings_plist_generator'
4
+
5
+ def self.save_metadata(metadata, plist_path, project, sandbox, user_target_uuid)
6
+ Xcodeproj.write_plist(metadata, plist_path)
7
+
8
+ # Find a root folder in the users Xcode Project called Pods, or make one
9
+ cocoapods_group = project.main_group["Pods"]
10
+ unless cocoapods_group
11
+ cocoapods_group = project.main_group.new_group("Pods", sandbox.root)
12
+ end
13
+
14
+ # Add the example plist to the found CocoaPods group
15
+ file_ref = cocoapods_group.files.find { |file| file.real_path == plist_path }
16
+ unless file_ref
17
+ file_ref = cocoapods_group.new_file(plist_path)
18
+ end
19
+
20
+ # Ensure that the plist is added to target
21
+ target = project.objects_by_uuid[user_target_uuid]
22
+ unless target.resources_build_phase.files_references.include?(file_ref)
23
+ target.add_resources([file_ref])
24
+ end
25
+
26
+ project.save
27
+
28
+ end
29
+
30
+ # TODO: Code golf this
31
+ def self.settings_bundle_in_project
32
+ Dir.glob("**/*Settings.bundle").first
33
+ end
34
+
35
+ Pod::HooksManager.register('cocoapods-acknowledgements', :post_install) do |context, user_options|
36
+ require 'cocoapods'
37
+
38
+ # Until CocoaPods provides a HashWithIndifferentAccess, normalize the hash keys here.
39
+ # See https://github.com/CocoaPods/CocoaPods/issues/3354
40
+
41
+ user_options.inject({}) do |normalized_hash, (key, value)|
42
+ normalized_hash[key.to_s] = value
43
+ normalized_hash
44
+ end
45
+
46
+ Pod::UI.section 'Adding Acknowledgements' do
47
+
48
+ should_include_settings = user_options["settings_bundle"] != nil
49
+
50
+ sandbox = context.sandbox if defined? context.sandbox
51
+ sandbox ||= Pod::Sandbox.new(context.sandbox_root)
52
+
53
+ context.umbrella_targets.each do |umbrella_target|
54
+ project = Xcodeproj::Project.open(umbrella_target.user_project_path)
55
+
56
+ umbrella_target.user_target_uuids.each do |user_target_uuid|
57
+
58
+ # Generate a plist representing all of the podspecs
59
+ metadata = PlistGenerator.generate(umbrella_target, sandbox)
60
+
61
+ next unless metadata
62
+
63
+ plist_path = sandbox.root + "#{umbrella_target.cocoapods_target_label}-metadata.plist"
64
+ save_metadata(metadata, plist_path, project, sandbox, user_target_uuid)
65
+
66
+ if should_include_settings
67
+ # Generate a plist in Settings format
68
+ settings_metadata = SettingsPlistGenerator.generate(umbrella_target, sandbox)
69
+
70
+ # We need to look for a Settings.bundle
71
+ # and add this to the root of the bundle
72
+
73
+ settings_bundle = settings_bundle_in_project
74
+ if settings_bundle == nil
75
+ Pod::UI.warn "Could not find a Settings.bundle to add the Pod Settings Plist to."
76
+ else
77
+ settings_plist_path = settings_bundle + "/#{umbrella_target.cocoapods_target_label}-settings-metadata.plist"
78
+ FileUtils.cp(plist_path, settings_plist_path)
79
+ Pod::UI.info "Added Pod info to Settings.bundle for target #{umbrella_target.cocoapods_target_label}"
80
+
81
+ # Support a callback for the key :settings_post_process
82
+ if user_options["settings_post_process"]
83
+ user_options["settings_post_process"].call(settings_plist_path, umbrella_target)
84
+ end
85
+
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+ end
97
+
98
+
@@ -0,0 +1,87 @@
1
+ require 'redcarpet'
2
+
3
+ module CocoaPodsAcknowledgements
4
+ class PlistGenerator
5
+ class << self
6
+
7
+ def markdown_parser
8
+ @markdown_parser ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML)
9
+ end
10
+
11
+ def generate(target_description, sandbox)
12
+ root_specs = target_description.specs.map(&:root).uniq
13
+
14
+ return nil if root_specs.empty?
15
+
16
+ specs_metadata = []
17
+ root_specs.each do |spec|
18
+ pod_root = sandbox.pod_dir(spec.name)
19
+ platform = Pod::Platform.new(target_description.platform_name)
20
+ file_accessor = file_accessor(spec, platform, sandbox)
21
+ license_text = license_text(spec, file_accessor)
22
+
23
+ spec_metadata = {
24
+ "name" => spec.name,
25
+ "version" => spec.version,
26
+ "authors" => spec.authors,
27
+ "socialMediaURL" => spec.social_media_url,
28
+ "summary" => spec.summary,
29
+ "description" => parse_markdown(spec.description),
30
+ "licenseType" => spec.license[:type],
31
+ "licenseText" => license_text,
32
+ }
33
+ specs_metadata << spec_metadata
34
+ end
35
+
36
+ metadata = {}
37
+ metadata["specs"] = specs_metadata
38
+ metadata
39
+ end
40
+
41
+ #-----------------------------------------------------------------------#
42
+
43
+ def file_accessor(spec, platform, sandbox)
44
+ pod_root = sandbox.pod_dir(spec.name)
45
+ if pod_root.exist?
46
+ path_list = Pod::Sandbox::PathList.new(pod_root)
47
+ Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
48
+ end
49
+ end
50
+
51
+ # Returns the text of the license for the given spec.
52
+ #
53
+ # @param [Specification] spec
54
+ # the specification for which license is needed.
55
+ #
56
+ # @return [String] The text of the license.
57
+ # @return [Nil] If not license text could be found.
58
+ #
59
+ def license_text(spec, file_accessor)
60
+ return nil unless spec.license
61
+ text = spec.license[:text]
62
+ unless text
63
+ if file_accessor
64
+ if license_file = file_accessor.license
65
+ if license_file.exist?
66
+ text = IO.read(license_file)
67
+ else
68
+ UI.warn "Unable to read the license file `#{license_file }` " \
69
+ "for the spec `#{spec}`"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ text
75
+ end
76
+
77
+ def parse_markdown(text)
78
+ return nil unless text
79
+ markdown_parser.render(text)
80
+ end
81
+
82
+ #-----------------------------------------------------------------------#
83
+
84
+ end
85
+ end
86
+ end
87
+
@@ -0,0 +1,54 @@
1
+ require 'cocoapods_acknowledgements/plist_generator'
2
+
3
+ module CocoaPodsAcknowledgements
4
+ class SettingsPlistGenerator < PlistGenerator
5
+ class << self
6
+
7
+ def generate(target_description, sandbox)
8
+ root_specs = target_description.specs.map(&:root).uniq
9
+
10
+ return nil if root_specs.empty?
11
+
12
+ specs_metadata = [header]
13
+
14
+ root_specs.each do |spec|
15
+ pod_root = sandbox.pod_dir(spec.name)
16
+ platform = Pod::Platform.new(target_description.platform_name)
17
+ file_accessor = file_accessor(spec, platform, sandbox)
18
+ license_text = license_text(spec, file_accessor)
19
+
20
+ spec_metadata = {
21
+ "Title" => spec.name,
22
+ "Type" => "PSGroupSpecifier",
23
+ "FooterText" => license_text
24
+ }
25
+ specs_metadata << spec_metadata
26
+ end
27
+
28
+ specs_metadata << footer
29
+ metadata = {
30
+ "PreferenceSpecifiers" => specs_metadata,
31
+ "Title" => "Acknowledgements",
32
+ "StringsTable" => "Acknowledgements"
33
+ }
34
+ end
35
+
36
+ def header
37
+ header = {
38
+ "FooterText" => "This application makes use of the following third party libraries:",
39
+ "Title" => "Acknowledgements",
40
+ "Type" => "PSGroupSpecifier"
41
+ }
42
+ end
43
+
44
+ def footer
45
+ footer = {
46
+ "FooterText" => "Generated by CocoaPods - http://cocoapods.org",
47
+ "Title" => nil,
48
+ "Type" => "PSGroupSpecifier"
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
54
+
@@ -0,0 +1,3 @@
1
+ module CocoaPodsAcknowledgements
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'cocoapods_acknowledgements'
2
+
@@ -0,0 +1,47 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'cocoapods'
11
+
12
+ require 'cocoapods_plugin'
13
+
14
+ #-----------------------------------------------------------------------------#
15
+
16
+ module Pod
17
+
18
+ # Disable the wrapping so the output is deterministic in the tests.
19
+ #
20
+ UI.disable_wrap = true
21
+
22
+ # Redirects the messages to an internal store.
23
+ #
24
+ module UI
25
+ @output = ''
26
+ @warnings = ''
27
+
28
+ class << self
29
+ attr_accessor :output
30
+ attr_accessor :warnings
31
+
32
+ def puts(message = '')
33
+ @output << "#{message}\n"
34
+ end
35
+
36
+ def warn(message = '', actions = [])
37
+ @warnings << "#{message}\n"
38
+ end
39
+
40
+ def print(message)
41
+ @output << message
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-acknowledgements
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Fabio Pelosin
8
+ - Orta Therox
9
+ - Marcelo Fabri
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-11-19 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: redcarpet
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '3.3'
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.3'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.3'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ description:
58
+ email:
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - cocoapods_acknowledgements.gemspec
71
+ - lib/cocoapods_acknowledgements.rb
72
+ - lib/cocoapods_acknowledgements/plist_generator.rb
73
+ - lib/cocoapods_acknowledgements/settings_plist_generator.rb
74
+ - lib/cocoapods_acknowledgements/version.rb
75
+ - lib/cocoapods_plugin.rb
76
+ - spec/spec_helper.rb
77
+ homepage: https://github.com/CocoaPods/cocoapods-acknowledgements
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.2.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: CocoaPods plugin that generates an acknowledgements plist to make it easy
101
+ to create tools to use in apps.
102
+ test_files:
103
+ - spec/spec_helper.rb
104
+ has_rdoc: