cocoapods-uploader 0.0.1

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: 56d37f19929d427ba4f13996b09d14ae0782fba3
4
+ data.tar.gz: fd4d3fc9ccd591d0d9eee822110b2474aefe02cf
5
+ SHA512:
6
+ metadata.gz: 475771f351b91e5dab804b3f6027761ba6c663ff305ca859d21d41287d4040a3b026803ab54bfab9711edbde9bcd109341483ddbc6a3ea6a2c3aa54856a5586d
7
+ data.tar.gz: 7b77905760bc4ef020acb241737ab74423199e45039832e876ff30141e409ea04b7db4c3b8bd1a4b49074a9f720b7b6d0c6134aa217bf23f04d17600510efcb9
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-uploader.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Alibaba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cocoapods-uploader
2
+ cocoapods-uploader is a tool that help upload file/dir to remote repository.
3
+
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-uploader
8
+
9
+ ## Usage
10
+
11
+ - setting
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,53 @@
1
+ require 'yaml'
2
+
3
+ module Pod
4
+ class Setting
5
+ attr_accessor :host, :repo, :user, :password, :suffix
6
+
7
+ def initialize(parameters={})
8
+ parameters = {'suffix'=>"/artifactory/service/local/repositories/+repo+/content/"}.merge(parameters)
9
+ @host = parameters['host']
10
+ @repo = parameters['repo']
11
+ @user = parameters['user']
12
+ @password = parameters['password']
13
+ @suffix = parameters['suffix']
14
+ end
15
+
16
+ def open
17
+ path = "#{Pod::Config.instance.home_dir}/maven.yml"
18
+ if File.exist?(path)
19
+ config = YAML.load_file(path)
20
+ @host = config['host']
21
+ @repo = config['repo']
22
+ @user = config['user']
23
+ @password = config['password']
24
+ @suffix = config['suffix']
25
+ end
26
+ end
27
+
28
+ def save
29
+ path = "#{Pod::Config.instance.home_dir}/maven.yml"
30
+
31
+ File.open(path, "w+") do |file|
32
+ config = {'host'=>host,'repo'=>repo,'user'=>user,'password'=>password,'suffix'=>suffix}
33
+ file.puts(config.to_yaml)
34
+ end
35
+ end
36
+
37
+ def to_hash
38
+ hash = {}
39
+ hash['host'] = host
40
+ hash['repo'] = repo
41
+ hash['user'] = user
42
+ hash['password'] = password
43
+ hash['suffix'] = suffix
44
+ hash
45
+ end
46
+
47
+ def == other
48
+ to_hash == other.to_hash
49
+ end
50
+
51
+
52
+ end
53
+ end
@@ -0,0 +1,95 @@
1
+ require 'cocoapods-uploader/command/maven/config'
2
+ require 'rest-client'
3
+ require 'zip'
4
+ require 'fileutils'
5
+
6
+ module Pod
7
+ class Command
8
+ class Maven < Upload
9
+ self.summary = 'Upload file/dir to remote maven repository.'
10
+
11
+ self.description = <<-DESC
12
+ Upload file/dir to remote maven repository.
13
+ DESC
14
+
15
+ self.arguments = [
16
+ CLAide::Argument.new('PATH', true),
17
+ CLAide::Argument.new('SPEC', true)
18
+ ]
19
+
20
+ def initialize(argv)
21
+ @path = argv.shift_argument
22
+ @spec = argv.shift_argument
23
+ super
24
+ end
25
+
26
+ def validate!
27
+ super
28
+ help! 'path & spec is required.' unless @path && @spec
29
+ end
30
+
31
+ def run
32
+ version = Specification.from_file(@spec).version
33
+ name = Specification.from_file(@spec).name
34
+
35
+ file_name = "#{name}.gz"
36
+ compress_file(@path,file_name)
37
+
38
+ setting = Pod::Setting.new
39
+ setting.open
40
+
41
+ url = "#{setting.host}#{setting.suffix.gsub('+repo+',setting.repo)}/#{name.downcase}/#{name.downcase}/#{version}/#{file_name.downcase}"
42
+ puts "Upload url: #{url}"
43
+ RestClient::Resource.new(url, :user => "#{setting.user}", :password => "#{setting.password}").post(:file => File.new(file_name.downcase)).code
44
+
45
+ end
46
+
47
+
48
+ private
49
+
50
+ def compress_file(path,file_name)
51
+ file = "./#{file_name}"
52
+ if Pod::Config.instance.verbose?
53
+ puts "Compress File #{file}"
54
+ end
55
+ if File.exist?(file)
56
+ FileUtils.rm(file)
57
+ end
58
+ entries = [path]#Dir.entries(path) - %w(. ..)
59
+ Zip::File.open(file, ::Zip::File::CREATE) do |io|
60
+ write_entries entries, '', io
61
+ end
62
+ end
63
+
64
+ def write_entries(entries, inpath, io)
65
+ entries.each do |e|
66
+ entry_path = inpath == '' ? e : File.join(inpath, e)
67
+ zip_path = File.join('.', entry_path)
68
+
69
+ if Pod::Config.instance.verbose?
70
+ puts "Deflating #{zip_path}"
71
+ end
72
+
73
+ if File.directory? zip_path
74
+ recursively_deflate_directory(zip_path, io, entry_path)
75
+ else
76
+ put_into_archive(zip_path, io, entry_path)
77
+ end
78
+ end
79
+ end
80
+
81
+ def recursively_deflate_directory(zip_path, io, entry_path)
82
+ io.mkdir entry_path
83
+ subdir = Dir.entries(zip_path) - %w(. ..)
84
+ write_entries subdir, entry_path, io
85
+ end
86
+
87
+ def put_into_archive(zip_path, io, entry_path)
88
+ io.get_output_stream(entry_path) do |f|
89
+ f.puts(File.open(zip_path, 'rb').read)
90
+ end
91
+ end
92
+
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,40 @@
1
+ require 'cocoapods-uploader/command/maven/maven'
2
+ module Pod
3
+ class Command
4
+ class Set < Maven
5
+ self.summary = 'Setting remote maven repository.'
6
+
7
+ self.description = <<-DESC
8
+ Setting remote maven repository.
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('HOST', true),
13
+ CLAide::Argument.new('REPO', true),
14
+ CLAide::Argument.new('USER', false),
15
+ CLAide::Argument.new('PASSWORD', false),
16
+ CLAide::Argument.new('SUFFIX', false)
17
+ ]
18
+
19
+ def initialize(argv)
20
+ @host = argv.shift_argument
21
+ @repo = argv.shift_argument
22
+ @user = argv.shift_argument
23
+ @password = argv.shift_argument
24
+ @suffix = argv.shift_argument
25
+ super
26
+ end
27
+
28
+ def validate!
29
+ # super
30
+ help! 'host & repo is required.' unless @host && @repo
31
+ end
32
+
33
+ def run
34
+ config = Pod::Setting.new('user'=>@user,'password'=> @password,'host'=>@host,'repo'=>@repo,'suffix'=>@suffix)
35
+ config.save
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,21 @@
1
+
2
+ module Pod
3
+ class Command
4
+ class Upload < Command
5
+
6
+ require 'cocoapods-uploader/command/maven/maven'
7
+ require 'cocoapods-uploader/command/maven/set'
8
+
9
+ self.abstract_command = true
10
+
11
+ self.summary = 'Upload file/dir to remote storage.'
12
+
13
+ self.description = <<-DESC
14
+ Upload file/dir to remote storage.
15
+ DESC
16
+
17
+ self.default_subcommand = 'maven'
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-uploader/command/upload'
@@ -0,0 +1,3 @@
1
+ module CocoapodsUploader
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-uploader/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-uploader/command'
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-uploader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - supern_lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyzip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Upload file/dir to remote storage.
70
+ email:
71
+ - supern.lee@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - Gemfile
77
+ - LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - lib/cocoapods-uploader.rb
81
+ - lib/cocoapods-uploader/command.rb
82
+ - lib/cocoapods-uploader/command/maven/config.rb
83
+ - lib/cocoapods-uploader/command/maven/maven.rb
84
+ - lib/cocoapods-uploader/command/maven/set.rb
85
+ - lib/cocoapods-uploader/command/upload.rb
86
+ - lib/cocoapods-uploader/gem_version.rb
87
+ - lib/cocoapods_plugin.rb
88
+ homepage: https://github.com/alibaba/cocoapods-uploader
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.6.6
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Upload file/dir to remote storage.
112
+ test_files: []