cocoapods-lazy 0.2.2 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d772616c122ea26de244839e7dd24d7cbf5accc
4
- data.tar.gz: cbc468c4cb629fcc910cfe3d2d40d19116fca1ba
3
+ metadata.gz: 65d3ec7903729f223055ef69069f95b9ca310c14
4
+ data.tar.gz: 1ef030dac21fdc14cddd566344a7aeaf693d3218
5
5
  SHA512:
6
- metadata.gz: 6ed1e5e47ea83776baaa152263b08f9162e9090ee4d21de4da7938e43a47f6aad086553310808fac51eed3ebf116cd036b39a16a5e29331e0e88f3910c73e344
7
- data.tar.gz: 3cb70ea06bd75b055bee357112c85ba8ba5e361f976b5e1a5164b0a662d3034026c1dc98e888ac0bad2587a364d0a3f49d915dfb7277d3933b92f65800d8f58e
6
+ metadata.gz: 8d0f16974e0e07e0475e65319bd467cd1aa54945d0b9fbe90cee55968a40ae4ecd5b691bf1456b0174b24c54b79758bcba7cb87da53c449698b7a4ca37f146a3
7
+ data.tar.gz: 485e3a01b3ebf6523f4bbe89a2d40ebb67810860297f231724bee71f88f90d59bbcdeae88d00a927cf309c8d32b2d7edda9ad186db7fd61cd17881c00371aa0c
@@ -1,16 +1,45 @@
1
1
  require 'cocoapods'
2
- require 'cocoapods-lazy/credential'
2
+ require 'cocoapods-lazy/logger'
3
3
 
4
4
  module Pod
5
5
  class Podfile
6
6
  module DSL
7
- class Credential
8
- attr_accessor :login
9
- attr_accessor :password
7
+ class Config
10
8
  attr_accessor :base_url
11
9
 
12
- def is_valid?
13
- return login != nil && password != nil && base_url != nil
10
+ def validate
11
+ raise 'Write base_url for continue' if base_url == nil
12
+ end
13
+
14
+ def login
15
+ return @login unless @login.nil?
16
+ Logger.important_i "Write login from #{@base_url}"
17
+ Logger.important "Write login from #{@base_url}"
18
+ @login = $stdin.gets
19
+ return @login
20
+ end
21
+
22
+ def login=(login)
23
+ @login = Shellwords.escape(login) unless login.blank?
24
+ end
25
+
26
+ def password
27
+ return @password unless @password.nil?
28
+ Logger.important_i "Write password from #{@base_url}"
29
+ Logger.important "Write password from #{@base_url}"
30
+ @password = Shellwords.escape $stdin.gets.chomp
31
+ return @password
32
+ end
33
+
34
+ def password=(password)
35
+ @password = Shellwords.escape(password) unless password.blank?
36
+ end
37
+
38
+ def to_s
39
+ descriptor = ""
40
+ descriptor += "login = #{@login}\n" unless @login.nil?
41
+ descriptor += "password = *****\n" unless @password.nil?
42
+ descriptor += "base_url = #{@base_url}"
14
43
  end
15
44
  end
16
45
  end
@@ -20,13 +49,13 @@ end
20
49
  module Pod
21
50
  class Podfile
22
51
  module DSL
23
- class_attr_accessor :credential
52
+ class_attr_accessor :config
24
53
 
25
- def pods_storage_credential(&block)
26
- credential = Credential.new()
27
- block.call(credential)
28
- raise unless credential.is_valid?
29
- DSL.credential = Pod::Lazy::Credential.new(credential.login, credential.password, credential.base_url)
54
+ def cocoapods_lazy(&block)
55
+ config = Config.new()
56
+ block.call(config)
57
+ config.validate
58
+ DSL.config = config
30
59
  end
31
60
  end
32
61
  end
