dependencyswapper 0.4.0 → 0.5.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: 0b373936514939c9ba4f38cb9ad43fad3e4e91e1
4
- data.tar.gz: 471edad590870e8bdc9e4dac498eb70eb750bd75
3
+ metadata.gz: 891c705a70bf7123600a98e8b7f515669c9b36b7
4
+ data.tar.gz: e3ac88621bc578d83200fe6976eb096f54720027
5
5
  SHA512:
6
- metadata.gz: 15734e45c6922250e765593a6cea6b39ac09119fe8c5e75c2d7293ffb68abe2fbe290fc6f7fdb81bfcc11bfd0b7292bb424b42fc0f9ad2ceadfdb927504a0411
7
- data.tar.gz: 4da67691c32609ff683e8973fcad9c1cc2a3716b4374fd8dd5d73eda7b77fef4399dc91b03399e3457f98eee4a98c76f703c5cdaad4fe55f783c3d27707e4544
6
+ metadata.gz: a819f609bdedb5025c7f12a1b6cdf0fc30af4018074f42a1dd60ce0531f7359650f848c4a72b4f9d386fd51bbe8cd00b51df1ec8f7134234918380825f6c580f
7
+ data.tar.gz: f937c2f937e203a9cff4aa1f24f660aa49e9cbbd8afb5439cf49a428cdded0defcfef05cb5b73cca3ca41276539a79187b38ef89694cc9a382c34642c7ba48ac
data/.DS_Store CHANGED
Binary file
@@ -16,12 +16,12 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- if spec.respond_to?(:metadata)
20
- spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
- else
22
- raise "RubyGems 2.0 or newer is required to protect against " \
23
- "public gem pushes."
24
- end
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
25
 
26
26
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
27
  f.match(%r{^(test|spec|features)/})
@@ -3,6 +3,7 @@ require 'fileutils'
3
3
  require 'tempfile'
4
4
  require 'json'
5
5
  require 'find'
6
+ require "dependencyswapper/graph.rb"
6
7
 
7
8
  module Dependency
8
9
  class DependencyReplacer
@@ -21,9 +22,21 @@ module Dependency
21
22
  end
22
23
 
23
24
  def run
25
+ graph = Dependency::Graph.new({
26
+ :podfilelock_path => @podfile_path + ".lock"
27
+ })
28
+ pods = graph.generate()
29
+
30
+ #tag variable to store the version
31
+ tag = ""
32
+
33
+ pods.each { |pod|
34
+ if pod.name.eql? @dependency_name
35
+ tag = pod.version
36
+ end
37
+ }
38
+
24
39
  file_lines = ''
25
- # file = File.read("#{Dir.home}/.depswapper/depmapper.json")
26
- # dependency_replacements = JSON.parse(file)
27
40
 
28
41
  IO.readlines(@podfile_path).each do |line|
29
42
  file_lines += line unless line.include? "'" + dependency_name + "'"
@@ -37,11 +50,16 @@ module Dependency
37
50
  if remote_url.to_s.empty?
38
51
  puts "You are missing the dependency mapping for " + dependency_name + "."
39
52
  else
40
- url_extension = File.extname(remote_url)
53
+ url_extension = File.extname(remote_url)
41
54
  if url_extension.to_s.empty?
42
55
  remote_url = remote_url + ".git"
43
56
  end
44
- file_lines += "pod '" + @dependency_name + "', :git => '" + remote_url + "'\n"
57
+
58
+ if tag.length > 0
59
+ file_lines += "pod '" + @dependency_name + "', :git => '" + remote_url + "', :tag => '" + tag + "'\n"
60
+ else
61
+ file_lines += "pod '" + @dependency_name + "', :git => '" + remote_url + "'\n"
62
+ end
45
63
  end
46
64
  end
47
65
  end
@@ -64,13 +82,17 @@ module Dependency
64
82
  remote_url = dependency_replacements["homepage"]
65
83
  if remote_url.to_s.empty?
66
84
  puts "You are missing the dependency mapping for " + dependency_name + "."
67
- else
68
- url_extension = File.extname(remote_url)
85
+ else
86
+ url_extension = File.extname(remote_url)
69
87
  if url_extension.to_s.empty?
70
88
  remote_url = remote_url + ".git"
71
89
  end
72
90
  unless File.directory?("dev-#{dependency_name}")
73
- `git clone #{remote_url} dev-#{dependency_name}`
91
+ if tag.length > 0
92
+ `git clone --branch #{tag} #{remote_url} dev-#{dependency_name}`
93
+ else
94
+ `git clone #{remote_url} dev-#{dependency_name}`
95
+ end
74
96
  end
75
97
  file_lines += "pod '" + @dependency_name + "', :path => './dev-" + dependency_name + "/'\n"
76
98
  end
@@ -83,4 +105,4 @@ module Dependency
83
105
  `pod install`
84
106
  end
85
107
  end
