cocoapods-thumbs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be1911e684ecd560aa333fb0088a7ba60e9bf0f9
4
+ data.tar.gz: f880f0ccd9565cf314544d3f907eabe5217dd011
5
+ SHA512:
6
+ metadata.gz: 06413867596a6e8902352912a99e41f08f9e738bef3dfb7b4809ca20997962daf498fceb8d101ec34aef0391314bfb24ac1902e18db37f35282643ac6cbcecb3
7
+ data.tar.gz: e23f58d0431ef6b78bc217f532a08296f3b419036ca005b2901cccc949052be85a96a4e3eb22ad0c9b5c27cbcc62cb0111d95df64d03c1da5c616a49b9330ae0
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/.travis.yml ADDED
@@ -0,0 +1,27 @@
1
+ # Sets Travis to run the Ruby specs on OS X machines to be as close as possible
2
+ # to the user environment.
3
+ #
4
+ language: objective-c
5
+
6
+ addons:
7
+ code_climate:
8
+ repo_token: ac16a75350b3a1f800cda5b913dabe4157fe5fce82bde75c62c9c5fb4dd8df27
9
+
10
+ env:
11
+ - RVM_RUBY_VERSION=system
12
+
13
+ before_install:
14
+ - export LANG=en_US.UTF-8
15
+ - curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem
16
+ - source ~/.rvm/scripts/rvm
17
+ - if [[ $RVM_RUBY_VERSION != 'system' ]]; then rvm install $RVM_RUBY_VERSION; fi
18
+ - rvm use $RVM_RUBY_VERSION
19
+ - if [[ $RVM_RUBY_VERSION == 'system' ]]; then sudo gem install bundler --no-ri --no-rdoc; else gem install bundler --no-ri --no-rdoc; fi
20
+
21
+
22
+ install:
23
+ - sudo bundle install --without=documentation
24
+
25
+ script:
26
+ - bundle exec pod setup --silent
27
+ - bundle exec rake specs
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-thumbs.gemspec
4
+ gemspec
5
+
6
+ gem 'json', '1.7.7'
7
+
8
+ group :development do
9
+ gem 'cocoapods'
10
+ gem 'bacon'
11
+ gem 'mocha'
12
+ gem 'mocha-on-bacon'
13
+ gem 'prettybacon'
14
+ gem 'rest'
15
+
16
+ if RUBY_VERSION >= '1.9.3'
17
+ gem "codeclimate-test-reporter", group: :test, require: nil
18
+ end
19
+
20
+ end
21
+
data/Gemfile.lock ADDED
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-thumbs (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.2.1)
10
+ i18n (~> 0.7)
11
+ json (~> 1.7, >= 1.7.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ bacon (1.2.0)
16
+ claide (0.8.1)
17
+ cocoapods (0.37.1)
18
+ activesupport (>= 3.2.15)
19
+ claide (~> 0.8.1)
20
+ cocoapods-core (= 0.37.1)
21
+ cocoapods-downloader (~> 0.9.0)
22
+ cocoapods-plugins (~> 0.4.2)
23
+ cocoapods-trunk (~> 0.6.0)
24
+ cocoapods-try (~> 0.4.4)
25
+ colored (~> 1.2)
26
+ escape (~> 0.0.4)
27
+ molinillo (~> 0.2.3)
28
+ nap (~> 0.8)
29
+ xcodeproj (~> 0.24.1)
30
+ cocoapods-core (0.37.1)
31
+ activesupport (>= 3.2.15)
32
+ fuzzy_match (~> 2.0.4)
33
+ nap (~> 0.8.0)
34
+ cocoapods-downloader (0.9.0)
35
+ cocoapods-plugins (0.4.2)
36
+ nap
37
+ cocoapods-trunk (0.6.0)
38
+ nap (>= 0.8)
39
+ netrc (= 0.7.8)
40
+ cocoapods-try (0.4.4)
41
+ codeclimate-test-reporter (0.4.7)
42
+ simplecov (>= 0.7.1, < 1.0.0)
43
+ colored (1.2)
44
+ docile (1.1.5)
45
+ escape (0.0.4)
46
+ fuzzy_match (2.0.4)
47
+ i18n (0.7.0)
48
+ json (1.7.7)
49
+ metaclass (0.0.4)
50
+ minitest (5.6.1)
51
+ mocha (1.1.0)
52
+ metaclass (~> 0.0.1)
53
+ mocha-on-bacon (0.2.2)
54
+ mocha (>= 0.13.0)
55
+ molinillo (0.2.3)
56
+ multi_json (1.11.0)
57
+ nap (0.8.0)
58
+ net-http-persistent (2.9.4)
59
+ netrc (0.7.8)
60
+ prettybacon (0.0.2)
61
+ bacon (~> 1.2)
62
+ rake (10.4.2)
63
+ rest (3.0.6)
64
+ net-http-persistent (>= 2.9.1)
65
+ netrc
66
+ simplecov (0.9.2)
67
+ docile (~> 1.1.0)
68
+ multi_json (~> 1.0)
69
+ simplecov-html (~> 0.9.0)
70
+ simplecov-html (0.9.0)
71
+ thread_safe (0.3.5)
72
+ tzinfo (1.2.2)
73
+ thread_safe (~> 0.1)
74
+ xcodeproj (0.24.1)
75
+ activesupport (>= 3)
76
+ colored (~> 1.2)
77
+
78
+ PLATFORMS
79
+ ruby
80
+
81
+ DEPENDENCIES
82
+ bacon
83
+ bundler (~> 1.3)
84
+ cocoapods
85
+ cocoapods-thumbs!
86
+ codeclimate-test-reporter
87
+ json (= 1.7.7)
88
+ mocha
89
+ mocha-on-bacon
90
+ prettybacon
91
+ rake
92
+ rest
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Quadion Technologies
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,44 @@
1
+ # Cocoapods thumbs
2
+
3
+ [![Build Status](http://img.shields.io/travis/quadion/cocoapods-thumbs/master.svg?style=flat)](https://travis-ci.org/quadion/cocoapods-thumbs)
4
+ [![Coverage](https://img.shields.io/codeclimate/coverage/github/quadion/cocoapods-thumbs.svg?style=flat)](https://codeclimate.com/github/quadion/cocoapods-thumbs)
5
+ [![Code Climate](https://img.shields.io/codeclimate/github/quadion/cocoapods-thumbs.svg?style=flat)](https://codeclimate.com/github/quadion/cocoapods-thumbs)
6
+
7
+ cocoapods-thumbs is a simple implementation of a graylist (whitelist + blacklist) for Podspecs.
8
+
9
+ When run, cocoapods will check either the full Podfile or a single Podspec against votes stored in a server
10
+ and report them back to the user.
11
+
12
+ The server needs only to return a JSON (with a syntax similar to the one available at https://github.com/quadion/thumbs/blob/master/list.json).
13
+
14
+ While more elaborate servers providing means for users to vote with a UI can be created, using a GitHub repository with a single JSON file and voting through Pull Requests could suffice in most cases (this is what we do, our repo is https://github.com/quadion/thumbs).
15
+
16
+ ## Installation
17
+
18
+ $ gem install cocoapods-thumbs
19
+
20
+ ## Usage
21
+
22
+ ### Setting the server
23
+
24
+ Set the server URL by calling:
25
+
26
+ $ pod thumbs server URL
27
+
28
+ ### Checking a full Podfile
29
+
30
+ On the same directory your Podfile is, run:
31
+
32
+ $ pod thumbs
33
+
34
+ ### Checking a single Podspec
35
+
36
+ To check a single Podspec run:
37
+
38
+ $ pod thumbs NAME REQUIREMENT
39
+
40
+ Where VERSION is a version requirement with the same supported syntax as in a Podfile.
41
+
42
+ By default, this will use a platform os iOS 8.3. If you want to override the platform and version you can add:
43
+
44
+ $ pod thumbs NAME REQUIREMENT --platform=osx --version=10.10
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,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-thumbs/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cocoapods-thumbs"
8
+ spec.version = CocoapodsThumbs::VERSION
9
+ spec.authors = ["Pablo Bendersky"]
10
+ spec.summary = %q{CocoaPods plugin which allows to see peer votes of a Podfile or single Podspec.}
11
+ spec.homepage = "https://github.com/quadion/cocoapods-thumbs"
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_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake"
21
+ end
@@ -0,0 +1,29 @@
1
+ module Pod
2
+ class Command
3
+ class Thumbs
4
+ class Server < Thumbs
5
+ self.summary = 'Configures the thumbs server URL.'
6
+ self.arguments = [
7
+ CLAide::Argument.new('URL', true),
8
+ ]
9
+
10
+ def initialize(argv)
11
+ @url = argv.shift_argument
12
+ super
13
+ end
14
+
15
+ def validate!
16
+ help! 'Please specify a server URL.' unless @url
17
+ end
18
+
19
+ def run
20
+ Pod::Thumbs::Configuration.set_url(@url)
21
+
22
+ UI.title("Server configured") do
23
+ UI.labeled 'URL', @url
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,131 @@
1
+ require 'yaml'
2
+ require 'rest'
3
+
4
+ require 'cocoapods-thumbs/voted_dependency'
5
+ require 'cocoapods-thumbs/votes_list'
6
+ require 'cocoapods-thumbs/dependency_vote'
7
+ require 'cocoapods-thumbs/user_interface'
8
+ require 'cocoapods-thumbs/configuration'
9
+
10
+ module Pod
11
+ class Command
12
+
13
+ class Thumbs < Command
14
+ self.summary = "Use cocoapods-thumbs to upvote or downvote Pods based on past experiences."
15
+
16
+ self.description = <<-DESC
17
+ Use cocoapods-thumbs to upvote or downvote Pods based on past experiences.
18
+ DESC
19
+
20
+ self.arguments = [
21
+ CLAide::Argument.new('NAME', false),
22
+ CLAide::Argument.new('REQUIREMENT', false),
23
+ ]
24
+
25
+ # @return [Pathname]
26
+ #
27
+ THUMBS_TMP_DIR = Pathname.new('/tmp/CocoaPods/Thumbs')
28
+
29
+ DEFAULT_PLATFORM_VERSIONS = {
30
+ :ios => '8.3',
31
+ :osx => '10.10'
32
+ }
33
+
34
+ require 'cocoapods-thumbs/command/thumbs/server'
35
+
36
+ attr_accessor :name, :requirement, :platform, :platform_version
37
+
38
+ def initialize(argv)
39
+ @comments = argv.flag?('comments')
40
+ @platform = argv.option('platform', 'ios').to_sym
41
+ @platform_version = argv.option('version', DEFAULT_PLATFORM_VERSIONS[@platform])
42
+ @name, @requirement = argv.shift_argument, argv.shift_argument
43
+ @requirement ||= Pod::Requirement.default.to_s
44
+ super
45
+ end
46
+
47
+ def self.options
48
+ [
49
+ ['--comments', 'Display user comments alongside votes.'],
50
+ ['--platform', 'When specifying a Podname the platform to use for calculating dependencies. Valid values: ios / osx. Defaults to ios.'],
51
+ ['--version', 'When specifying a platform, use this option to set a version different than the default (iOS 8.3 and OS X 10.10)']
52
+ ].concat(super)
53
+ end
54
+
55
+ def validate!
56
+ super
57
+ verify_config_exists!
58
+ verify_podfile_exists! if @name.nil?
59
+ verify_valid_platform! unless @name.nil?
60
+ end
61
+
62
+ def run
63
+ @configuration = Pod::Thumbs::Configuration.load
64
+ @rest = Rest::Client.new
65
+ @votes_list = Pod::Thumbs::VotesList.new(@rest.get(@configuration[:url]).body)
66
+
67
+ configure_sandbox_and_podfile
68
+
69
+ sandbox = @sandbox
70
+ podfile = @podfile
71
+ analyzer = Installer::Analyzer.new(
72
+ sandbox,
73
+ podfile,
74
+ nil
75
+ )
76
+
77
+ specs = analyzer.analyze(false).specs_by_target.values.flatten(1)
78
+
79
+ specs.each do |spec|
80
+ voted_dependencies = @votes_list.find(spec.name, spec.version)
81
+ if ! voted_dependencies.empty? then
82
+ UI.section "#{spec.name} #{spec.version}" do
83
+ voted_dependencies.each do |voted_dependency|
84
+ UI.marked_labeled "", voted_dependency.dependency.requirement, voted_dependency.votes_summary_string
85
+ if @comments then
86
+ UI.indented_block do
87
+ voted_dependency.votes.select {|v| v.comment != nil }.each do |vote|
88
+ UI.marked_labeled vote.type_string, vote.voter, vote.comment, 15
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ private
99
+
100
+ def configure_sandbox_and_podfile
101
+ if @name then
102
+ parent = self
103
+ config.integrate_targets = false
104
+ @podfile = Pod::Podfile.new do |pod|
105
+ pod.pod parent.name, parent.requirement
106
+ pod.xcodeproj 'Thumbs.xcodeproj'
107
+ pod.platform parent.platform, parent.platform_version
108
+ end
109
+
110
+ @sandbox = Pod::Sandbox.new(THUMBS_TMP_DIR)
111
+ else
112
+ @podfile = config.podfile
113
+ @sandbox = config.sandbox
114
+ end
115
+ end
116
+
117
+ def verify_config_exists!
118
+ unless Pod::Thumbs::Configuration.exists?
119
+ raise Informative, "No cocoapods-thumb configuration file found on your home directory. Run `pod thumbs server'."
120
+ end
121
+ end
122
+
123
+ def verify_valid_platform!
124
+ if ! [:ios, :osx].include? @platform
125
+ raise Informative, 'platform must be either ios or osx'
126
+ end
127
+ end
128
+
129
+ end
130
+ end
131
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-thumbs/command/thumbs.rb'
@@ -0,0 +1,32 @@
1
+ module Pod
2
+ module Thumbs
3
+
4
+ class Configuration
5
+
6
+ def self.config_file_path
7
+ File.expand_path('~/.cocoapods-thumbs.yaml')
8
+ end
9
+
10
+ def self.exists?
11
+ begin
12
+ YAML::load(IO.read(config_file_path))
13
+ true
14
+ rescue
15
+ false
16
+ end
17
+ end
18
+
19
+ def self.load
20
+ YAML.load_file(config_file_path)
21
+ end
22
+
23
+ def self.set_url(url)
24
+ config = { url: url }
25
+
26
+ File.open(config_file_path, 'w') { |f| f.write config.to_yaml }
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ module Pod
2
+
3
+ module Thumbs
4
+
5
+ class DependencyVote
6
+
7
+ attr_accessor :type
8
+ attr_accessor :voter
9
+ attr_accessor :comment
10
+
11
+ def initialize(options = {})
12
+ self.type = options[:type]
13
+ self.voter = options[:voter]
14
+ self.comment = options[:comment]
15
+ end
16
+
17
+ def type=(type)
18
+ if type.is_a? String then
19
+ @type = type.to_sym
20
+ else
21
+ @type = type
22
+ end
23
+ end
24
+
25
+ def type_string
26
+ @type == :up ? "+".green : "-".red
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsThumbs
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,29 @@
1
+ module Pod
2
+ module UserInterface
3
+
4
+ class << self
5
+
6
+ # Changes the indentation level and yields to the given block.
7
+ # Useful to call succesive UI methods and have their content be indented.
8
+ def indented_block(relative_indentation = 2)
9
+ self.indentation_level += relative_indentation
10
+
11
+ yield if block_given?
12
+
13
+ self.indentation_level -= relative_indentation
14
+ end
15
+
16
+ # Prints a message with a label and a given marker, instead of the standard hyphen.
17
+ #
18
+ def marked_labeled(marker, label, value, justification = 12)
19
+ if value
20
+ title = "#{marker} #{label}: "
21
+ puts wrap_string(title.ljust(justification) + "#{value}", self.indentation_level)
22
+ end
23
+ end
24
+
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,40 @@
1
+ module Pod
2
+
3
+ module Thumbs
4
+
5
+ class VotedDependency
6
+
7
+ attr_accessor :dependency
8
+ attr_accessor :votes
9
+
10
+ delegate :name, :to => :dependency
11
+
12
+ def initialize(dependency, votes)
13
+ @dependency = dependency
14
+ @votes = votes.map { |v| v.is_a?(Hash) ? DependencyVote.new(v) : v }
15
+ end
16
+
17
+ def up_votes
18
+ @votes.select { |v| v.type == :up }
19
+ end
20
+
21
+ def down_votes
22
+ @votes.select { |v| v.type == :down }
23
+ end
24
+
25
+ def satisfied_by?(version)
26
+ @dependency.requirement.satisfied_by? version
27
+ end
28
+
29
+ def votes_summary_string
30
+ result = []
31
+ result << "+#{up_votes.count}".green if up_votes.count > 0
32
+ result << "-#{down_votes.count}".red if down_votes.count > 0
33
+ result.join(" ")
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+
3
+ module Pod
4
+ module Thumbs
5
+
6
+ class VotesList
7
+
8
+ attr_reader :voted_dependencies
9
+
10
+ def initialize(json_list_url)
11
+ list = JSON.parse(json_list_url, {:symbolize_names => true})
12
+
13
+ @voted_dependencies = Array.new
14
+
15
+ list[:thumbs].each do |entry|
16
+ voted_dependency = VotedDependency.new(Pod::Dependency.new(entry[:name], entry[:version]), entry[:votes])
17
+
18
+ @voted_dependencies << voted_dependency
19
+ end
20
+ end
21
+
22
+ def find(name, version_requirement)
23
+ @voted_dependencies.select { |vd| vd.name == name and vd.satisfied_by? version_requirement }
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-thumbs/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-thumbs/command.rb'
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Thumbs::Server do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ thumbs server }).should.be.instance_of Command::Thumbs::Server
8
+ end
9
+
10
+ it "should error if we don't get a server URL" do
11
+ command = Command.parse(%w( thumbs server ))
12
+ exception = lambda { command.validate! }.should.raise CLAide::Help
13
+ exception.message.should.include 'specify a server URL'
14
+ end
15
+
16
+ it "should set the new URL for the server and print it back to the user" do
17
+ test_server = "https://github.com/pbendersky/thumbs/raw/master/list.json"
18
+ command = Command.parse(%W( thumbs server #{test_server} ))
19
+ lambda { command.validate! }.should.not.raise CLAide::Help
20
+ command.run
21
+ UI.output.should.include test_server
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
@@ -0,0 +1,59 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+
5
+ require 'cocoapods-thumbs/configuration'
6
+
7
+ describe Command::Thumbs do
8
+
9
+ before do
10
+ Pod::Config.any_instance.stubs(:podfile).returns(Pod::Podfile.new(Pathname.new(ROOT + '/specs/fixtures/Podfile')))
11
+ Pod::Config.any_instance.stubs(:integrate_targets?).returns(false)
12
+ Pod::Thumbs::Configuration.stubs(:config_file_path).returns(File.new(ROOT + 'spec/fixtures/.cocoapods-thumbs.yaml'))
13
+ Pod::Command::Thumbs.any_instance.stubs(:verify_config_exists!).returns(true)
14
+ end
15
+
16
+ describe 'CLAide' do
17
+ it 'registers it self' do
18
+ Command.parse(%w{ thumbs }).should.be.instance_of Command::Thumbs
19
+ end
20
+
21
+ it 'can accept a comments parameter' do
22
+ command = Command.parse(%w{ thumbs --comments })
23
+ lambda { command.validate! }.should.not.raise CLAide::Help
24
+ end
25
+
26
+ it 'can accept a platform parameter' do
27
+ command = Command.parse(%w{ thumbs AFNetworking 2.5.3 --platform=ios })
28
+ lambda { command.validate! }.should.not.raise CLAide::Help
29
+ end
30
+
31
+ it 'can accept ios as a platform' do
32
+ command = Command.parse(%w{ thumbs AFNetworking 2.5.3 --platform=ios })
33
+ lambda { command.validate! }.should.not.raise CLAide::Help
34
+ end
35
+
36
+ it 'can accept osx as a platform' do
37
+ command = Command.parse(%w{ thumbs AFNetworking 2.5.3 --platform=osx })
38
+ lambda { command.validate! }.should.not.raise CLAide::Help
39
+ end
40
+
41
+ it 'fails with anything other than ios or osx as a platform' do
42
+ command = Command.parse(%w{ thumbs AFNetworking 2.5.3 --platform=win })
43
+ lambda { command.validate! }.should.raise Pod::Informative
44
+ end
45
+
46
+ it 'can optionally receive a spec name' do
47
+ command = Command.parse(%w{ thumbs AFNetworking })
48
+ lambda { command.run }.should.not.raise CLAide::Help
49
+ end
50
+
51
+ it 'can optionally receive a spec name and a requirements string' do
52
+ command = Command.parse(%w{ thumbs AFNetworking 2.5 })
53
+ lambda { command.run }.should.not.raise CLAide::Help
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+
@@ -0,0 +1,43 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+
5
+ describe Thumbs::DependencyVote do
6
+ before do
7
+ # votes = [
8
+ # DependencyVote.new(name: 'AFNetworking', type: :up, voter: '@pbendersky', comment: 'Excelent'),
9
+ # ]
10
+ @dependency_vote = Thumbs::DependencyVote.new(type: :up, voter: '@pbendersky', comment: 'Nice')
11
+ @dependency_down_vote = Thumbs::DependencyVote.new(type: :down, voter: '@pbendersky', comment: 'Nice')
12
+ end
13
+
14
+ it 'has a type' do
15
+ @dependency_vote.type.should.equal :up
16
+ end
17
+
18
+ it 'has a voter' do
19
+ @dependency_vote.voter.should.equal '@pbendersky'
20
+ end
21
+
22
+ it 'may have a comment' do
23
+ @dependency_vote.comment.should.equal 'Nice'
24
+ end
25
+
26
+ it 'can be initialized from a hash' do
27
+ hash = { type: :up, voter: '@pbendersky', comment: 'Nice' }
28
+
29
+ dependency_vote = Thumbs::DependencyVote.new(hash)
30
+
31
+ dependency_vote.type.should.be.equal :up
32
+ dependency_vote.voter.should.be.equal '@pbendersky'
33
+ dependency_vote.comment.should.be.equal 'Nice'
34
+ end
35
+
36
+ it 'has a string representation of its up / down type' do
37
+ @dependency_vote.type_string.should.be.equal "+".green
38
+ @dependency_down_vote.type_string.should.be.equal "-".red
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ :url: https://github.com/pbendersky/thumbs/raw/master/list.json
@@ -0,0 +1,18 @@
1
+ # Uncomment this line to define a global platform for your project
2
+ source 'https://github.com/CocoaPods/Specs.git'
3
+
4
+ platform :ios, "7.0"
5
+
6
+ target "testTarget" do
7
+ pod 'AFNetworking', '~> 2.5'
8
+ pod 'AFNetworkActivityLogger'
9
+ pod 'MBProgressHUD', '~> 0.8'
10
+ pod 'PSTAlertController'
11
+ pod 'GRMustache', '~> 7.3'
12
+ pod 'FCModel', '~> 0.9'
13
+ pod 'SDWebImage', '~>3.6'
14
+ pod 'UIActivityIndicator-for-SDWebImage'
15
+ pod 'youtube-ios-player-helper', '~> 0.1.1'
16
+ pod 'RETableViewManager', '~> 1.6'
17
+ end
18
+
@@ -0,0 +1,37 @@
1
+ {
2
+ "thumbs": [
3
+ {
4
+ "name": "AFNetworking",
5
+ "version": "~> 2.5",
6
+ "votes": [
7
+ {
8
+ "type": "up",
9
+ "voter": "@pbendersky",
10
+ "comment": "Excellent library!"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "name": "AFNetworking",
16
+ "version": "2.5.2",
17
+ "votes": [
18
+ {
19
+ "type": "down",
20
+ "voter": "@pbendersky",
21
+ "comment": "Don't use this version, update to 2.5.3 instead."
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "name": "EGOTableViewPullRefresh",
27
+ "version": "~> 0.1",
28
+ "votes": [
29
+ {
30
+ "type": "down",
31
+ "voter": "@pbendersky",
32
+ "comment": "Discontinued. Use native implementation in UITableView"
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
@@ -0,0 +1,58 @@
1
+ # Set up coverage analysis
2
+ #-----------------------------------------------------------------------------#
3
+
4
+ if RUBY_VERSION >= '1.9.3'
5
+ require 'codeclimate-test-reporter'
6
+ CodeClimate::TestReporter.configure do |config|
7
+ config.logger.level = Logger::WARN
8
+ end
9
+ CodeClimate::TestReporter.start
10
+ end
11
+
12
+ require 'pathname'
13
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
14
+ $:.unshift((ROOT + 'lib').to_s)
15
+ $:.unshift((ROOT + 'spec').to_s)
16
+
17
+ require 'bundler/setup'
18
+ require 'bacon'
19
+ require 'pretty_bacon'
20
+ require 'mocha-on-bacon'
21
+ require 'cocoapods'
22
+
23
+ require 'cocoapods_plugin'
24
+
25
+ #-----------------------------------------------------------------------------#
26
+
27
+ module Pod
28
+
29
+ # Disable the wrapping so the output is deterministic in the tests.
30
+ #
31
+ UI.disable_wrap = true
32
+
33
+ # Redirects the messages to an internal store.
34
+ #
35
+ module UI
36
+ @output = ''
37
+ @warnings = ''
38
+
39
+ class << self
40
+ attr_accessor :output
41
+ attr_accessor :warnings
42
+
43
+ def puts(message = '')
44
+ @output << "#{message}\n"
45
+ end
46
+
47
+ def warn(message = '', actions = [])
48
+ @warnings << "#{message}\n"
49
+ end
50
+
51
+ def print(message)
52
+ @output << message
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ #-----------------------------------------------------------------------------#
@@ -0,0 +1,68 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+
5
+ describe Thumbs::VotedDependency do
6
+ before do
7
+ votes = [
8
+ Thumbs::DependencyVote.new(type: :up, voter: '@user1', comment: 'Excelent'),
9
+ Thumbs::DependencyVote.new(type: :up, voter: '@user2', comment: 'Excelent'),
10
+ Thumbs::DependencyVote.new(type: :down, voter: '@user3', comment: "Don't use this please."),
11
+ ]
12
+ @voted_dependency = Thumbs::VotedDependency.new(Pod::Dependency.new('AFNetworking', '~> 2.5'), votes)
13
+ end
14
+
15
+ it 'has a cocoapods dependency' do
16
+ @voted_dependency.dependency.should.not.be.nil
17
+ end
18
+
19
+ it 'has an array of votes' do
20
+ @voted_dependency.votes.should.not.be.nil
21
+ end
22
+
23
+ it 'has some upvotes' do
24
+ @voted_dependency.up_votes.count.should.be.equal 2
25
+ end
26
+
27
+ it 'has upvotes as instances of DependencyVote' do
28
+ @voted_dependency.up_votes.first.class.should.be.equal Thumbs::DependencyVote
29
+ end
30
+
31
+ it 'has some downvotes' do
32
+ @voted_dependency.down_votes.count.should.be.equal 1
33
+ end
34
+
35
+ it 'has downvotes as instances of DependencyVote' do
36
+ @voted_dependency.down_votes.first.class.should.be.equal Thumbs::DependencyVote
37
+ end
38
+
39
+ it 'has DependencyVote instances as votes' do
40
+ @voted_dependency.votes.count.should.be.equal 3
41
+ @voted_dependency.votes.first.class.should.be.equal Thumbs::DependencyVote
42
+ end
43
+
44
+ it 'initializes its votes from an array of hashes and turns them into DependencyVote' do
45
+ votes = [
46
+ {
47
+ "type" => "up",
48
+ "voter" => "@pbendersky",
49
+ "comment" => "Excellent library!"
50
+ }
51
+ ]
52
+ voted_dependency = Thumbs::VotedDependency.new(Pod::Dependency.new, votes)
53
+
54
+ voted_dependency.votes.first.should.be.kind_of Thumbs::DependencyVote
55
+ end
56
+
57
+ it 'can be satisfied by a version' do
58
+ @voted_dependency.satisfied_by?(Version.new('2.5.3')).should.be.true
59
+ @voted_dependency.satisfied_by?(Version.new('2.4.2')).should.be.false
60
+ end
61
+
62
+ it 'can return a colored string with a summary of its votes' do
63
+ @voted_dependency.votes_summary_string.should.equal "#{"+2".green} #{"-1".red}"
64
+ end
65
+
66
+ end
67
+
68
+ end
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+
5
+ describe Thumbs::VotesList do
6
+
7
+ def greater_than(number)
8
+ lambda { |obj| obj > number }
9
+ end
10
+
11
+ before do
12
+ @voted_list = Thumbs::VotesList.new(IO.read(File.new(File.expand_path('../fixtures/list.json', __FILE__))))
13
+ end
14
+
15
+ it 'should properly parse the JSON thumbs file' do
16
+ @voted_list.should.not.be.nil
17
+ end
18
+
19
+ it 'should have some voted dependencies' do
20
+ @voted_list.voted_dependencies.should.not.be.nil
21
+ end
22
+
23
+ it 'should have a non empty list of voted dependencies' do
24
+ @voted_list.voted_dependencies.count.should.be greater_than(0)
25
+ end
26
+
27
+ it 'should include AFNetworking and EGOTableViewPullRefresh as voted dependencies' do
28
+ @voted_list.voted_dependencies.find { |o| o.name == 'AFNetworking' }.should.not.be.nil
29
+ @voted_list.voted_dependencies.find { |o| o.name == 'EGOTableViewPullRefresh' }.should.not.be.nil
30
+ end
31
+
32
+ it 'can find a VotedDependency by its name and satisfied version' do
33
+ @voted_list.find('AFNetworking', Version.new('2.5.3')).should.not.be.nil
34
+ @voted_list.find('AFNetworking', Version.new('2.5.3')).count.should.be.equal 1
35
+ @voted_list.find('AFNetworking', Version.new('2.5.3')).should.be.kind_of Array
36
+ end
37
+
38
+ it 'can return multiple VotedDependency entries' do
39
+ @voted_list.find('AFNetworking', Version.new('2.5.2')).count.should.be.equal 2
40
+ end
41
+
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-thumbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pablo Bendersky
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-18 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: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - .gitignore
48
+ - .travis.yml
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-thumbs.gemspec
55
+ - lib/cocoapods-thumbs.rb
56
+ - lib/cocoapods-thumbs/command.rb
57
+ - lib/cocoapods-thumbs/command/thumbs.rb
58
+ - lib/cocoapods-thumbs/command/thumbs/server.rb
59
+ - lib/cocoapods-thumbs/configuration.rb
60
+ - lib/cocoapods-thumbs/dependency_vote.rb
61
+ - lib/cocoapods-thumbs/gem_version.rb
62
+ - lib/cocoapods-thumbs/user_interface.rb
63
+ - lib/cocoapods-thumbs/voted_dependency.rb
64
+ - lib/cocoapods-thumbs/votes_list.rb
65
+ - lib/cocoapods_plugin.rb
66
+ - spec/command/thumbs/server_spec.rb
67
+ - spec/command/thumbs_spec.rb
68
+ - spec/dependency_vote_spec.rb
69
+ - spec/fixtures/.cocoapods-thumbs.yaml
70
+ - spec/fixtures/Podfile
71
+ - spec/fixtures/list.json
72
+ - spec/spec_helper.rb
73
+ - spec/voted_dependency_spec.rb
74
+ - spec/votes_list_spec.rb
75
+ homepage: https://github.com/quadion/cocoapods-thumbs
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.2
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: CocoaPods plugin which allows to see peer votes of a Podfile or single Podspec.
99
+ test_files:
100
+ - spec/command/thumbs/server_spec.rb
101
+ - spec/command/thumbs_spec.rb
102
+ - spec/dependency_vote_spec.rb
103
+ - spec/fixtures/.cocoapods-thumbs.yaml
104
+ - spec/fixtures/Podfile
105
+ - spec/fixtures/list.json
106
+ - spec/spec_helper.rb
107
+ - spec/voted_dependency_spec.rb
108
+ - spec/votes_list_spec.rb