cocoapods-whitelist 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cf23a30117897a6467e11b44087ad09a8bdbcd51
4
+ data.tar.gz: 6183ef966ab86e5aaab202bdd354fd8b566a3329
5
+ SHA512:
6
+ metadata.gz: 843846f1b260439b6676a8619c1e6eb98e530f1114252c847d021617f477527c2ff1a4c0a3b92c8d7106766d7d217004d6e16ba64587f21dd3fac504546c5e51
7
+ data.tar.gz: 20013be046ad6c51ba4febb4361c7eb2a808ff6db18b399361997e195f5f252ea682cde5530ab5ba3ef2b9990b51866a6f83d60bfad4b21edb1e206acbfeb8b7
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-whitelist.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+ gem 'mocha'
9
+ gem 'bacon'
10
+ gem 'mocha-on-bacon'
11
+ gem 'prettybacon'
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-whitelist (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (2.3.4)
10
+ activesupport (4.2.7.1)
11
+ i18n (~> 0.7)
12
+ json (~> 1.7, >= 1.7.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
+ tzinfo (~> 1.1)
16
+ bacon (1.2.0)
17
+ claide (1.0.1)
18
+ cocoapods (1.1.1)
19
+ activesupport (>= 4.0.2, < 5)
20
+ claide (>= 1.0.1, < 2.0)
21
+ cocoapods-core (= 1.1.1)
22
+ cocoapods-deintegrate (>= 1.0.1, < 2.0)
23
+ cocoapods-downloader (>= 1.1.2, < 2.0)
24
+ cocoapods-plugins (>= 1.0.0, < 2.0)
25
+ cocoapods-search (>= 1.0.0, < 2.0)
26
+ cocoapods-stats (>= 1.0.0, < 2.0)
27
+ cocoapods-trunk (>= 1.1.1, < 2.0)
28
+ cocoapods-try (>= 1.1.0, < 2.0)
29
+ colored (~> 1.2)
30
+ escape (~> 0.0.4)
31
+ fourflusher (~> 2.0.1)
32
+ gh_inspector (~> 1.0)
33
+ molinillo (~> 0.5.1)
34
+ nap (~> 1.0)
35
+ xcodeproj (>= 1.3.3, < 2.0)
36
+ cocoapods-core (1.1.1)
37
+ activesupport (>= 4.0.2, < 5)
38
+ fuzzy_match (~> 2.0.4)
39
+ nap (~> 1.0)
40
+ cocoapods-deintegrate (1.0.1)
41
+ cocoapods-downloader (1.1.3)
42
+ cocoapods-plugins (1.0.0)
43
+ nap
44
+ cocoapods-search (1.0.0)
45
+ cocoapods-stats (1.0.0)
46
+ cocoapods-trunk (1.1.2)
47
+ nap (>= 0.8, < 2.0)
48
+ netrc (= 0.7.8)
49
+ cocoapods-try (1.1.0)
50
+ colored (1.2)
51
+ escape (0.0.4)
52
+ fourflusher (2.0.1)
53
+ fuzzy_match (2.0.4)
54
+ gh_inspector (1.0.3)
55
+ i18n (0.7.0)
56
+ json (1.8.6)
57
+ metaclass (0.0.4)
58
+ minitest (5.10.1)
59
+ mocha (1.2.1)
60
+ metaclass (~> 0.0.1)
61
+ mocha-on-bacon (0.2.3)
62
+ mocha (>= 0.13.0)
63
+ molinillo (0.5.5)
64
+ nanaimo (0.2.3)
65
+ nap (1.1.0)
66
+ netrc (0.7.8)
67
+ prettybacon (0.0.2)
68
+ bacon (~> 1.2)
69
+ rake (12.0.0)
70
+ thread_safe (0.3.5)
71
+ tzinfo (1.2.2)
72
+ thread_safe (~> 0.1)
73
+ xcodeproj (1.4.2)
74
+ CFPropertyList (~> 2.3.3)
75
+ activesupport (>= 3)
76
+ claide (>= 1.0.1, < 2.0)
77
+ colored (~> 1.2)
78
+ nanaimo (~> 0.2.3)
79
+
80
+ PLATFORMS
81
+ ruby
82
+
83
+ DEPENDENCIES
84
+ bacon
85
+ bundler (~> 1.3)
86
+ cocoapods
87
+ cocoapods-whitelist!
88
+ mocha
89
+ mocha-on-bacon
90
+ prettybacon
91
+ rake
92
+
93
+ BUNDLED WITH
94
+ 1.13.6
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Nicolas Andres Suarez <nicolasandres.suarez@mercadolibre.com>
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.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cocoapods-whitelist
2
+
3
+ A description of cocoapods-whitelist.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-whitelist
8
+
9
+ ## Usage
10
+
11
+ $ pod spec whitelist POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-whitelist/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-whitelist'
8
+ spec.version = CocoapodsWhitelist::VERSION
9
+ spec.authors = ['Mobile Team']
10
+ spec.email = ['mobile@mercadolibre.com']
11
+ spec.description = %q{A short description of cocoapods-whitelist.}
12
+ spec.summary = %q{A longer description of cocoapods-whitelist.}
13
+ spec.homepage = 'https://github.com/mercadolibre/mobile-cocoapods_whitelist'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake', '~> 12.0'
23
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-whitelist/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-whitelist/command/whitelist'
@@ -0,0 +1,139 @@
1
+ require 'open-uri'
2
+
3
+ DEFAULT_WHITELIST_URL = "https://raw.githubusercontent.com/mercadolibre/mobile-dependencies_whitelist/master/ios-whitelist.json"
4
+ ERROR_MESSAGE = "Please check your dependencies"
5
+
6
+ class AllowedDependency
7
+ attr_accessor :name
8
+ attr_accessor :version
9
+ def initialize(name, version)
10
+ @name = name
11
+ @version = version
12
+ end
13
+ end
14
+
15
+ module Pod
16
+ class Command
17
+ class Whitelist < Command
18
+ self.summary = 'Short description of cocoapods-whitelist.'
19
+ self.description = <<-DESC
20
+ Longer description of cocoapods-whitelist.
21
+ DESC
22
+
23
+ self.arguments = [ CLAide::Argument.new('config', false),
24
+ CLAide::Argument.new('podspec', false),
25
+ CLAide::Argument.new('fail-on-error', false) ]
26
+
27
+ def self.options
28
+ [ ['--config=CONFIG', 'Config file or URL for the blacklist'],
29
+ ['--podspec=PODSPEC', 'Podspec file to be lint'],
30
+ ['--fail-on-error', 'Raise an exception in case of error']
31
+ ].concat(super)
32
+ end
33
+
34
+ def initialize(argv)
35
+ @whitelist_url = argv ? argv.option('config', DEFAULT_WHITELIST_URL) : DEFAULT_WHITELIST_URL
36
+ @pospec_path = argv ? argv.option('podspec') : nil
37
+ @fail_on_error = argv ? argv.flag?('fail-on-error') : false
38
+ @failure = false
39
+ super
40
+ end
41
+
42
+ def validate!
43
+ help! "A whitelist file or URL is needed." unless @whitelist_url
44
+ end
45
+
46
+ def run
47
+ whitelist = get_whitelist
48
+ specifications = get_podspec_specifications
49
+ specifications.map do |specification|
50
+ validate_dependencies(JSON.parse(specification.to_json), whitelist)
51
+ end
52
+ show_error_message
53
+ end
54
+
55
+ def show_error_message
56
+ return unless @failure
57
+ if @fail_on_error
58
+ raise Informative.new(ERROR_MESSAGE)
59
+ else
60
+ UI.puts ERROR_MESSAGE.red
61
+ end
62
+ end
63
+
64
+ # Checks the dependencies the project contains are in the whitelist
65
+ def validate_dependencies(podspec, whitelist, parentName = nil)
66
+ pod_name = parentName ? "#{parentName}/#{podspec['name']}" : podspec['name']
67
+ puts "Verifying dependencies in #{pod_name}"
68
+
69
+ dependencies = podspec["dependencies"] ? podspec["dependencies"] : []
70
+ not_allowed = []
71
+
72
+ dependencies.each do |name, versions|
73
+ # Skip subspec dependency
74
+ next if parentName && name.start_with?("#{parentName}/")
75
+
76
+ allowedDependency = whitelist.select { |item|
77
+ name == item.name && (versions.empty? || !item.version || versions.grep(/#{item.version}/).any?)
78
+ }
79
+
80
+ if allowedDependency.empty?
81
+ not_allowed.push("#{name} (#{versions.join(", ")})")
82
+ next
83
+ end
84
+ end
85
+
86
+ if not_allowed.any?
87
+ UI.puts " Error: Found dependencies not allowed:".red
88
+ not_allowed.each {|dependency| UI.puts " - #{dependency}".red}
89
+ @failure = true
90
+ else
91
+ UI.puts " OK".green
92
+ end
93
+
94
+ # Validate subspecs dependencies
95
+ if podspec["subspecs"]
96
+ podspec["subspecs"].each do |subspec|
97
+ validate_dependencies(subspec, whitelist, pod_name)
98
+ end
99
+ end
100
+ end
101
+
102
+ def get_whitelist
103
+ begin
104
+ open(@whitelist_url) { |io|
105
+ buffer = io.read
106
+ parse_whitelist(buffer)
107
+ }
108
+ rescue OpenURI::HTTPError => e
109
+ status = e.io.status.join(' ')
110
+ raise "Failed to fetch whitelist from '#{@whitelist_url}'.\n Error: #{status}"
111
+ end
112
+ end
113
+
114
+ def parse_whitelist(raw_whitelist)
115
+ json = JSON.parse(raw_whitelist)
116
+ return json["whitelist"].map { |dependencyJson|
117
+ AllowedDependency.new(dependencyJson["name"], dependencyJson["version"])
118
+ }
119
+ end
120
+
121
+ def get_podspec_specifications
122
+ if @pospec_path
123
+ return [Pod::Specification.from_file(@pospec_path)]
124
+ end
125
+
126
+ # Search .podspec in current directory
127
+ podspecs = Dir.glob("./*.podspec")
128
+
129
+ if podspecs.count == 0
130
+ # Search .podspec in parent directory.
131
+ # Some projects has Podfile into a subdirectory ("Example"), and run "pod install" from there.
132
+ podspecs = Dir.glob("../*.podspec")
133
+ end
134
+
135
+ return podspecs.map { |path| Pod::Specification.from_file(path) }
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsWhitelist
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'cocoapods-whitelist/command'
2
+
3
+ module Whitelist
4
+ Pod::HooksManager.register('cocoapods-whitelist', :pre_install) do |context, options|
5
+ argv = CLAide::ARGV.new(options)
6
+ puts argv
7
+ Pod::Command::Whitelist.new(argv).run
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+
2
+ Pod::Spec.new do |s|
3
+ s.name = "MLSearch"
4
+ s.version = "3.17.0"
5
+ s.summary = "Componente de search"
6
+ s.homepage = "http://www.mercadolibre.com.ar"
7
+ s.license = "none"
8
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
9
+ s.platform = :ios, "7.0"
10
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
11
+ s.requires_arc = true
12
+ s.dependency 'MLRecommendations', '~>1.0.0'
13
+
14
+ end
@@ -0,0 +1,13 @@
1
+ Pod::Spec.new do |s|
2
+ s.name = "MLSearch"
3
+ s.version = "3.17.0"
4
+ s.summary = "Componente de search"
5
+ s.homepage = "http://www.mercadolibre.com.ar"
6
+ s.license = "none"
7
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
8
+ s.platform = :ios, "7.0"
9
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
10
+ s.requires_arc = true
11
+ s.dependency 'MeliSDK', '~>5.1'
12
+
13
+ end
@@ -0,0 +1,14 @@
1
+
2
+ Pod::Spec.new do |s|
3
+ s.name = "MLSearch"
4
+ s.version = "3.17.0"
5
+ s.summary = "Componente de search"
6
+ s.homepage = "http://www.mercadolibre.com.ar"
7
+ s.license = "none"
8
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
9
+ s.platform = :ios, "7.0"
10
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
11
+ s.requires_arc = true
12
+ s.dependency 'AFNetworking'
13
+
14
+ end
@@ -0,0 +1,9 @@
1
+ {
2
+ "whitelist": [{
3
+ "name": "MeliSDK",
4
+ "version": "^~>5.[0-9]+$"
5
+ }, {
6
+ "name": "MLRecommendations",
7
+ "version": null
8
+ }]
9
+ }
@@ -0,0 +1,19 @@
1
+
2
+ Pod::Spec.new do |s|
3
+ s.name = "MLSearch"
4
+ s.version = "3.17.0"
5
+ s.summary = "Componente de search"
6
+ s.homepage = "http://www.mercadolibre.com.ar"
7
+ s.license = "none"
8
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
9
+ s.platform = :ios, "7.0"
10
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
11
+ s.requires_arc = true
12
+
13
+ s.subspec "Suggestion" do |suggestion|
14
+ suggestion.resource = "LibraryComponents/Suggestions/assets/*.*", "LibraryComponents/Suggestions/classes/*.xib"
15
+ suggestion.source_files = "LibraryComponents/Suggestions/classes/*.{h,m,c}"
16
+ suggestion.dependency "MeliSDK", "~>5.0"
17
+ end
18
+
19
+ end
@@ -0,0 +1,14 @@
1
+
2
+ Pod::Spec.new do |s|
3
+ s.name = "MLSearch"
4
+ s.version = "3.17.0"
5
+ s.summary = "Componente de search"
6
+ s.homepage = "http://www.mercadolibre.com.ar"
7
+ s.license = "none"
8
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
9
+ s.platform = :ios, "7.0"
10
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
11
+ s.requires_arc = true
12
+ s.dependency 'MeliSDK', '5.4.1'
13
+
14
+ end
@@ -0,0 +1,20 @@
1
+
2
+ Pod::Spec.new do |s|
3
+ s.name = "MLSearch"
4
+ s.version = "3.17.0"
5
+ s.summary = "Componente de search"
6
+ s.homepage = "http://www.mercadolibre.com.ar"
7
+ s.license = "none"
8
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
9
+ s.platform = :ios, "7.0"
10
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
11
+ s.requires_arc = true
12
+ s.dependency 'MeliSDK'
13
+
14
+ s.subspec "Suggestion" do |suggestion|
15
+ suggestion.resource = "LibraryComponents/Suggestions/assets/*.*", "LibraryComponents/Suggestions/classes/*.xib"
16
+ suggestion.source_files = "LibraryComponents/Suggestions/classes/*.{h,m,c}"
17
+ suggestion.dependency "AFNetworking", "~>3.0"
18
+ end
19
+
20
+ end
@@ -0,0 +1,14 @@
1
+
2
+ Pod::Spec.new do |s|
3
+ s.name = "MLSearch"
4
+ s.version = "3.17.0"
5
+ s.summary = "Componente de search"
6
+ s.homepage = "http://www.mercadolibre.com.ar"
7
+ s.license = "none"
8
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
9
+ s.platform = :ios, "7.0"
10
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
11
+ s.requires_arc = true
12
+ s.dependency 'MeliSDK', '>4.0', '<5.0'
13
+
14
+ end
@@ -0,0 +1,12 @@
1
+ Pod::Spec.new do |s|
2
+ s.name = "MLSearch"
3
+ s.version = "3.17.0"
4
+ s.summary = "Componente de search"
5
+ s.homepage = "http://www.mercadolibre.com.ar"
6
+ s.license = "none"
7
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
8
+ s.platform = :ios, "7.0"
9
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
10
+ s.requires_arc = true
11
+
12
+ end
@@ -0,0 +1,14 @@
1
+
2
+ Pod::Spec.new do |s|
3
+ s.name = "MLSearch"
4
+ s.version = "3.17.0"
5
+ s.summary = "Componente de search"
6
+ s.homepage = "http://www.mercadolibre.com.ar"
7
+ s.license = "none"
8
+ s.author = { "Mobile team" => "mobile@mercadolibre.com" }
9
+ s.platform = :ios, "7.0"
10
+ s.source = { :git => "git@github.com:mercadolibre/search-ios.git", :tag => s.version.to_s }
11
+ s.requires_arc = true
12
+ s.dependency 'MeliSDK'
13
+
14
+ end
@@ -0,0 +1,50 @@
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 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
@@ -0,0 +1,100 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ WHITELIST_FILE = './spec/mocks/whitelist.json'
4
+
5
+ module Pod
6
+ describe Command::Whitelist do
7
+ describe 'general' do
8
+ it 'registers itself' do
9
+ Command.parse(%w{ whitelist }).should.be.instance_of Command::Whitelist
10
+ end
11
+
12
+ it 'parse whitelist json' do
13
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}"])
14
+ dependencies = command.get_whitelist
15
+ dependencies.size.should.equal 2
16
+ end
17
+ end
18
+
19
+ describe 'validations' do
20
+ it 'dependency without version should be valid' do
21
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('MeliSDK')
22
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
23
+ specification = Pod::Specification.from_file('./spec/mocks/without_version.podspec')
24
+ command.expects(:get_podspec_specifications).returns([specification])
25
+ lambda { command.run }.should.not.raise
26
+ end
27
+
28
+ it 'dependency with major version fixed should be valid' do
29
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('MeliSDK', '~>5.0')
30
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
31
+ specification = Pod::Specification.from_file('./spec/mocks/major_version_fixed.podspec')
32
+ command.expects(:get_podspec_specifications).returns([specification])
33
+ lambda { command.run }.should.not.raise
34
+ end
35
+
36
+ it 'not allowed dependency should not be valid' do
37
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('AFNetworking')
38
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
39
+ specification = Pod::Specification.from_file('./spec/mocks/not_allowed.podspec')
40
+ command.expects(:get_podspec_specifications).returns([specification])
41
+ lambda { command.run }.should.raise Informative
42
+ end
43
+
44
+ it 'dependency with not allowed version should not be valid' do
45
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('AFNetworking')
46
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
47
+ specification = Pod::Specification.from_file('./spec/mocks/with_fixed_version.podspec')
48
+ command.expects(:get_podspec_specifications).returns([specification])
49
+ lambda { command.run }.should.raise Informative
50
+ end
51
+
52
+ it 'dependency with two versions rquieremnt should not be valid' do
53
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('AFNetworking')
54
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
55
+ specification = Pod::Specification.from_file('./spec/mocks/with_two_requirement.podspec')
56
+ command.expects(:get_podspec_specifications).returns([specification])
57
+ lambda { command.run }.should.raise Informative
58
+ end
59
+
60
+ it 'dependency not allowed in subspec should not be valid' do
61
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('AFNetworking')
62
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
63
+ specification = Pod::Specification.from_file('./spec/mocks/with_not_allowed_in_subspec.podspec')
64
+ command.expects(:get_podspec_specifications).returns([specification])
65
+ lambda { command.run }.should.raise Informative
66
+ end
67
+
68
+ it 'podspec without dependencies should be valid' do
69
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('AFNetworking')
70
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
71
+ specification = Pod::Specification.from_file('./spec/mocks/without_dependencies.podspec')
72
+ command.expects(:get_podspec_specifications).returns([specification])
73
+ lambda { command.run }.should.not.raise
74
+ end
75
+
76
+ it 'podspec with allowed dependencies in subspec should be valid' do
77
+ # Whitelist: ('MeliSDK', '~>5.*') | Subspec: ('MeliSDK')
78
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
79
+ specification = Pod::Specification.from_file('./spec/mocks/with_allowed_in_subspec.podspec')
80
+ command.expects(:get_podspec_specifications).returns([specification])
81
+ lambda { command.run }.should.not.raise
82
+ end
83
+
84
+ it 'podspec with dependency not restricted by version should be valid' do
85
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('MLRecommendations', '~>1.0.0')
86
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--fail-on-error"])
87
+ specification = Pod::Specification.from_file('./spec/mocks/free_version.podspec')
88
+ command.expects(:get_podspec_specifications).returns([specification])
89
+ lambda { command.run }.should.not.raise
90
+ end
91
+
92
+ it 'not allowed dependency should not raise exception if --fail-on-error is not present' do
93
+ # Whitelist: ('MeliSDK', '~>5.*') | Podspec: ('AFNetworking')
94
+ command = Command.parse(['whitelist', "--config=#{WHITELIST_FILE}", "--podspec=./spec/mocks/not_allowed.podspec"])
95
+ lambda { command.run }.should.not.raise
96
+ end
97
+
98
+ end
99
+ end
100
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-whitelist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mobile Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ description: A short description of cocoapods-whitelist.
42
+ email:
43
+ - mobile@mercadolibre.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - cocoapods-whitelist.gemspec
54
+ - lib/cocoapods-whitelist.rb
55
+ - lib/cocoapods-whitelist/command.rb
56
+ - lib/cocoapods-whitelist/command/whitelist.rb
57
+ - lib/cocoapods-whitelist/gem_version.rb
58
+ - lib/cocoapods_plugin.rb
59
+ - spec/mocks/free_version.podspec
60
+ - spec/mocks/major_version_fixed.podspec
61
+ - spec/mocks/not_allowed.podspec
62
+ - spec/mocks/whitelist.json
63
+ - spec/mocks/with_allowed_in_subspec.podspec
64
+ - spec/mocks/with_fixed_version.podspec
65
+ - spec/mocks/with_not_allowed_in_subspec.podspec
66
+ - spec/mocks/with_two_requirement.podspec
67
+ - spec/mocks/without_dependencies.podspec
68
+ - spec/mocks/without_version.podspec
69
+ - spec/spec_helper.rb
70
+ - spec/whitelist_spec.rb
71
+ homepage: https://github.com/mercadolibre/mobile-cocoapods_whitelist
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.8
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: A longer description of cocoapods-whitelist.
95
+ test_files:
96
+ - spec/mocks/free_version.podspec
97
+ - spec/mocks/major_version_fixed.podspec
98
+ - spec/mocks/not_allowed.podspec
99
+ - spec/mocks/whitelist.json
100
+ - spec/mocks/with_allowed_in_subspec.podspec
101
+ - spec/mocks/with_fixed_version.podspec
102
+ - spec/mocks/with_not_allowed_in_subspec.podspec
103
+ - spec/mocks/with_two_requirement.podspec
104
+ - spec/mocks/without_dependencies.podspec
105
+ - spec/mocks/without_version.podspec
106
+ - spec/spec_helper.rb
107
+ - spec/whitelist_spec.rb