86
- end
108
+ end
@@ -0,0 +1,60 @@
1
+ require "dependencyswapper/pod.rb"
2
+ require "dependencyswapper/stringextractor.rb"
3
+ require 'fileutils'
4
+ require 'tempfile'
5
+
6
+ #This class generates the dependency graph by retrieving its Pod with its dependencies
7
+ module Dependency
8
+ class Graph
9
+ attr_reader :podfilelock_path
10
+
11
+ def self.perform(options)
12
+ new(options).perform
13
+ end
14
+
15
+ def initialize(options)
16
+ @podfilelock_path = options.fetch(:podfilelock_path)
17
+ @pods = Array.new()
18
+ if !File.exist?(@podfilelock_path)
19
+ puts "The Podfile.lock is missing. We will run pod install so we can generate the dependency graph to swap dependencies."
20
+ `pod install`
21
+ end
22
+ end
23
+
24
+ def generate
25
+ pod = nil
26
+
27
+ #Read line by line the Podfile.lock
28
+ IO.readlines(@podfilelock_path).each do |line|
29
+ #If we are generating the depdency map of a pod, and we have a pod,
30
+ # and the line includes a depdendency(we know cause there is a parenthesis determining a version in it),
31
+ # then we add the dependency name to the pod.dependencies
32
+ if pod && (line.include?("=") || line.include?("~"))
33
+ dependency = line.string_between_markers("- ", " (")
34
+ pod.dependencies.push(dependency)
35
+ end
36
+
37
+ #At this point we found a Pod, lets build it and add its dependencies to it. We know we found a pod since
38
+ #the podfile.lock will show only the version.
39
+ unless line.include?("=") || line.include?("~")
40
+ # We are going to generate a new pod but we are carrying one already, we will push it to the pods array first before we clear the variable with a new pod.
41
+ if pod != nil
42
+ @pods.push(pod)
43
+ end
44
+ name = line.string_between_markers("- ", " (")
45
+ version = line.string_between_markers("(", ")")
46
+ pod = Dependency::Pod.new({
47
+ :name => name,
48
+ :version => version
49
+ })
50
+ end
51
+
52
+ unless line.include?("(") || line.include?(":")
53
+ return @pods
54
+ end
55
+ end
56
+ return @pods
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,16 @@
1
+ #This class is a model for the Pod
2
+ module Dependency
3
+ class Pod
4
+ attr_reader :name, :version, :dependencies
5
+
6
+ def self.perform(options)
7
+ new(options).perform
8
+ end
9
+
10
+ def initialize(options)
11
+ @name = options.fetch(:name)
12
+ @version = options.fetch(:version)
13
+ @dependencies = Array.new
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def string_between_markers marker1, marker2
3
+ self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Dependencyswapper
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
Binary file
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependencyswapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Terns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2017-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.15'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.15'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: The dependencyswapper allows developers to switch between non source
@@ -77,7 +77,7 @@ executables:
77
77
  extensions: []
78
78
  extra_rdoc_files: []
79
79
  files:
80
- - .DS_Store
80
+ - ".DS_Store"
81
81
  - CODE_OF_CONDUCT.md
82
82
  - Gemfile
83
83
  - Gemfile.lock
@@ -88,22 +88,19 @@ files:
88
88
  - bin/console
89
89
  - bin/depswapper
90
90
  - bin/setup
91
- - dependencyswapper-0.1.0.gem
92
91
  - dependencyswapper.gemspec
93
- - lib/.DS_Store
94
92
  - lib/dependencyswapper.rb
95
- - lib/dependencyswapper/.DS_Store
96
93
  - lib/dependencyswapper/DependencyReplacer.rb
97
94
  - lib/dependencyswapper/cli.rb
95
+ - lib/dependencyswapper/graph.rb
96
+ - lib/dependencyswapper/pod.rb
97
+ - lib/dependencyswapper/stringextractor.rb
98
98
  - lib/dependencyswapper/version.rb
99
- - pkg/dependencyswapper-0.1.0.gem
100
- - pkg/dependencyswapper-0.2.0.gem
101
- - pkg/dependencyswapper-0.3.0.gem
99
+ - pkg/dependencyswapper-0.5.0.gem
102
100
  homepage: https://github.com/pkrmf/dependencyswapper
103
101
  licenses:
104
102
  - MIT
105
- metadata:
106
- allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
103
+ metadata: {}
107
104
  post_install_message: Thanks for installing! Make sure to run `depswapper setup` command
108
105
  before start using depswapper!
109
106
  rdoc_options: []
@@ -111,17 +108,17 @@ require_paths:
111
108
  - lib
112
109
  required_ruby_version: !ruby/object:Gem::Requirement
113
110
  requirements:
114
- - - '>='
111
+ - - ">="
115
112
  - !ruby/object:Gem::Version
116
113
  version: '0'
117
114
  required_rubygems_version: !ruby/object:Gem::Requirement
118
115
  requirements:
119
- - - '>='
116
+ - - ">="
120
117
  - !ruby/object:Gem::Version
121
118
  version: '0'
122
119
  requirements: []
123
120
  rubyforge_project:
124
- rubygems_version: 2.0.14.1
121
+ rubygems_version: 2.5.2
125
122
  signing_key:
126
123
  specification_version: 4
127
124
  summary: Swaps the cocoapods dependencies between a production environment and a test/development
Binary file
data/lib/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file
Binary file