@@ -0,0 +1,15 @@
1
+ module Pod
2
+ module Lazy
3
+ class Logger
4
+ def self.info(value)
5
+ UI.puts "#### #{value}".ansi.blue
6
+ end
7
+
8
+ def self.important(value)
9
+ UI.puts "#### #{value}".ansi.magenta
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ Logger = Pod::Lazy::Logger
@@ -1,10 +1,10 @@
1
1
  require 'cocoapods'
2
+ require 'cocoapods-core/podfile'
2
3
  require 'cocoapods-lazy/version'
3
- require 'cocoapods-lazy/log'
4
+ require 'cocoapods-lazy/logger'
4
5
  require 'cocoapods-lazy/repository'
5
6
  require 'cocoapods-lazy/remote_storage'
6
7
  require 'cocoapods-lazy/dsl'
7
- require 'cocoapods-core/podfile'
8
8
 
9
9
  module Pod
10
10
  module Lazy
@@ -15,32 +15,28 @@ module Pod
15
15
  end
16
16
 
17
17
  def run
18
- puts "Redirection to cocoapods-lazy"
19
- credential = load_credential()
20
- unless credential.nil?
21
- puts "cocoapods-lazy is enabled in Podfile"
22
- puts "Credentials:\n#{credential}"
23
- remote_storage = Pod::Lazy::RemoteStorage.new(credential)
18
+ Logger.info "Redirection to cocoapods-lazy"
19
+ lazy_config = load_credential()
20
+ unless lazy_config.nil?
21
+ Logger.info "cocoapods-lazy is enabled in Podfile"
22
+ Logger.info "Lazy config:\n#{lazy_config}"
23
+ remote_storage = Pod::Lazy::RemoteStorage.new(lazy_config)
24
24
  repository = Pod::Lazy::Repository.new(remote_storage)
25
25
  repository.fetch() if @should_fetch
26
- puts "Run origin command"
26
+ Logger.info "Run origin command"
27
27
  super
28
28
  if repository.should_store && @should_store
29
- puts "Storing..."
29
+ Logger.info "Storing..."
30
30
  repository.store()
31
31
  end
32
- puts "Flow cocoapods-lazy if finished"
32
+ Logger.info "Flow cocoapods-lazy if finished"
33
33
  else
34
- puts "cocoapods-lazy is not enabled in Podfile"
35
- puts "Run origin command"
34
+ Logger.info "cocoapods-lazy is not enabled in Podfile"
35
+ Logger.info "Run origin command"
36
36
  super
37
37
  end
38
38
  end
39
39
 
40
- def puts(value)
41
- Pod::Lazy::Log.puts(value)
42
- end
43
-
44
40
  def options
