cocoapods-schoutedenapus 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: 51b97c9d41dd712489e1aee8794c5ded2a390e04
4
+ data.tar.gz: c8666c8030ba27a9e63999a779f9fe1e1a5615ac
5
+ SHA512:
6
+ metadata.gz: 19da82bf3488c6c3c49b9698c89b0bd7169e476ff8cb092cd3b5ee919ad1a733bf623186d9e25371a7d98e75898268a3acd6dc68c38b195fc46a0aa7c15f80fb
7
+ data.tar.gz: 0bce5d16d51f7eee982485d7f348c2204ece13db4852f20ae42164d0ee8dbfe540b4c539792e1ecd65d727c9ed19b8d57e1eb317448ceaa6b44a70cf38ba88d6
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ osx_image: xcode7.1
2
+ language: objective-c
3
+ cache: bundler
4
+ before_install:
5
+ - bundle install
6
+ - bundle exec pod repo update --silent
7
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'cocoapods'
7
+
8
+ gem 'mocha'
9
+ gem 'bacon'
10
+ gem 'mocha-on-bacon'
11
+ gem 'prettybacon'
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Boris Bügling <boris@icculus.org>
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,25 @@
1
+ # Schoutedenapus
2
+
3
+ Generate Swift packages from podspecs.
4
+
5
+ Looking for the reverse conversion? => [Chocolat][1]
6
+
7
+ ## Usage
8
+
9
+ Running
10
+
11
+ $ pod lib schoutedenapus POD_SPEC
12
+
13
+ will generate a new `Package.swift` in the current directory.
14
+
15
+ As of right now, Schoutedenapus will only pick up the name and dependencies
16
+ from the original podspec, you will have to manually move your source files
17
+ into a directory structure that works with SPM.
18
+
19
+ ## Installation
20
+
21
+ Schoutedenapus is a CocoaPods plugin distributed as RubyGem:
22
+
23
+ $ gem install cocoapods-schoutedenapus
24
+
25
+ [1]: https://github.com/neonichu/Chocolat
data/Rakefile ADDED
@@ -0,0 +1,12 @@
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
@@ -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-schoutedenapus/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-schoutedenapus'
8
+ spec.version = CocoapodsSchoutedenapus::VERSION
9
+ spec.authors = ['Boris Bügling']
10
+ spec.email = ['boris@icculus.org']
11
+ spec.summary = 'Generate Swift packages from podspecs.'
12
+ spec.homepage = 'https://github.com/neonichu/Schoutedenapus'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_development_dependency 'rake'
22
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-schoutedenapus/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-schoutedenapus/command/schoutedenapus'
@@ -0,0 +1,45 @@
1
+ require 'cocoapods-schoutedenapus/converter'
2
+
3
+ module Pod
4
+ class Command
5
+ class Lib
6
+ class Schoutedenapus < Lib
7
+ self.summary = 'Generate Swift packages from podspecs.'
8
+
9
+ self.arguments = [ CLAide::Argument.new('PODSPEC', true) ]
10
+
11
+ def initialize(argv)
12
+ @spec = spec_with_path(argv.shift_argument)
13
+ super
14
+ end
15
+
16
+ def validate!
17
+ super
18
+ help! 'A podspec is required.' unless @spec
19
+ end
20
+
21
+ def run
22
+ File.write('Package.swift', ::Schoutedenapus::Converter.new(@spec).to_s)
23
+ end
24
+
25
+ private
26
+
27
+ def spec_with_path(path)
28
+ return if path.nil? || !Pathname.new(path).exist?
29
+
30
+ if Pathname.new(path).directory?
31
+ help! path + ': is a directory.'
32
+ return
33
+ end
34
+
35
+ unless ['.podspec', '.json'].include? Pathname.new(path).extname
36
+ help! path + ': is not a podspec.'
37
+ return
38
+ end
39
+
40
+ Specification.from_file(path)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,42 @@
1
+ module Schoutedenapus
2
+ class Converter
3
+ def initialize(spec)
4
+ @spec = spec
5
+ end
6
+
7
+ def to_s
8
+ return <<-EOF
9
+ import PackageDescription
10
+
11
+ let package = Package(
12
+ \tname: "#{@spec.name}"#{dependencies}
13
+ )
14
+ EOF
15
+ end
16
+
17
+ private
18
+
19
+ def dependency_to_package(dep)
20
+ set = Pod::SourcesManager.search(dep)
21
+ Pod::Command::help! "Could not find pod '#{dep.name}'" if set.nil?
22
+ url = set.specification.source[:git]
23
+ # FIXME: Should use the lowest matching version
24
+ major = set.versions.first.major
25
+ minor = set.versions.first.minor
26
+ "\t\t.Package(url: \"#{url}\", majorVersion: #{major}, minor: #{minor}),"
27
+ end
28
+
29
+ def dependencies
30
+ return '' if @spec.dependencies.count == 0
31
+
32
+ deps = @spec.dependencies.map { |dep| dependency_to_package(dep) }.join("\n")
33
+ dependencies = <<-EOF
34
+ ,
35
+ \tdependencies: [
36
+ #{deps}
37
+ \t]
38
+ EOF
39
+ dependencies.rstrip!
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsSchoutedenapus
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-schoutedenapus/command'
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Lib::Schoutedenapus do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w( lib schoutedenapus )).should.be.instance_of Command::Lib::Schoutedenapus
8
+ end
9
+
10
+ it 'parses a given spec' do
11
+ cmd = Command.parse(%w( lib schoutedenapus spec/fixtures/Stencil.podspec.json ))
12
+ cmd.validate!
13
+
14
+ cmd.instance_variable_get('@spec').name.should == 'Stencil'
15
+ end
16
+
17
+ it 'generates a Package.swift file' do
18
+ cmd = Command.parse(%w( lib schoutedenapus spec/fixtures/Stencil.podspec.json ))
19
+ cmd.run
20
+
21
+ FileUtils.compare_file('spec/fixtures/Package.swift', 'Package.swift').should == true
22
+ FileUtils.rm_f('Package.swift')
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Schoutedenapus
4
+ describe Converter do
5
+ describe 'Conversion' do
6
+ it 'can convert a podspec' do
7
+ fixture = File.new('spec/fixtures/Package.swift').read()
8
+ spec = Pod::Specification.from_file('spec/fixtures/Stencil.podspec.json')
9
+
10
+ actual = Converter.new(spec).to_s
11
+
12
+ actual.should == fixture
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ import PackageDescription
2
+
3
+ let package = Package(
4
+ name: "Stencil",
5
+ dependencies: [
6
+ .Package(url: "https://github.com/kylef/PathKit.git", majorVersion: 0, minor: 5),
7
+ ]
8
+ )
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "Stencil",
3
+ "version": "0.4.0",
4
+ "summary": "Stencil is a simple and powerful template language for Swift.",
5
+ "homepage": "https://github.com/kylef/Stencil",
6
+ "license": {
7
+ "type": "BSD",
8
+ "file": "LICENSE"
9
+ },
10
+ "authors": {
11
+ "Kyle Fuller": "inbox@kylefuller.co.uk"
12
+ },
13
+ "social_media_url": "http://twitter.com/kylefuller",
14
+ "source": {
15
+ "git": "https://github.com/kylef/Stencil.git",
16
+ "tag": "0.4.0"
17
+ },
18
+ "source_files": [
19
+ "Sources/*.swift",
20
+ "Sources/TemplateLoader/*.swift"
21
+ ],
22
+ "platforms": {
23
+ "ios": "8.0",
24
+ "osx": "10.9"
25
+ },
26
+ "requires_arc": true,
27
+ "dependencies": {
28
+ "PathKit": [ "~> 0.5.0" ]
29
+ },
30
+ "test_specification": {
31
+ "source_files": [
32
+ "Tests/*.swift",
33
+ "Tests/TemplateLoader/*.swift",
34
+ "Tests/Nodes/*.swift"
35
+ ],
36
+ "dependencies": {
37
+ "Spectre": [ "~> 0.5.0" ],
38
+ "PathKit": [ "~> 0.5.0" ]
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,49 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.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
+ # Disable the wrapping so the output is deterministic in the tests.
21
+ #
22
+ UI.disable_wrap = true
23
+
24
+ # Redirects the messages to an internal store.
25
+ #
26
+ module UI
27
+ @output = ''
28
+ @warnings = ''
29
+
30
+ class << self
31
+ attr_accessor :output
32
+ attr_accessor :warnings
33
+
34
+ def puts(message = '')
35
+ @output << "#{message}\n"
36
+ end
37
+
38
+ def warn(message = '', _actions = [])
39
+ @warnings << "#{message}\n"
40
+ end
41
+
42
+ def print(message)
43
+ @output << message
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-schoutedenapus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Boris Bügling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-08 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
+ - boris@icculus.org
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-schoutedenapus.gemspec
55
+ - lib/cocoapods-schoutedenapus.rb
56
+ - lib/cocoapods-schoutedenapus/command.rb
57
+ - lib/cocoapods-schoutedenapus/command/schoutedenapus.rb
58
+ - lib/cocoapods-schoutedenapus/converter.rb
59
+ - lib/cocoapods-schoutedenapus/gem_version.rb
60
+ - lib/cocoapods_plugin.rb
61
+ - spec/command/schoutedenapus_spec.rb
62
+ - spec/converter_spec.rb
63
+ - spec/fixtures/Package.swift
64
+ - spec/fixtures/Stencil.podspec.json
65
+ - spec/spec_helper.rb
66
+ homepage: https://github.com/neonichu/Schoutedenapus
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.0.14
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Generate Swift packages from podspecs.
90
+ test_files:
91
+ - spec/command/schoutedenapus_spec.rb
92
+ - spec/converter_spec.rb
93
+ - spec/fixtures/Package.swift
94
+ - spec/fixtures/Stencil.podspec.json
95
+ - spec/spec_helper.rb
96
+ has_rdoc: