cocoapods-plugins 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 627b3a781e5eb3dcd8bab22e1c54fab8cd28195f
4
- data.tar.gz: df053120c04bba449b761518c619f5843eac54ba
3
+ metadata.gz: 175693b505a342790eaf3cbcfab9fe7d6c927632
4
+ data.tar.gz: 1eb97667021a96671e34ee923e62240661435bfc
5
5
  SHA512:
6
- metadata.gz: 6cd540ae5191ef202aebf16877f9ba09e10213162eefa8abd3787a2f1a2fda32cf82c417a799b3ed0e910956477cf3556ffbadab168a1b58ef2060b7fa2c0cab
7
- data.tar.gz: ee7c74aa53ab71e6be6b5652dfb165215a596cb4aa5f64f7ab625b5ff56f0b5eb12c21a0ddc91241677c8d8d30f71284c83f3ef079f794d804bcf08f5a7d98b1
6
+ metadata.gz: 7efb87c03471c63a0b594674a09cba9e8fe1360e494cb3d2a6c3f23e485fde14d2f948f97b39a382fa399039ec7ea4eb2c0cd50b9a3faba4eae220ca53ad0f35
7
+ data.tar.gz: b5bf88be513744b69e474ca6954d574074fb4e35adee075654eda5f5eda76e4e5d24243318495332b7a62b943a427d4db4fbe3248c6b24706c8667cb8a3e001c
@@ -1,4 +1,4 @@
1
1
  inherit_from:
2
- - .rubocop-cocoapods.yml
2
+ - .rubocop_cocoapods.yml
3
3
 
4
4
 
@@ -1,8 +1,15 @@
1
1
  AllCops:
2
2
  Include:
3
- - Rakefile
3
+ - ./Rakefile
4
+ - ./Gemfile
5
+ - ./*.gemspec
4
6
  Exclude:
5
- - spec/fixtures/**
7
+ - ./spec/fixtures/**/*
8
+
9
+ # At the moment not ready to be used
10
+ # https://github.com/bbatsov/rubocop/issues/947
11
+ Documentation:
12
+ Enabled: false
6
13
 
7
14
  #- CocoaPods -----------------------------------------------------------------#
8
15
 
@@ -30,6 +37,19 @@ SingleLineBlockParams:
30
37
  Encoding:
31
38
  Enabled: false
32
39
 
40
+ # Having these make it easier to *not* forget to add one when adding a new
41
+ # value and you can simply copy the previous line.
42
+ TrailingComma:
43
+ EnforcedStyleForMultiline: comma
44
+
45
+ # Clashes with CLAide Command#validate!
46
+ GuardClause:
47
+ Enabled: false
48
+
49
+ # Not always desirable: lib/claide/command/plugins_helper.rb:12:15
50
+ Next:
51
+ Enabled: false
52
+
33
53
  #- CocoaPods support for Ruby 1.8.7 ------------------------------------------#
34
54
 
35
55
  HashSyntax:
@@ -38,6 +58,14 @@ HashSyntax:
38
58
  Lambda:
39
59
  Enabled: false
40
60
 
61
+ DotPosition:
62
+ EnforcedStyle: trailing
63
+
64
+ EachWithObject:
65
+ Enabled: false
66
+
67
+ Style/SpecialGlobalVars:
68
+ Enabled: false
41
69
 
42
70
  #- CocoaPods specs -----------------------------------------------------------#
43
71
 
@@ -1,26 +1,24 @@
1
- # Sets Travis to run the Ruby specs on OS X machines which are required to
2
- # build the native extensions of Xcodeproj.
1
+ # Sets Travis to run the Ruby specs on OS X machines to be as close as possible
2
+ # to the user environment.
3
3
  #
4
4
  language: objective-c
5
+ addons:
6
+ code_climate:
7
+ repo_token: 2926ae7ea0b2a6ced8b0d67efa235769ab85de1d9c9f6702f40d80bacec3c9c4
8
+
5
9
  env:
6
- # This is what 10.8.x comes with and we want to support that.
7
10
  - RVM_RUBY_VERSION=system
8
- - RVM_RUBY_VERSION=2.0.0-p353
11
+ # - RVM_RUBY_VERSION=1.8.7-p358
9
12
 
10
13
  before_install:
14
+ - export LANG=en_US.UTF-8
11
15
  - curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem
12
- - export SSL_CERT_FILE=/usr/local/share/cacert.pem
13
- - export PYTHONPATH=/usr/local
14
- - export GIT_AUTHOR_NAME=CocoaPods
15
- - export GIT_AUTHOR_EMAIL=cocoapods@example.com
16
16
  - source ~/.rvm/scripts/rvm
17
17
  - if [[ $RVM_RUBY_VERSION != 'system' ]]; then rvm install $RVM_RUBY_VERSION; fi
18
18
  - rvm use $RVM_RUBY_VERSION
19
- - if [[ $RVM_RUBY_VERSION == 'system' ]]; then export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future; fi
20
- - if [[ $RVM_RUBY_VERSION == 'system' ]]; then sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2; fi
21
19
  - if [[ $RVM_RUBY_VERSION == 'system' ]]; then sudo gem install bundler --no-ri --no-rdoc; else gem install bundler --no-ri --no-rdoc; fi
22
-
20
+
23
21
  install:
24
- - bundle install --path ./travis_bundle_dir
25
-
22
+ - sudo bundle install --without=documentation
23
+
26
24
  script: bundle exec rake spec
@@ -1,5 +1,13 @@
1
1
  # Cocoapods::Plugins Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ * Added a reminder to add plugin to `plugins.json` once released (fix #27)
6
+ [Olivier Halligon](https://github.com/AliSoftware)
7
+
8
+ * Print out the version of plugins when invoked with `--verbose`
9
+ [David Grandinetti](https://github.com/dbgrandi)
10
+
3
11
  ## 0.2.0
4
12
 
5
13
  * Migrating to new syntax of CLAide::Command#arguments (fix #23)
data/Gemfile CHANGED
@@ -3,13 +3,18 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'cocoapods'
6
+ gem 'cocoapods', :git => 'https://github.com/CocoaPods/CocoaPods.git', :branch => 'master'
7
+ gem 'cocoapods-core', :git => 'https://github.com/CocoaPods/Core.git', :branch => 'master'
8
+ gem 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master'
9
+
7
10
  gem 'bacon'
8
- gem 'coveralls', :require => false
9
11
  gem 'mocha-on-bacon'
10
12
  gem 'prettybacon'
13
+ gem 'vcr'
11
14
  gem 'webmock'
15
+
12
16
  if RUBY_VERSION >= '1.9.3'
17
+ gem 'codeclimate-test-reporter', :require => nil
13
18
  gem 'rubocop'
14
19
  end
15
20
  end
@@ -1,94 +1,112 @@
1
+ GIT
2
+ remote: https://github.com/CocoaPods/CLAide.git
3
+ revision: 31e74fae76461e9832e488f77a9e8116703c201b
4
+ branch: master
5
+ specs:
6
+ claide (0.7.0)
7
+
8
+ GIT
9
+ remote: https://github.com/CocoaPods/CocoaPods.git
10
+ revision: 576b10b9bf72c3aaded4e767bc0f8735a8e1fcca
11
+ branch: master
12
+ specs:
13
+ cocoapods (0.33.1)
14
+ activesupport (>= 3.2.15, < 4)
15
+ claide (~> 0.7.0)
16
+ cocoapods-core (= 0.33.1)
17
+ cocoapods-downloader (~> 0.6.1)
18
+ cocoapods-plugins (~> 0.3.0)
19
+ cocoapods-trunk (~> 0.1.4)
20
+ cocoapods-try (~> 0.3.0)
21
+ colored (~> 1.2)
22
+ escape (~> 0.0.4)
23
+ json_pure (~> 1.8)
24
+ nap (~> 0.8)
25
+ open4 (~> 1.3)
26
+ xcodeproj (~> 0.18.0)
27
+
28
+ GIT
29
+ remote: https://github.com/CocoaPods/Core.git
30
+ revision: 2c5be5dbb1157c10e86ff75223a119b74d01ae7f
31
+ branch: master
32
+ specs:
33
+ cocoapods-core (0.33.1)
34
+ activesupport (>= 3.2.15)
35
+ fuzzy_match (~> 2.0.4)
36
+ json_pure (~> 1.8)
37
+ nap (~> 0.8.0)
38
+
1
39
  PATH
2
40
  remote: .
3
41
  specs:
4
- cocoapods-plugins (0.2.0)
42
+ cocoapods-plugins (0.3.0)
5
43
  nap
6
44
 
7
45
  GEM
8
46
  remote: https://rubygems.org/
9
47
  specs:
10
- activesupport (3.2.17)
48
+ CFPropertyList (2.2.8)
49
+ activesupport (3.2.19)
11
50
  i18n (~> 0.6, >= 0.6.4)
12
51
  multi_json (~> 1.0)
13
52
  addressable (2.3.6)
14
53
  ast (2.0.0)
54
+ astrolabe (1.3.0)
55
+ parser (>= 2.2.0.pre.3, < 3.0)
15
56
  bacon (1.2.0)
16
- claide (0.5.0)
17
- cocoapods (0.32.1)
18
- activesupport (>= 3.2.15, < 4)
19
- claide (~> 0.5.0)
20
- cocoapods-core (= 0.32.1)
21
- cocoapods-downloader (~> 0.5.0)
22
- cocoapods-try (~> 0.2.0)
23
- colored (~> 1.2)
24
- escape (~> 0.0.4)
25
- json_pure (~> 1.8)
26
- nap (~> 0.7)
27
- open4 (~> 1.3)
28
- xcodeproj (~> 0.16.1)
29
- cocoapods-core (0.32.1)
30
- activesupport (>= 3.2.15, < 4)
31
- fuzzy_match (~> 2.0.4)
57
+ cocoapods-downloader (0.6.1)
58
+ cocoapods-trunk (0.1.4)
32
59
  json_pure (~> 1.8)
33
- nap (~> 0.5)
34
- cocoapods-downloader (0.5.0)
35
- cocoapods-try (0.2.0)
60
+ nap (>= 0.8)
61
+ netrc
62
+ cocoapods-try (0.3.0)
63
+ codeclimate-test-reporter (0.4.0)
64
+ simplecov (>= 0.7.1, < 1.0.0)
36
65
  colored (1.2)
37
- coveralls (0.7.0)
38
- multi_json (~> 1.3)
39
- rest-client
40
- simplecov (>= 0.7)
41
- term-ansicolor
42
- thor
43
66
  crack (0.4.2)
44
67
  safe_yaml (~> 1.0.0)
45
- docile (1.1.3)
68
+ docile (1.1.5)
46
69
  escape (0.0.4)
47
70
  fuzzy_match (2.0.4)
48
- i18n (0.6.9)
49
- json (1.8.1)
71
+ i18n (0.6.11)
50
72
  json_pure (1.8.1)
51
73
  metaclass (0.0.4)
52
- mime-types (2.2)
53
- mocha (1.0.0)
74
+ mocha (1.1.0)
54
75
  metaclass (~> 0.0.1)
55
76
  mocha-on-bacon (0.2.2)
56
77
  mocha (>= 0.13.0)
57
- multi_json (1.9.2)
58
- nap (0.7.0)
59
- open4 (1.3.3)
60
- parser (2.1.9)
78
+ multi_json (1.10.1)
79
+ nap (0.8.0)
80
+ netrc (0.7.7)
81
+ open4 (1.3.4)
82
+ parser (2.2.0.pre.4)
61
83
  ast (>= 1.1, < 3.0)
62
84
  slop (~> 3.4, >= 3.4.5)
63
85
  powerpack (0.0.9)
64
- prettybacon (0.0.1)
86
+ prettybacon (0.0.2)
65
87
  bacon (~> 1.2)
66
88
  rainbow (2.0.0)
67
- rake (10.2.2)
68
- rest-client (1.6.7)
69
- mime-types (>= 1.16)
70
- rubocop (0.20.1)
71
- json (>= 1.7.7, < 2)
72
- parser (~> 2.1.7)
89
+ rake (10.3.2)
90
+ rubocop (0.26.0)
91
+ astrolabe (~> 1.3)
92
+ parser (>= 2.2.0.pre.4, < 3.0)
73
93
  powerpack (~> 0.0.6)
74
94
  rainbow (>= 1.99.1, < 3.0)
75
95
  ruby-progressbar (~> 1.4)
76
- ruby-progressbar (1.4.2)
77
- safe_yaml (1.0.2)
78
- simplecov (0.8.2)
96
+ ruby-progressbar (1.5.1)
97
+ safe_yaml (1.0.3)
98
+ simplecov (0.9.0)
79
99
  docile (~> 1.1.0)
80
100
  multi_json
81
101
  simplecov-html (~> 0.8.0)
82
102
  simplecov-html (0.8.0)
83
- slop (3.5.0)
84
- term-ansicolor (1.3.0)
85
- tins (~> 1.0)
86
- thor (0.19.1)
87
- tins (1.1.0)
88
- webmock (1.17.4)
89
- addressable (>= 2.2.7)
103
+ slop (3.6.0)
104
+ vcr (2.9.3)
105
+ webmock (1.18.0)
106
+ addressable (>= 2.3.6)
90
107
  crack (>= 0.3.2)
91
- xcodeproj (0.16.1)
108
+ xcodeproj (0.18.0)
109
+ CFPropertyList (~> 2.2)
92
110
  activesupport (~> 3.0)
93
111
  colored (~> 1.2)
94
112
 
@@ -98,11 +116,14 @@ PLATFORMS
98
116
  DEPENDENCIES
99
117
  bacon
100
118
  bundler (~> 1.3)
101
- cocoapods
119
+ claide!
120
+ cocoapods!
121
+ cocoapods-core!
102
122
  cocoapods-plugins!
103
- coveralls
123
+ codeclimate-test-reporter
104
124
  mocha-on-bacon
105
125
  prettybacon
106
126
  rake
107
127
  rubocop
128
+ vcr
108
129
  webmock
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Cocoapods plugins
2
2
 
3
- [![Build Status](https://img.shields.io/travis/CocoaPods/cocoapods-plugins.svg)](https://travis-ci.org/CocoaPods/cocoapods-plugins)
4
- [![Coverage Status](https://coveralls.io/repos/CocoaPods/cocoapods-plugins/badge.png)](https://coveralls.io/r/CocoaPods/cocoapods-plugins)
5
- [![Code Climate](https://img.shields.io/codeclimate/github/CocoaPods/cocoapods-plugins.svg)](https://codeclimate.com/github/CocoaPods/cocoapods-plugins)
3
+ [![Build Status](https://img.shields.io/travis/CocoaPods/cocoapods-plugins/master.svg?style=flat)](https://travis-ci.org/CocoaPods/cocoapods-plugins)
4
+ [![Coverage](https://img.shields.io/codeclimate/coverage/github/CocoaPods/cocoapods-plugins.svg?style=flat)](https://codeclimate.com/github/CocoaPods/cocoapods-plugins)
5
+ [![Code Climate](https://img.shields.io/codeclimate/github/CocoaPods/cocoapods-plugins.svg?style=flat)](https://codeclimate.com/github/CocoaPods/cocoapods-plugins)
6
6
 
7
7
  CocoaPods plugin which shows info about available CocoaPods plugins or helps you get started developing a new plugin. Yeah, it's very meta.
8
8
 
@@ -33,7 +33,7 @@ If a `TEMPLATE_URL`, pointing to a git repo containing a compatible template, is
33
33
 
34
34
  ## Get your plugin listed
35
35
 
36
- The list of plugins is in the cocoapods.org repository at [https://github.com/CocoaPods/cocoapods.org/blob/master/data/plugins.json](https://github.com/CocoaPods/cocoapods.org/blob/master/data/plugins.json).
36
+ The list of plugins is in the cocoapods.org repository at [https://github.com/CocoaPods/cocoapods.org/blob/master/plugins.json](https://github.com/CocoaPods/cocoapods.org/blob/master/plugins.json).
37
37
 
38
38
  To have your plugin listed, submit a pull request that adds your plugin details.
39
39
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ task :bootstrap do
7
7
  else
8
8
  $stderr.puts "\033[0;31m" \
9
9
  "[!] Please install the bundler gem manually:\n" \
10
- " $ [sudo] gem install bundler" \
10
+ ' $ [sudo] gem install bundler' \
11
11
  "\e[0m"
12
12
  exit 1
13
13
  end
@@ -19,7 +19,6 @@ begin
19
19
 
20
20
  task :default => 'spec'
21
21
 
22
-
23
22
  # Spec
24
23
  #-----------------------------------------------------------------------------#
25
24
 
@@ -43,7 +42,7 @@ begin
43
42
  task :rubocop do
44
43
  if RUBY_VERSION >= '1.9.3'
45
44
  require 'rubocop'
46
- cli = Rubocop::CLI.new
45
+ cli = RuboCop::CLI.new
47
46
  result = cli.run(FileList['{spec,lib}/**/*.rb'])
48
47
  abort('RuboCop failed!') unless result == 0
49
48
  else
@@ -2,5 +2,5 @@
2
2
  # The namespace of the Cocoapods plugins plugin.
3
3
  #
4
4
  module CocoapodsPlugins
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
@@ -0,0 +1,114 @@
1
+ require 'pod/command/gem_index_cache'
2
+
3
+ module Pod
4
+ class Command
5
+ # This module is used by Command::PluginsHelper to download the Gem
6
+ # Specification data, check if a Gem is installed, and provide info
7
+ # on all versions of a Gem.
8
+ #
9
+ module GemHelper
10
+ # A GemIndexCache to manage downloading/caching the spec index.
11
+ #
12
+ @cache = nil
13
+
14
+ # Getter for GemIndexCache
15
+ #
16
+ # @return [GemIndexCache] a new or memoized GemIndexCache
17
+ #
18
+ def self.cache
19
+ @cache ||= GemIndexCache.new
20
+ end
21
+
22
+ # Instantiate a cache and download the spec index if it has
23
+ # not already been done.
24
+ #
25
+ def self.download_and_cache_specs
26
+ cache.download_and_cache_specs
27
+ end
28
+
29
+ # Tells if a gem is installed
30
+ #
31
+ # @param [String] gem_name
32
+ # The name of the plugin gem to test
33
+ #
34
+ # @param [String] version_string
35
+ # An optional version string, used to check if a specific
36
+ # version of a gem is installed
37
+ #
38
+ # @return [Bool] true if the gem is installed, false otherwise.
39
+ #
40
+ def self.gem_installed?(gem_name, version_string = nil)
41
+ version = Gem::Version.new(version_string) if version_string
42
+
43
+ gems = Gem::Specification.find_all_by_name(gem_name)
44
+ return !gems.empty? unless version
45
+
46
+ gems.each do |gem|
47
+ return true if gem.version == version
48
+ end
49
+
50
+ false
51
+ end
52
+
53
+ # Get the version of a gem that is installed locally. If more than
54
+ # one version is installed, this returns the first version found,
55
+ # which MAY not be the highest/newest version.
56
+ #
57
+ # @return [String] The version of the gem that is installed,
58
+ # or nil if it is not installed.
59
+ #
60
+ def self.installed_version(gem_name)
61
+ gem = Gem::Specification.find_all_by_name(gem_name).first
62
+ gem ? gem.version.to_s : nil
63
+ end
64
+
65
+ # Create a string containing all versions of a plugin,
66
+ # colored to indicate if a specific version is installed
67
+ # locally.
68
+ #
69
+ # @param [String] plugin_name
70
+ # The name of the plugin gem
71
+ #
72
+ # @param [GemIndexCache] index_cache
73
+ # Optional index cache can be passed in, otherwise
74
+ # the module instance is used.
75
+ #
76
+ # @return [String] a string containing a comma separated
77
+ # concatenation of all versions of a plugin
78
+ # that were found on rubygems.org
79
+ #
80
+ def self.versions_string(plugin_name, index_cache = @cache)
81
+ name_tuples = index_cache.specs_with_name(plugin_name)
82
+ sorted_versions = name_tuples.sort_by(&:version)
83
+ version_strings = colorize_versions(sorted_versions)
84
+ version_strings.join ', '
85
+ end
86
+
87
+ #----------------#
88
+
89
+ private
90
+
91
+ # Colorize an Array of version strings so versions that are installed
92
+ # are green and uninstalled versions are yellow.
93
+ #
94
+ # @param [Array] versions
95
+ # sorted array of Gem::NameTuples representing all versions of
96
+ # a plugin gem.
97
+ #
98
+ # @return [Array] An array of strings, each one being the version
99
+ # string of the same plugin
100
+ #
101
+ def self.colorize_versions(versions)
102
+ colored_strings = []
103
+ versions.reverse_each do |name_tuple|
104
+ if gem_installed?(name_tuple.name, name_tuple.version.to_s)
105
+ colored_strings << name_tuple.version.to_s.green
106
+ else
107
+ colored_strings << name_tuple.version.to_s.yellow
108
+ end
109
+ end
110
+ colored_strings
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,87 @@
1
+ require 'pod/command/gem_helper'
2
+
3
+ module Pod
4
+ class Command
5
+ # This class is used by Command::GemsHelper to download the Gem
6
+ # Specification index from rubygems.org and provide info about
7
+ # the index.
8
+ #
9
+ class GemIndexCache
10
+ # A memoized hash of all the rubygem specs. If it is nil, the specs will
11
+ # be downloaded, which will take a few seconds to download.
12
+ #
13
+ # @return [Hash] The hash of all rubygems
14
+ #
15
+ def specs
16
+ @specs ||= download_specs
17
+ end
18
+
19
+ # Alias to make the initial caching process more readable.
20
+ #
21
+ alias_method :download_and_cache_specs, :specs
22
+
23
+ # Get an Array of Gem::NameTuple objects that match a given
24
+ # spec name.
25
+ #
26
+ # @param [String] name
27
+ # The name of the gem to match on (e.g. 'cocoapods-try')
28
+ #
29
+ # @return [Array] Array of Gem::NameTuple that match the name
30
+ #
31
+ def specs_with_name(name)
32
+ matching_specs = @specs.select do |spec|
33
+ spec[0].name == name
34
+ end
35
+
36
+ name_tuples = []
37
+ matching_specs.each do |(name_tuple, _)|
38
+ name_tuples << name_tuple
39
+ end
40
+
41
+ name_tuples
42
+ end
43
+
44
+ #----------------#
45
+
46
+ private
47
+
48
+ # Force the rubygem spec index file
49
+ #
50
+ # @return [Hash] The hash of all rubygems
51
+ #
52
+ def download_specs
53
+ UI.puts 'Downloading Rubygem specification index...'
54
+ fetcher = Gem::SpecFetcher.fetcher
55
+ results, errors = fetcher.available_specs(:released)
56
+
57
+ unless errors.empty?
58
+ UI.puts 'Error downloading Rubygem specification index: ' +
59
+ errors.first.error.to_s
60
+ return []
61
+ end
62
+
63
+ flatten_fetcher_results(results)
64
+ end
65
+
66
+ # Flatten the dictionary returned from Gem::SpecFetcher
67
+ # to a simple array.
68
+ #
69
+ # @param [Hash] results
70
+ # the hash returned from the call to
71
+ # Gem::SpecFetcher.available_specs()
72
+ #
73
+ # @return [Array] Array of all spec results
74
+ #
75
+ def flatten_fetcher_results(results)
76
+ specs = []
77
+ results.each do |source, source_specs|
78
+ source_specs.each do |tuple|
79
+ specs << [tuple, source]
80
+ end
81
+ end
82
+
83
+ specs
84
+ end
85
+ end
86
+ end
87
+ end
@@ -1,3 +1,5 @@
1
+ require 'pod/command/plugins_helper'
2
+
1
3
  module Pod
2
4
  class Command
3
5
  class Plugins
@@ -11,7 +13,7 @@ module Pod
11
13
  self.summary = 'Creates a new plugin'
12
14
  self.description = <<-DESC
13
15
  Creates a scaffold for the development of a new plugin
14
- according to the CocoaPods best practices.
16
+ named `NAME` according to the CocoaPods best practices.
15
17
 
16
18
  If a `TEMPLATE_URL`, pointing to a git repo containing a
17
19
  compatible template, is specified, it will be used
@@ -19,14 +21,14 @@ module Pod
19
21
  DESC
20
22
 
21
23
  self.arguments = [
22
- ['NAME', :required],
23
- ['TEMPLATE_URL', :optional]
24
+ CLAide::Argument.new('NAME', true),
25
+ CLAide::Argument.new('TEMPLATE_URL', false),
24
26
  ]
25
27
 
26
28
  def initialize(argv)
27
29
  @name = argv.shift_argument
28
30
  unless @name.nil? || @name.empty? || @name.index(NAME_PREFIX) == 0
29
- @name = @name.dup.prepend(NAME_PREFIX)
31
+ @name = NAME_PREFIX + @name.dup
30
32
  end
31
33
  @template_url = argv.shift_argument
32
34
  super
@@ -37,14 +39,14 @@ module Pod
37
39
  if @name.nil? || @name.empty?
38
40
  help! 'A name for the plugin is required.'
39
41
  end
40
- if @name.match(/\s/)
41
- help! 'The plugin name cannot contain spaces.'
42
- end
42
+
43
+ help! 'The plugin name cannot contain spaces.' if @name.match(/\s/)
43
44
  end
44
45
 
45
46
  def run
46
47
  clone_template
47
48
  configure_template
49
+ show_reminder
48
50
  end
49
51
 
50
52
  #----------------------------------------#
@@ -96,6 +98,15 @@ module Pod
96
98
  def template_repo_url
97
99
  @template_url || TEMPLATE_REPO
98
100
  end
101
+
102
+ # Shows a reminder to the plugin author to make a Pull Request
103
+ # in order to update plugins.json once the plugin is released
104
+ #
105
+ def show_reminder
106
+ repo = PluginsHelper::PLUGINS_JSON_REPO
107
+ UI.notice "Don't forget to create a Pull Request on #{repo}\n" \
108
+ ' to add your plugin to the plugins.json file once it is released!'
109
+ end
99
110
  end
100
111
  end
101
112
  end
@@ -1,4 +1,5 @@
1
1
  require 'pod/command/plugins_helper'
2
+ require 'pod/command/gem_helper'
2
3
 
3
4
  module Pod
4
5
  class Command
@@ -18,6 +19,7 @@ module Pod
18
19
 
19
20
  def run
20
21
  plugins = PluginsHelper.known_plugins
22
+ GemHelper.download_and_cache_specs if self.verbose?
21
23
 
22
24
  UI.title 'Available CocoaPods Plugins:' do
23
25
  plugins.each do |plugin|
@@ -1,4 +1,5 @@
1
1
  require 'pod/command/plugins_helper'
2
+ require 'pod/command/gem_helper'
2
3
 
3
4
  module Pod
4
5
  class Command
@@ -10,19 +11,19 @@ module Pod
10
11
  class Search < Plugins
11
12
  self.summary = 'Search for known plugins'
12
13
  self.description = <<-DESC
13
- Searches plugins whose name contains the given text
14
- (ignoring case).
14
+ Searches plugins whose 'name' contains the given `QUERY`.
15
+ `QUERY` is a regular expression, ignoring case.
15
16
 
16
- With --full, it also searches by author and description.
17
+ With `--full`, it also searches by 'author' and 'description'.
17
18
  DESC
18
19
 
19
20
  self.arguments = [
20
- ['QUERY', :required]
21
+ CLAide::Argument.new('QUERY', true),
21
22
  ]
22
23
 
23
24
  def self.options
24
25
  [
25
- ['--full', 'Search by name, author, and description']
26
+ ['--full', 'Search by name, author, and description'],
26
27
  ].concat(super.reject { |option, _| option == '--silent' })
27
28
  end
28
29
 
@@ -44,6 +45,7 @@ module Pod
44
45
 
45
46
  def run
46
47
  plugins = PluginsHelper.matching_plugins(@query, @full_text_search)
48
+ GemHelper.download_and_cache_specs if self.verbose?
47
49
 
48
50
  UI.title "Available CocoaPods Plugins matching '#{@query}':"
49
51
  plugins.each do |plugin|
@@ -1,3 +1,5 @@
1
+ require 'pod/command/gem_helper'
2
+
1
3
  module Pod
2
4
  class Command
3
5
  # This module is used by Command::Plugins::List
@@ -5,8 +7,12 @@ module Pod
5
7
  # the JSON describing the plugins list and manipulate it
6
8
  #
7
9
  module PluginsHelper
8
- PLUGINS_URL = 'https://raw.githubusercontent.com/CocoaPods/' \
9
- 'cocoapods.org/master/data/plugins.json'
10
+ PLUGINS_JSON_REPO_NAME = 'CocoaPods/cocoapods.org'
11
+ PLUGINS_JSON_REPO = 'https://github.com/' + PLUGINS_JSON_REPO_NAME
12
+ PLUGINS_JSON_REL_URL = '/master/plugins.json'
13
+
14
+ PLUGINS_RAW_URL = 'https://raw.githubusercontent.com/' \
15
+ + PLUGINS_JSON_REPO_NAME + PLUGINS_JSON_REL_URL
10
16
 
11
17
  # Force-download the JSON
12
18
  #
@@ -14,7 +20,7 @@ module Pod
14
20
  #
15
21
  def self.download_json
16
22
  UI.puts 'Downloading Plugins list...'
17
- response = REST.get(PLUGINS_URL)
23
+ response = REST.get(PLUGINS_RAW_URL)
18
24
  if response.ok?
19
25
  parse_json(response.body)
20
26
  else
@@ -56,22 +62,6 @@ module Pod
56
62
  end
57
63
  end
58
64
 
59
- # Tells if a gem is installed
60
- #
61
- # @param [String] gem_name
62
- # The name of the plugin gem to test
63
- #
64
- # @return [Bool] true if the gem is installed, false otherwise.
65
- #
66
- def self.gem_installed?(gem_name)
67
- if Gem::Specification.methods.include?(:find_all_by_name)
68
- Gem::Specification.find_all_by_name(gem_name).any?
69
- else
70
- # Fallback to Gem.available? for old versions of rubygems
71
- Gem.available?(gem_name)
72
- end
73
- end
74
-
75
65
  # Display information about a plugin
76
66
  #
77
67
  # @param [Hash] plugin
@@ -86,9 +76,10 @@ module Pod
86
76
 
87
77
  UI.title(plugin_colored_name, '', 1) do
88
78
  UI.puts_indented plugin['description']
89
- UI.labeled('Gem', plugin['gem'])
90
- UI.labeled('URL', plugin['url'])
91
- UI.labeled('Author', plugin['author']) if verbose
79
+ ljust = verbose ? 16 : 11
80
+ UI.labeled('Gem', plugin['gem'], ljust)
81
+ UI.labeled('URL', plugin['url'], ljust)
82
+ print_verbose_plugin(plugin, ljust) if verbose
92
83
  end
93
84
  end
94
85
 
@@ -96,6 +87,23 @@ module Pod
96
87
 
97
88
  private
98
89
 
90
+ # Smaller helper to print out the verbose details
91
+ # for a plugin.
92
+ #
93
+ # @param [Hash] plugin
94
+ # The hash describing the plugin
95
+ #
96
+ # @param [Integer] ljust
97
+ # The left justification that is passed into UI.labeled
98
+ #
99
+ def self.print_verbose_plugin(plugin, ljust)
100
+ UI.labeled('Author', plugin['author'], ljust)
101
+ unless GemHelper.cache.specs.empty?
102
+ versions = GemHelper.versions_string(plugin['gem'])
103
+ UI.labeled('Versions', versions, ljust)
104
+ end
105
+ end
106
+
99
107
  # Parse the given JSON data, handling parsing errors if any
100
108
  #
101
109
  # @param [String] json_str
@@ -117,7 +125,8 @@ module Pod
117
125
  #
118
126
  def self.plugin_title(plugin)
119
127
  plugin_name = "-> #{plugin['name']}"
120
- if gem_installed?(plugin['gem'])
128
+ if GemHelper.gem_installed?(plugin['gem'])
129
+ plugin_name += " (#{GemHelper.installed_version(plugin['gem'])})"
121
130
  plugin_name.green
122
131
  else
123
132
  plugin_name.yellow
@@ -0,0 +1,40 @@
1
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
+
3
+ # The CocoaPods namespace
4
+ #
5
+ module Pod
6
+ describe Command::GemHelper do
7
+ before do
8
+ UI.output = ''
9
+ end
10
+
11
+ after do
12
+ mocha_teardown
13
+ end
14
+
15
+ it 'detects if a gem is installed' do
16
+ Command::GemHelper.gem_installed?('bacon').should.be.true
17
+ Command::GemHelper.gem_installed?('fake-fake-fake-gem').should.be.false
18
+ end
19
+
20
+ it 'detects if a specific version of a gem is installed' do
21
+ Command::GemHelper.gem_installed?('bacon', Bacon::VERSION).should.be.true
22
+ impossibacon = Gem::Version.new(Bacon::VERSION).bump
23
+ Command::GemHelper.gem_installed?('bacon', impossibacon).should.be.false
24
+ end
25
+
26
+ it 'creates a version list that includes all versions of a single gem' do
27
+ spec2 = Gem::NameTuple.new('cocoapods-plugins', Gem::Version.new('0.2.0'))
28
+ spec1 = Gem::NameTuple.new('cocoapods-plugins', Gem::Version.new('0.1.0'))
29
+ response = [{ 1 => [spec2, spec1] }, []]
30
+ Gem::SpecFetcher.any_instance.stubs(:available_specs).returns(response)
31
+
32
+ @cache = Command::GemIndexCache.new
33
+ @cache.download_and_cache_specs
34
+ versions_string =
35
+ Command::GemHelper.versions_string('cocoapods-plugins', @cache)
36
+ versions_string.should.include('0.2.0')
37
+ versions_string.should.include('0.1.0')
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
+
3
+ # The CocoaPods namespace
4
+ #
5
+ module Pod
6
+ describe Command::GemIndexCache do
7
+
8
+ before do
9
+ @cache = Command::GemIndexCache.new
10
+ UI.output = ''
11
+ end
12
+
13
+ after do
14
+ mocha_teardown
15
+ end
16
+
17
+ it 'notifies the user that it is downloading the spec index' do
18
+ response = [{}, []]
19
+ Gem::SpecFetcher.any_instance.stubs(:available_specs).returns(response)
20
+
21
+ @cache.download_and_cache_specs
22
+ UI.output.should.include('Downloading Rubygem specification index...')
23
+ UI.output.should.not.include('Error downloading Rubygem specification')
24
+ end
25
+
26
+ it 'notifies the user when getting the spec index fails' do
27
+ error = Gem::RemoteFetcher::UnknownHostError.new('no host', 'bad url')
28
+ wrapper_error = stub(:error => error)
29
+ response = [[], [wrapper_error]]
30
+ Gem::SpecFetcher.any_instance.stubs(:available_specs).returns(response)
31
+
32
+ @cache.download_and_cache_specs
33
+ @cache.specs.should.be.empty?
34
+ UI.output.should.include('Downloading Rubygem specification index...')
35
+ UI.output.should.include('Error downloading Rubygem specification')
36
+ end
37
+
38
+ end
39
+ end
@@ -12,8 +12,8 @@ module Pod
12
12
  end
13
13
 
14
14
  it 'registers itself' do
15
- Command.parse(%w(plugins create))
16
- .should.be.instance_of Command::Plugins::Create
15
+ Command.parse(%w(plugins create)).
16
+ should.be.instance_of Command::Plugins::Create
17
17
  end
18
18
 
19
19
  #--- Validation
@@ -12,8 +12,8 @@ module Pod
12
12
  end
13
13
 
14
14
  it 'registers itself' do
15
- Command.parse(%w(plugins list))
16
- .should.be.instance_of Command::Plugins::List
15
+ Command.parse(%w(plugins list)).
16
+ should.be.instance_of Command::Plugins::List
17
17
  end
18
18
 
19
19
  #--- Output printing
@@ -12,8 +12,8 @@ module Pod
12
12
  end
13
13
 
14
14
  it 'registers itself' do
15
- Command.parse(%w(plugins search))
16
- .should.be.instance_of Command::Plugins::Search
15
+ Command.parse(%w(plugins search)).
16
+ should.be.instance_of Command::Plugins::Search
17
17
  end
18
18
 
19
19
  #--- Validation
@@ -10,7 +10,7 @@ module Pod
10
10
  stub_plugins_json_request
11
11
  json = Command::PluginsHelper.download_json
12
12
  json.should.not.be.nil?
13
- json.should.be.kind_of? Hash
13
+ json.should.be.is_a? Hash
14
14
  json['plugins'].size.should.eql? 3
15
15
  end
16
16
 
@@ -30,10 +30,5 @@ module Pod
30
30
  end.message.should.match(expected_error)
31
31
  end
32
32
 
33
- it 'detects if a gem is installed' do
34
- Helper = Command::PluginsHelper
35
- Helper.gem_installed?('bacon').should.be.true
36
- Helper.gem_installed?('fake-fake-fake-gem').should.be.false
37
- end
38
33
  end
39
34
  end
@@ -1,20 +1,15 @@
1
1
  # Set up coverage analysis
2
2
  #-----------------------------------------------------------------------------#
3
- if ENV['CI'] || ENV['GENERATE_COVERAGE']
4
- require 'simplecov'
5
- require 'coveralls'
6
-
7
- if ENV['CI']
8
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
9
- elsif ENV['GENERATE_COVERAGE']
10
- SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
11
- end
12
- SimpleCov.start do
13
- add_filter '/travis_bundle_dir'
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
14
8
  end
9
+ CodeClimate::TestReporter.start
15
10
  end
16
11
 
17
- # General Setup
12
+ # Set up
18
13
  #-----------------------------------------------------------------------------#
19
14
 
20
15
  require 'pathname'
@@ -33,6 +28,16 @@ include WebMock::API
33
28
  require 'cocoapods'
34
29
  require 'cocoapods_plugin'
35
30
 
31
+ # VCR
32
+ #--------------------------------------#
33
+
34
+ require 'vcr'
35
+ VCR.configure do |c|
36
+ c.cassette_library_dir = ROOT + 'spec/fixtures/vcr_cassettes'
37
+ c.hook_into :webmock
38
+ c.ignore_hosts 'codeclimate.com'
39
+ end
40
+
36
41
  #-----------------------------------------------------------------------------#
37
42
 
38
43
  # The CocoaPods namespace
@@ -92,8 +97,8 @@ module SpecHelper
92
97
  module PluginsStubs
93
98
  def stub_plugins_json_request(json = nil, status = 200)
94
99
  body = json || File.read(fixture('plugins.json'))
95
- stub_request(:get, Pod::Command::PluginsHelper::PLUGINS_URL)
96
- .to_return(:status => status, :body => body, :headers => {})
100
+ stub_request(:get, Pod::Command::PluginsHelper::PLUGINS_RAW_URL).
101
+ to_return(:status => status, :body => body, :headers => {})
97
102
  end
98
103
  end
99
104
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Grandinetti
@@ -9,48 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-20 00:00:00.000000000 Z
12
+ date: 2014-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nap
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
34
  version: '1.3'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.3'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  description: |2
@@ -63,10 +63,10 @@ executables: []
63
63
  extensions: []
64
64
  extra_rdoc_files: []
65
65
  files:
66
- - ".gitignore"
67
- - ".rubocop-cocoapods.yml"
68
- - ".rubocop.yml"
69
- - ".travis.yml"
66
+ - .gitignore
67
+ - .rubocop.yml
68
+ - .rubocop_cocoapods.yml
69
+ - .travis.yml
70
70
  - CHANGELOG.md
71
71
  - Gemfile
72
72
  - Gemfile.lock
@@ -76,11 +76,15 @@ files:
76
76
  - cocoapods-plugins.gemspec
77
77
  - lib/cocoapods_plugin.rb
78
78
  - lib/cocoapods_plugins.rb
79
+ - lib/pod/command/gem_helper.rb
80
+ - lib/pod/command/gem_index_cache.rb
79
81
  - lib/pod/command/plugins.rb
80
82
  - lib/pod/command/plugins/create.rb
81
83
  - lib/pod/command/plugins/list.rb
82
84
  - lib/pod/command/plugins/search.rb
83
85
  - lib/pod/command/plugins_helper.rb
86
+ - spec/command/gem_helper_spec.rb
87
+ - spec/command/gem_index_cache_spec.rb
84
88
  - spec/command/plugins/create_spec.rb
85
89
  - spec/command/plugins/list_spec.rb
86
90
  - spec/command/plugins/search_spec.rb
@@ -98,21 +102,23 @@ require_paths:
98
102
  - lib
99
103
  required_ruby_version: !ruby/object:Gem::Requirement
100
104
  requirements:
101
- - - ">="
105
+ - - '>='
102
106
  - !ruby/object:Gem::Version
103
107
  version: '0'
104
108
  required_rubygems_version: !ruby/object:Gem::Requirement
105
109
  requirements:
106
- - - ">="
110
+ - - '>='
107
111
  - !ruby/object:Gem::Version
108
112
  version: '0'
109
113
  requirements: []
110
114
  rubyforge_project:
111
- rubygems_version: 2.2.2
115
+ rubygems_version: 2.0.14
112
116
  signing_key:
113
117
  specification_version: 4
114
118
  summary: CocoaPods plugin which shows info about available CocoaPods plugins.
115
119
  test_files:
120
+ - spec/command/gem_helper_spec.rb
121
+ - spec/command/gem_index_cache_spec.rb
116
122
  - spec/command/plugins/create_spec.rb
117
123
  - spec/command/plugins/list_spec.rb
118
124
  - spec/command/plugins/search_spec.rb