dependencyswapper 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abfd5c6b197dc90a8195950a3fcae04acfaf68ed
4
- data.tar.gz: 097a5b9e10d0680c018f6247d6b16599d6c38adf
3
+ metadata.gz: 2c55ec26d2939f54b497a91168b9211600d461ed
4
+ data.tar.gz: a1e01fe1859e8c4f8f1af75682b3c8d294b78b66
5
5
  SHA512:
6
- metadata.gz: 635a9ea7f53e1696b767b995ba0af582a89bb80f38e5b16f10681c273581f5b86b9eb6a2bde537cd5f72ffe9a1300c777e7710deb7df4a95571b7d52179f2fc6
7
- data.tar.gz: 0dfb32370ebfe321e43c3b3f29e4f454c4876f61f553bc7539ff1932b7d675ff55e53a96a2dec8b0f4cd57536753d7fd12c5b521960093093d564ca3f47aea98
6
+ metadata.gz: 13c4688acc853593f9692470b6d4f7212930572a6c787646a91829d2322ab1ebd7006561ef8269143e88bf70d8d99f40c63a56db5fc2a3a87027fd9f902c9241
7
+ data.tar.gz: f4b393c5050b7bcbc0ee83d6689748b3ab01d93e6670cabacf4c427fcf8db59c9972110d31bdc224388d430a1a1fa0c2451f5736bf19ea2c0f594d57069aaec6
data/.DS_Store CHANGED
Binary file
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Dependencyswapper
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dependencyswapper`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Dependencyswapper also known as `depswapper` is a CocoaPods plugin that allows to switch between "dev/test/prod" environments with just running a simple ruby command.
4
+
5
+ As a watchOS, tvOS and iOS Framework developer I often find myself wanting to debug my non source Frameworks to make sure the problem is not in my dependent Application/Framework. It is always time consuming to have to find the `Podfile`, then look for the git repository of the Framework I want to debug and then google the syntax to read from a git repository. With this ruby gem, the only thing you need to do is keep track of your Framework repositories and add them to the `~/.depswapper/depmapper.json` file.
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
6
7
 
7
8
  ## Installation
8
9
 
@@ -22,13 +23,9 @@ Or install it yourself as:
22
23
 
23
24
  ## Usage
24
25
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+ First it is very important to run a setup command. This is as simple as running `depswapper setup` in the console.
30
27
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+ Now `depswapper` is ready to be used. Whenever you want to swap environments on any of your dependencies, run `depswapper test "NameOfYourFramework"` or `depswapper dev "NameOfYourFramework"` at the root of your Project.
32
29
 
33
30
  ## Contributing
34
31
 
data/bin/depswapper CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "dependencyswapper/cli"
3
3
 
4
- Dependency::CLI.start ARGV
4
+ Dependency::CLI.start(ARGV)
data/bin/setup CHANGED
@@ -3,6 +3,4 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
6
+ bundle install
@@ -27,9 +27,9 @@ Gem::Specification.new do |spec|
27
27
  f.match(%r{^(test|spec|features)/})
28
28
  end
29
29
  spec.bindir = "bin"
30
- spec.executables = ["depswapper"]
30
+ spec.executables = ["depswapper", "setup"]
31
31
  spec.require_paths = ["lib"]
32
-
32
+ spec.post_install_message = "Thanks for installing! Make sure to run `depswapper setup` command before start using depswapper!"
33
33
  spec.add_development_dependency "bundler", "~> 1.15"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
35
  spec.add_development_dependency "rspec", "~> 3.0"
data/lib/.DS_Store CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'fileutils'
3
3
  require 'tempfile'
4
- require 'dependencyswapper/DependencyMapper.rb'
4
+ require 'json'
5
5
 
6
6
  module Dependency
7
7
  class DependencyReplacer
@@ -14,17 +14,54 @@ module Dependency
14
14
  def initialize(options)
15
15
  @dependency_name = options.fetch(:dependency_name)
16
16
  @podfile_path = "Podfile"
17
+ if !File.exist?(@podfile_path)
18
+ abort("Cannot find the podfile. Make sure to run depswapper where your Podfile exists!")
19
+ end
17
20
  end
18
21
 
19
22
  def run
23
+
24
+ file_lines = ''
25
+ file = File.read("#{Dir.home}/.depswapper/depmapper.json")
26
+ dependency_replacements = JSON.parse(file)
27
+
28
+ IO.readlines(@podfile_path).each do |line|
29
+ file_lines += line unless line.include? "'" + dependency_name + "'"
30
+ if line.include? "'" + dependency_name + "'"
31
+ # We will look at the DependencyMapper to map each Framework with its git repository.
32
+ remote_url = dependency_replacements[dependency_name]
33
+ if remote_url.to_s.empty?
34
+ puts "You are missing the dependency mapping for " + dependency_name + ". Make sure to add it in #{Dir.home}/.depswapper/depmapper.json"
35
+ else
36
+ file_lines += "pod '" + @dependency_name + "', :git => '" + remote_url + "'\n"
37
+ end
38
+ end
39
+ end
40
+
41
+ #<extra string manipulation to file_lines if you wanted>
42
+
43
+ File.open(@podfile_path, 'w') do |file|
44
+ file.puts file_lines
45
+ end
46
+ end
47
+
48
+ def dev
49
+
20
50
  file_lines = ''
21
- dependency_mapper = DependencyMapper.new({})
51
+ file = File.read("#{Dir.home}/.depswapper/depmapper.json")
52
+ dependency_replacements = JSON.parse(file)
53
+
22
54
  IO.readlines(@podfile_path).each do |line|
23
55
  file_lines += line unless line.include? "'" + dependency_name + "'"
24
56
  if line.include? "'" + dependency_name + "'"
25
57
  # We will look at the DependencyMapper to map each Framework with its git repository.
26
- remote_url = dependency_mapper.dependency_replacements[dependency_name]
27
- file_lines += "pod '" + @dependency_name + "', :git => '" + remote_url + "'\n"
58
+ remote_url = dependency_replacements[dependency_name]
59
+ if remote_url.to_s.empty?
60
+ puts "You are missing the dependency mapping for " + dependency_name + ". Make sure to add it in #{Dir.home}/.depswapper/depmapper.json"
61
+ else
62
+ `git clone #{remote_url} dev-#{dependency_name}`
63
+ file_lines += "pod '" + @dependency_name + "', :path => './dev-" + dependency_name + "/'\n"
64
+ end
28
65
  end
