cocoapods-lazy 0.1.7 → 0.2.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: 903b99550e354ca4035fb7021d49be011ae4db03
4
- data.tar.gz: 15c6c568a2acf74acb278975c987a04bdc3c68fc
3
+ metadata.gz: 31dedd5dea5833fbe92abfd1afee2b25a9a511ee
4
+ data.tar.gz: ec7e61f41ee7060738c8a192cdeb1a559cb1b963
5
5
  SHA512:
6
- metadata.gz: 9f919422cc599c310140193a8abd918fc938eb1777448a1d3f2c16725dc6498e8fa5f80f76c4ad392e5fa5f905725094f0860ca0926750ff1b3761cdb1f2fd30
7
- data.tar.gz: d92de93e644cd4416d5e3bfd6733b5cf96049b36692b8b543e388b71eeef7c41405c193876816495da4cd538e5fe4adc810aa34432a6d8bb1dbb3c1a497c199d
6
+ metadata.gz: 33b49fd632cfd59f4b10534dd5fbdd7f716d4a94c4467e865757127b4128f0d78429e347a754dfe160f32de5f31ad307445423e8eb7ef303336f80ea74278e36
7
+ data.tar.gz: 586a1b19ecebf9431e07021797a1eec1b4e8acd9fe8756ad9dfb619523d5332981f2f847b7b11984fd00ccdaf2ec35042488f99b7503a77a86464a0b2f8998c5
@@ -0,0 +1,21 @@
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
@@ -0,0 +1,33 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods-lazy/credential'
3
+
4
+ module Pod
5
+ class Podfile
6
+ module DSL
7
+ class Credential
8
+ attr_accessor :login
9
+ attr_accessor :password
10
+ attr_accessor :base_url
11
+
12
+ def is_valid?
13
+ return login != nil && password != nil && base_url != nil
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ module Pod
21
+ class Podfile
22
+ module DSL
23
+ class_attr_accessor :credential
24
+
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)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ module Pod
2
+ module Lazy
3
+ module Log
4
+ def self.puts(value)
5
+ UI.puts "#### #{value}"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,73 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods-lazy/version'
3
+ require 'cocoapods-lazy/log'
4
+ require 'cocoapods-lazy/repository'
5
+ require 'cocoapods-lazy/remote_storage'
6
+ require 'cocoapods-lazy/dsl'
7
+ require 'cocoapods-core/podfile'
8
+
9
+ module Pod
10
+ module Lazy
11
+ def initialize(argv)
12
+ super
13
+ @should_store = argv.flag?('store', true)
14
+ @should_fetch = argv.flag?('fetch', true)
15
+ end
16
+
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)
24
+ repository = Pod::Lazy::Repository.new(remote_storage)
25
+ repository.fetch() if @should_fetch
26
+ puts "Run 'pod #{ARGV.join(" ")}'"
27
+ super
28
+ if repository.should_store && @should_store
29
+ puts "Storing..."
30
+ repository.store()
31
+ end
32
+ puts "Flow cocoapods-lazy if finished"
33
+ else
34
+ puts "cocoapods-lazy is not enabled in Podfile"
35
+ puts "Run cocoapods #{ARGV}"
36
+ super
37
+ end
38
+ end
39
+
40
+ def puts(value)
41
+ Pod::Lazy::Log.puts(value)
42
+ end
43
+
44
+ def options
45
+ [
46
+ ['--no-fetch', 'Skip fetch action'],
47
+ ['--no-store', 'Skip store action'],
48
+ ].concat(super)
49
+ end
50
+
51
+ private
52
+
53
+ def load_credential
54
+ path = Pathname.new('Podfile')
55
+ Podfile.from_file(path)
56
+ Pod::Podfile::DSL.credential
57
+ end
58
+ end
59
+ end
60
+
61
+ class Pod::Command::Install
62
+ prepend Pod::Lazy
63
+ end
64
+
65
+ class Pod::Command::Update
66
+ prepend Pod::Lazy
67
+ end
68
+
69
+ Pod::Command::Install.singleton_class.prepend Pod::Lazy
70
+ Pod::Command::Update.singleton_class.prepend Pod::Lazy
71
+
72
+ # Pod::Command::Install.singleton_class.send :prepend, Pod::Lazy
73
+ # Pod::Command::Update.singleton_class.send :prepend, Pod::Lazy
@@ -0,0 +1,36 @@
1
+ require 'cocoapods-lazy/log'
2
+
3
+ module Pod
4
+ module Lazy
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
12
+ end
13
+
14
+ def fetch(name:)
15
+ zip_name = "#{name}.zip"
16
+ url = @base_url + zip_name
17
+ puts `curl --fail -v -u #{@login}:#{@password} #{url} --output #{zip_name}`
18
+ `unzip #{zip_name}`
19
+ `rm -rf #{zip_name}`
20
+ end
21
+
22
+ def store(name:)
23
+ zip_name = "#{name}.zip"
24
+ unless File.exist?(zip_name)
25
+ puts "Make zip: #{zip_name}"
26
+ `zip -9 -r -y #{zip_name} Pods`
27
+ 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}"
32
+ `rm -rf #{zip_name}`
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,31 +1,72 @@
1
- require 'dotenv'
2
- require 'shellwords'
3
-
4
- class Repository
5
- def initialize(file)
6
- Dotenv.load(file)
7
- @user = Shellwords.escape ENV['STORE_USER']
8
- @password = Shellwords.escape ENV['STORE_PASSWORD']
9
- @base_url = ENV['BASE_URL']
10
- end
1
+ require 'cocoapods-core'
2
+ require 'fileutils'
3
+ require 'cocoapods-lazy/log'
11
4
 