45
41
  [
46
42
  ['--no-fetch', 'Skip fetch action'],
@@ -53,7 +49,7 @@ module Pod
53
49
  def load_credential
54
50
  path = Pathname.new('Podfile')
55
51
  Podfile.from_file(path)
56
- Pod::Podfile::DSL.credential
52
+ Pod::Podfile::DSL.config
57
53
  end
58
54
  end
59
55
  end
@@ -1,20 +1,16 @@
1
- require 'cocoapods-lazy/log'
1
+ require 'cocoapods-lazy/logger'
2
2
 
3
3
  module Pod
4
4
  module Lazy
5
5
  class RemoteStorage
6
- include Pod::Lazy::Log
7
-
8
- def initialize(credential)
9
- @login = credential.login
10
- @password = credential.password
11
- @base_url = credential.base_url
6
+ def initialize(config)
7
+ @config = config
12
8
  end
13
9
 
14
10
  def fetch(name:)
15
11
  zip_name = "#{name}.zip"
16
- url = @base_url + zip_name
17
- puts `curl --fail -v -u #{@login}:#{@password} #{url} --output #{zip_name}`
12
+ url = @config.base_url + zip_name
13
+ `curl --fail #{url} --output #{zip_name}`
18
14
  `unzip #{zip_name}`
19
15
  `rm -rf #{zip_name}`
20
16
  end
@@ -22,13 +18,13 @@ module Pod
22
18
  def store(name:)
23
19
  zip_name = "#{name}.zip"
24
20
  unless File.exist?(zip_name)
25
- puts "Make zip: #{zip_name}"
21
+ Logger.info "Make zip: #{zip_name}"
26
22
  `zip -9 -r -y #{zip_name} Pods`
27
23
  end
28
- url = @base_url + zip_name
29
- puts "Storing to #{url}"
30
- `curl --fail -v -u #{@login}:#{@password} --upload-file #{zip_name} #{url}`
31
- puts "Remove #{zip_name}"
24
+ url = @config.base_url + zip_name
25
+ Logger.info "Storing to #{url}"
26
+ `curl --fail -u #{@config.login}:#{@config.password} --upload-file #{zip_name} #{url}`
27
+ Logger.info "Remove #{zip_name}"
32
28
  `rm -rf #{zip_name}`
33
29
  end
34
30
  end
@@ -1,12 +1,10 @@
1
1
  require 'cocoapods-core'
2
2
  require 'fileutils'
3
- require 'cocoapods-lazy/log'
3
+ require 'cocoapods-lazy/logger'
4
4
 
5
5
  module Pod
6
6
  module Lazy
7
7
  class Repository
8
- include Pod::Lazy::Log
9
-
10
8
  def initialize(repository)
11
9
  @repository = repository
12
10
  end
@@ -14,16 +12,16 @@ module Pod
14
12
  def fetch
15
13
  @fetched_checksum = read_podfile_checksum()
16
14
  if @fetched_checksum.nil?
17
- puts "Podfile.lock not found"
15
+ Logger.info "Podfile.lock not found"
18
16
  @is_generated_pods = true
19
17
  elsif @fetched_checksum != read_manifest_checksum()
20
- puts 'Checksum IS NOT EQUAL'
21
- puts 'Drop Pods directory'
18
+ Logger.info 'Checksum IS NOT EQUAL'
19
+ Logger.info 'Drop Pods directory'
22
20
  `rm -rf Pods`
23
21
  @repository.fetch(name: @fetched_checksum)
24
22
  @is_generated_pods = !Dir.exist?('Pods')
25
23
  else
26
- puts 'Checksum IS EQUAL'
24
+ Logger.info 'Checksum IS EQUAL'
27
25
  @is_generated_pods = false
28
26
  end
29
27
  end
@@ -33,7 +31,7 @@ module Pod
33
31
  end
34
32
 
35
33
  def store
36
- puts "Reason for store: #{store_reason || 'Not reason for store'}"
34
+ Logger.info "Reason for store: #{store_reason || 'Not reason for store'}"
37
35
  @repository.store(name: read_podfile_checksum())
38
36
  end
39
37
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsLazy
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-lazy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Mylnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-09 00:00:00.000000000 Z
11
+ date: 2019-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -59,9 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - lib/cocoapods-lazy/credential.rb
63
62
  - lib/cocoapods-lazy/dsl.rb
64
- - lib/cocoapods-lazy/log.rb
63
+ - lib/cocoapods-lazy/logger.rb
65
64
  - lib/cocoapods-lazy/main.rb
66
65
  - lib/cocoapods-lazy/remote_storage.rb
67
66
  - lib/cocoapods-lazy/repository.rb
@@ -1,21 +0,0 @@
1
- require 'shellwords'
2
-
3
- module Pod
4
- module Lazy
5
- class Credential
6
- attr_reader :login
7
- attr_reader :password
8
- attr_reader :base_url
9
-
10
- def initialize(login, password, base_url)
11
- @login = Shellwords.escape(login)
12
- @password = Shellwords.escape(password)
13
- @base_url = Shellwords.escape(base_url)
14
- end
15
-
16
- def to_s
17
- "login = #{@login} \npassword = #{@password} \nbase_url = #{@base_url}"
18
- end
19
- end
20
- end
21
- end
@@ -1,13 +0,0 @@
1
- module Pod
2
- module Lazy
3
- module Log
4
- def puts(value)
5
- Log.puts(value)
6
- end
7
-
8
- def self.puts(value)
9
- UI.puts "#### #{value}"
10
- end
11
- end
12
- end
13
- end