29
66
  end
30
67
 
@@ -3,8 +3,32 @@
3
3
 
4
4
  module Dependency
5
5
  class CLI < Thor
6
- Dependency::DependencySwapper.new({
7
- :dependency_name => ARGV[0]
6
+ desc "test FrameworkName", "Pulls the FrameworkName as source(not editable)"
7
+ def test(name)
8
+ Dependency::DependencySwapper.new({
9
+ :dependency_name => name
8
10
  }).run
11
+ end
12
+
13
+ desc "development FrameworkName", "Pulls the FrameworkName as development pod(editable source)"
14
+ def dev(name)
15
+ Dependency::DependencySwapper.new({
16
+ :dependency_name => name
17
+ }).dev
18
+ end
19
+
20
+ desc "setup", "Initial setup for depswapper"
21
+ def setup
22
+ puts "Make sure to add your dependency mappings in the ~/.depswapper/depmapper.json file!"
23
+ `if [ ! -d ~/.depswapper ]; then
24
+ mkdir -p ~/.depswapper;
25
+ fi
26
+
27
+ if [ ! -e ~/.depswapper/depmapper.json ];then
28
+ touch ~/.depswapper/depmapper.json
29
+ echo '{\n\t\"DependencyName\":\"git-url\"\n}' > ~/.depswapper/depmapper.json
30
+ fi
31
+ `
32
+ end
9
33
  end
10
34
  end
@@ -1,3 +1,3 @@
1
1
  module Dependencyswapper
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,7 +1,6 @@
1
1
  require "dependencyswapper/version"
2
- #require "dependencyswapper/DependencySwapper.rb"
3
2
  require "dependencyswapper/DependencyReplacer.rb"
4
- require "dependencyswapper/DependencyMapper.rb"
3
+ require 'fileutils'
5
4
 
6
5
  module Dependency
7
6
  class DependencySwapper
@@ -20,5 +19,11 @@ module Dependency
20
19
  :dependency_name => @dependency_name
21
20
  }).run
22
21
  end
22
+
23
+ def dev
24
+ Dependency::DependencyReplacer.new({
25
+ :dependency_name => @dependency_name
26
+ }).dev
27
+ end
23
28
  end
24
29
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependencyswapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.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-05 00:00:00.000000000 Z
11
+ date: 2017-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,7 @@ email:
73
73
  - tenxurz@gmail.com
74
74
  executables:
75
75
  - depswapper
76
+ - setup
76
77
  extensions: []
77
78
  extra_rdoc_files: []
78
79
  files:
@@ -92,18 +93,18 @@ files:
92
93
  - lib/.DS_Store
93
94
  - lib/dependencyswapper.rb
94
95
  - lib/dependencyswapper/.DS_Store
95
- - lib/dependencyswapper/DependencyMapper.rb
96
96
  - lib/dependencyswapper/DependencyReplacer.rb
97
- - lib/dependencyswapper/DependencySwapper.rb
98
97
  - lib/dependencyswapper/cli.rb
99
98
  - lib/dependencyswapper/version.rb
100
99
  - pkg/dependencyswapper-0.1.0.gem
100
+ - pkg/dependencyswapper-0.2.0.gem
101
101
  homepage: https://github.com/pkrmf/dependencyswapper
102
102
  licenses:
103
103
  - MIT
104
104
  metadata:
105
105
  allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
106
- post_install_message:
106
+ post_install_message: Thanks for installing! Make sure to run `depswapper setup` command
107
+ before start using depswapper!
107
108
  rdoc_options: []
108
109
  require_paths:
109
110
  - lib
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #Add your dependencies to the dependency_replacements. Before the arrow make sure to add the pod name, after the arrow its git repo.
4
- module Dependency
5
- class DependencyMapper
6
- attr_reader :dependency_replacements
7
-
8
- def self.perform(options)
9
- new(options).perform
10
- end
11
-
12
- def initialize(options)
13
- @dependency_replacements = {
14
- "ExampleFramework" => "git@bitbucket.org:myexample/example.git",
15
- "ExampleFramework2" => "git@bitbucket.org:myexample/example2.git",
16
- "ExampleFramework3" => "git@bitbucket.org:myexample/example3.git",
17
- "ExampleFramework4" => "git@bitbucket.org:myexample/example4.git"
18
- }
19
- end
20
- end
21
- end
@@ -1,7 +0,0 @@
1
- # #!/usr/bin/env ruby
2
- # require 'dependencyswapper/DependencyReplacer.rb'
3
-
4
- # dependency_name = ARGV[0]
5
- # Dependency::DependencyReplacer.new({
6
- # :dependency_name => dependency_name
7
- # }).run