12
- def download(name:)
13
- zip_name = "#{name}.zip"
14
- url = @base_url + zip_name
15
- puts `curl --fail -v -u #{@user}:#{@password} #{url} --output #{zip_name}`
16
- `unzip #{zip_name}`
17
- `rm -rf #{zip_name}`
18
- end
5
+ module Pod
6
+ module Lazy
7
+ class Repository
8
+ include Pod::Lazy::Log
9
+
10
+ def initialize(repository)
11
+ @repository = repository
12
+ end
13
+
14
+ def fetch
15
+ @fetched_checksum = read_podfile_checksum()
16
+ if @fetched_checksum.nil?
17
+ puts "Podfile.lock not found"
18
+ @is_generated_pods = true
19
+ elsif @fetched_checksum != read_manifest_checksum()
20
+ puts 'Checksum IS NOT EQUAL'
21
+ puts 'Drop Pods directory'
22
+ `rm -rf Pods`
23
+ @repository.fetch(name: @fetched_checksum)
24
+ @is_generated_pods = !Dir.exist?('Pods')
25
+ else
26
+ puts 'Checksum IS EQUAL'
27
+ @is_generated_pods = false
28
+ end
29
+ end
30
+
31
+ def should_store
32
+ @is_generated_pods || is_modified_pods?
33
+ end
34
+
35
+ def store
36
+ puts "Reason for store: #{store_reason || 'Not reason for store'}"
37
+ @repository.store(name: read_podfile_checksum())
38
+ end
39
+
40
+ private
41
+
42
+ def is_modified_pods?
43
+ @fetched_checksum != read_manifest_checksum()
44
+ end
45
+
46
+ def store_reason
47
+ if @is_generated_pods
48
+ "Pods is generated (not cached) so should be stored"
49
+ elsif is_modified_pods?
50
+ "Manifest is modified so should be stored"
51
+ else
52
+ nil
53
+ end
54
+ end
55
+
56
+ def read_podfile_checksum
57
+ read_checksum_from_lockfile('Podfile.lock')
58
+ end
19
59
 
20
- def upload(name:)
21
- zip_name = "#{name}.zip"
22
- unless File.exist?(zip_name)
23
- puts "Make zip: #{zip_name}"
24
- `zip -9 -r -y #{zip_name} Pods`
60
+ def read_manifest_checksum
61
+ read_checksum_from_lockfile('./Pods/Manifest.lock')
62
+ end
63
+
64
+ def read_checksum_from_lockfile(name)
65
+ path = Pathname.new(name)
66
+ return nil unless path.exist?
67
+ lockfile = Lockfile.from_file(path.realpath)
68
+ lockfile.internal_data['PODFILE CHECKSUM']
69
+ end
25
70
  end
26
- url = @base_url + zip_name
27
- puts "Storing to #{url}"
28
- `curl --fail -v -u #{@user}:#{@password} --upload-file #{zip_name} #{url}`
29
- `rm -rf #{zip_name}`
30
71
  end
31
72
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsLazy
2
- VERSION = "0.1.7"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,2 @@
1
+ require 'cocoapods-lazy/main'
2
+
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-lazy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.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-03 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: dotenv
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 2.6.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 2.6.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: cocoapods
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -69,16 +55,18 @@ dependencies:
69
55
  description: Share pods dir to team
70
56
  email:
71
57
  - ajjnix@gmail.com
72
- executables:
73
- - cocoapods-lazy
58
+ executables: []
74
59
  extensions: []
75
60
  extra_rdoc_files: []
76
61
  files:
77
- - bin/cocoapods-lazy
78
- - lib/cocoapods-lazy.rb
79
- - lib/cocoapods-lazy/podfile_lock.rb
62
+ - lib/cocoapods-lazy/credential.rb
63
+ - lib/cocoapods-lazy/dsl.rb
64
+ - lib/cocoapods-lazy/log.rb
65
+ - lib/cocoapods-lazy/main.rb
66
+ - lib/cocoapods-lazy/remote_storage.rb
80
67
  - lib/cocoapods-lazy/repository.rb
81
68
  - lib/cocoapods-lazy/version.rb
69
+ - lib/cocoapods_plugin.rb
82
70
  homepage: https://github.com/ajjnix/cocoapods-lazy
83
71
  licenses:
84
72
  - MIT
data/bin/cocoapods-lazy DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $LOAD_PATH.push File.expand_path("../../lib", __FILE__)
3
-
4
- require 'cocoapods-lazy'
5
-
6
- CocoapodsLazy::Invoker.invoke(ARGV)
@@ -1,13 +0,0 @@
1
- class PodfileLock
2
- def initialize(filename)
3
- @filename = filename
4
- end
5
-
6
- def checksum
7
- begin
8
- File.open(@filename).read().match(/(?<=PODFILE CHECKSUM: )\w*/).to_s
9
- rescue
10
- nil
11
- end
12
- end
13
- end
@@ -1,67 +0,0 @@
1
- require 'cocoapods-lazy/version'
2
- require 'cocoapods-lazy/podfile_lock'
3
- require 'cocoapods-lazy/repository'
4
- require 'cocoapods'
5
-
6
- module CocoapodsLazy
7
- class Invoker
8
- def self.invoke(argv)
9
- use_case = UseCase.new()
10
- case
11
- when argv.include?('install')
12
- use_case.install
13
- when argv.include?('update')
14
- use_case.update()
15
- when argv.include?('store')
16
- use_case.store()
17
- else
18
- raise "Unknown command!"
19
- end
20
- end
21
- end
22
-
23
- class UseCase
24
- def initialize()
25
- @repository = Repository.new("PodStore.env")
26
- end
27
-
28
- def install
29
- puts "Check local prebuild"
30
- if read_podfile_checksum() != read_manifest_checksum()
31
- puts 'Drop pods'
32
- `rm -rf Pods`
33
- @repository.download(name: read_podfile_checksum())
34
- is_downloaded = Dir.exist?('Pods')
35
- pod_install(ARGV)
36
- store() unless is_downloaded
37
- else
38
- puts 'Pods is actual'
39
- pod_install(ARGV)
40
- end
41
- end
42
-
43
- def update
44
- Pod::Command.run(ARGV)
45
- store()
46
- end
47
-
48
- def store
49
- @repository.upload(name: read_podfile_checksum())
50
- end
51
-
52
- private
53
-
54
- def read_podfile_checksum
55
- PodfileLock.new("Podfile.lock").checksum
56
- end
57
-
58
- def read_manifest_checksum
59
- PodfileLock.new("./Pods/Manifest.lock").checksum
60
- end
61
-
62
- def pod_install(argv)
63
- puts 'run pod install for actualize workspace'
64
- Pod::Command.run(argv)
65
- end
66
- end
67
- end