podspec-editor 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 555a2b480b496016f52187e62671fe0b148f700a
4
+ data.tar.gz: f50bd0d9df57a75e76296fb15f8280972ccbfead
5
+ SHA512:
6
+ metadata.gz: 81ee455ae6268b56cf277c07afbca4a37b6d15916181a90fb37ecb97fdd9718cfa0bfa1e61b8489f3ec3289a8f4e05c0d8400dd7251b2a89f83c42b1747d319a
7
+ data.tar.gz: 8bb55054499b1f434234ee28c6538492505b40e379e7d54587241a3ae18a70890c4b966ea7b16bf0fa40dc1c4ad95b7da041a6bfc5a278e679441ed3bc512f00
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ SimpleCov.start do
2
+ track_files 'lib/**/*.rb'
3
+ add_filter '/spec/'
4
+ end
5
+
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in podspec-editor.gemspec
6
+ gemspec
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ podspec-editor (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (3.0.0)
10
+ activesupport (4.2.10)
11
+ i18n (~> 0.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ atomos (0.1.3)
16
+ claide (1.0.2)
17
+ cocoapods (1.5.3)
18
+ activesupport (>= 4.0.2, < 5)
19
+ claide (>= 1.0.2, < 2.0)
20
+ cocoapods-core (= 1.5.3)
21
+ cocoapods-deintegrate (>= 1.0.2, < 2.0)
22
+ cocoapods-downloader (>= 1.2.0, < 2.0)
23
+ cocoapods-plugins (>= 1.0.0, < 2.0)
24
+ cocoapods-search (>= 1.0.0, < 2.0)
25
+ cocoapods-stats (>= 1.0.0, < 2.0)
26
+ cocoapods-trunk (>= 1.3.0, < 2.0)
27
+ cocoapods-try (>= 1.1.0, < 2.0)
28
+ colored2 (~> 3.1)
29
+ escape (~> 0.0.4)
30
+ fourflusher (~> 2.0.1)
31
+ gh_inspector (~> 1.0)
32
+ molinillo (~> 0.6.5)
33
+ nap (~> 1.0)
34
+ ruby-macho (~> 1.1)
35
+ xcodeproj (>= 1.5.7, < 2.0)
36
+ cocoapods-core (1.5.3)
37
+ activesupport (>= 4.0.2, < 6)
38
+ fuzzy_match (~> 2.0.4)
39
+ nap (~> 1.0)
40
+ cocoapods-deintegrate (1.0.2)
41
+ cocoapods-downloader (1.2.1)
42
+ cocoapods-plugins (1.0.0)
43
+ nap
44
+ cocoapods-search (1.0.0)
45
+ cocoapods-stats (1.0.0)
46
+ cocoapods-trunk (1.3.1)
47
+ nap (>= 0.8, < 2.0)
48
+ netrc (~> 0.11)
49
+ cocoapods-try (1.1.0)
50
+ colored2 (3.1.2)
51
+ concurrent-ruby (1.0.5)
52
+ coveralls (0.8.22)
53
+ json (>= 1.8, < 3)
54
+ simplecov (~> 0.16.1)
55
+ term-ansicolor (~> 1.3)
56
+ thor (~> 0.19.4)
57
+ tins (~> 1.6)
58
+ diff-lcs (1.3)
59
+ docile (1.3.1)
60
+ escape (0.0.4)
61
+ fourflusher (2.0.1)
62
+ fuzzy_match (2.0.4)
63
+ gh_inspector (1.1.3)
64
+ i18n (0.9.5)
65
+ concurrent-ruby (~> 1.0)
66
+ json (2.1.0)
67
+ minitest (5.11.3)
68
+ molinillo (0.6.6)
69
+ nanaimo (0.2.6)
70
+ nap (1.1.0)
71
+ netrc (0.11.0)
72
+ rake (10.5.0)
73
+ rspec (3.7.0)
74
+ rspec-core (~> 3.7.0)
75
+ rspec-expectations (~> 3.7.0)
76
+ rspec-mocks (~> 3.7.0)
77
+ rspec-core (3.7.1)
78
+ rspec-support (~> 3.7.0)
79
+ rspec-expectations (3.7.0)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.7.0)
82
+ rspec-mocks (3.7.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.7.0)
85
+ rspec-support (3.7.1)
86
+ ruby-macho (1.2.0)
87
+ simplecov (0.16.1)
88
+ docile (~> 1.1)
89
+ json (>= 1.8, < 3)
90
+ simplecov-html (~> 0.10.0)
91
+ simplecov-html (0.10.2)
92
+ term-ansicolor (1.6.0)
93
+ tins (~> 1.0)
94
+ thor (0.19.4)
95
+ thread_safe (0.3.6)
96
+ tins (1.16.3)
97
+ tzinfo (1.2.5)
98
+ thread_safe (~> 0.1)
99
+ xcodeproj (1.6.0)
100
+ CFPropertyList (>= 2.3.3, < 4.0)
101
+ atomos (~> 0.1.3)
102
+ claide (>= 1.0.2, < 2.0)
103
+ colored2 (~> 3.1)
104
+ nanaimo (~> 0.2.6)
105
+
106
+ PLATFORMS
107
+ ruby
108
+
109
+ DEPENDENCIES
110
+ bundler (~> 1.16)
111
+ cocoapods (~> 1.5)
112
+ coveralls
113
+ podspec-editor!
114
+ rake (~> 10.0)
115
+ rspec (~> 3.0)
116
+
117
+ BUNDLED WITH
118
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # podspec-editor
2
+
3
+ [![Build Status](https://travis-ci.org/X140Yu/podspec-editor.svg?branch=master)](https://travis-ci.org/X140Yu/podspec-editor)
4
+ [![Coverage Status](https://coveralls.io/repos/github/X140Yu/podspec-editor/badge.svg)](https://coveralls.io/github/X140Yu/podspec-editor)
5
+
6
+ 💎 A ruby gem which can edit [podspec](https://guides.cocoapods.org/syntax/podspec.html).
7
+
8
+
9
+ ## Installation
10
+
11
+ 🤣 Will be added later
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ require 'podspec_editor'
17
+
18
+ # create an editor
19
+ editor = PodspecEditor::Editor.new(spec_path: 'path/to/spec/')
20
+
21
+ # read value from editor
22
+ editor.spec.name
23
+ editor.spec.key_not_exist
24
+ editor.spec.subspecs[0].name
25
+
26
+ # remove value from editor
27
+ editor.spec.name = nil
28
+ editor.spec.key_not_exist = nil
29
+ editor.spec.subspecs[0].source_files = nil
30
+
31
+ # update value from editor
32
+ # update non-exist key will add this k-v pair to the spec
33
+ editor.spec.name = 'abc'
34
+ editor.spec.subspecs[0].name = 'cde'
35
+ editor.spec.subspecs[0].source_files = new_source_files = ['A.h']
36
+
37
+ # get current json content
38
+ editor.current_json_content
39
+ ```
40
+
41
+ See `spec/podspec/editor_spec.rb` for more usage examples.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "podspec/editor"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "POD_NAME",
3
+ "version": "1.0.0",
4
+ "summary": "TestPod summary",
5
+ "license": "MIT",
6
+ "authors": {
7
+ "test": "test@test.com"
8
+ },
9
+ "homepage": "https://www.example.com",
10
+ "platforms": {
11
+ "ios": "9.0"
12
+ }
13
+ }
@@ -0,0 +1,82 @@
1
+ require 'podspec/editor/version'
2
+ require 'pathname'
3
+ require 'ostruct'
4
+ require 'json'
5
+
6
+ module PodspecEditor
7
+ class Helper
8
+ def self.openstruct_to_hash(object, hash = {})
9
+ return object unless object.is_a?(OpenStruct)
10
+ object.each_pair do |key, value|
11
+ hash[key] = if value.is_a?(OpenStruct)
12
+ openstruct_to_hash(value)
13
+ elsif value.is_a?(Array)
14
+ value.map { |v| openstruct_to_hash(v) }
15
+ else
16
+ value
17
+ end
18
+ end
19
+ hash
20
+ end
21
+ end
22
+
23
+ class Spec
24
+ attr_accessor :inner_spec
25
+
26
+ def initialize(json_content)
27
+ @inner_spec = JSON.parse(json_content, object_class: OpenStruct)
28
+ end
29
+
30
+ # read
31
+ def method_missing(method, *args, &block)
32
+ inner_spec.send(method, *args, &block)
33
+ end
34
+ end
35
+
36
+ class Editor
37
+ attr_accessor :origin_json_content
38
+ attr_accessor :spec
39
+
40
+ def self.default_json_spec_content(pod_name)
41
+ content = File.read(File.expand_path('TEMPLATE.podspec.json', __dir__))
42
+ content.gsub('POD_NAME', pod_name)
43
+ end
44
+
45
+ def spec_to_json(spec_path)
46
+ Pod::Specification.from_file(spec_path).to_pretty_json.chomp
47
+ end
48
+
49
+ def initialize(args)
50
+ json_path = args[:json_path]
51
+ if json_path
52
+ unless Pathname.new(json_path).exist?
53
+ raise ArgumentError, "invalid json path #{json_path}"
54
+ end
55
+
56
+ @origin_json_content = File.read(json_path).chomp
57
+ end
58
+
59
+ json_content = args[:json_content]
60
+ @origin_json_content = json_content if json_content
61
+
62
+ spec_path = args[:spec_path]
63
+ if spec_path
64
+ unless Pathname.new(spec_path).exist?
65
+ raise ArgumentError, "invalid spec path #{spec_path}"
66
+ end
67
+
68
+ @origin_json_content = spec_to_json spec_path
69
+ end
70
+
71
+ @spec = Spec.new @origin_json_content
72
+ end
73
+
74
+ def current_hash
75
+ Helper.openstruct_to_hash(@spec.inner_spec)
76
+ end
77
+
78
+ def current_json_content
79
+ JSON.pretty_generate(current_hash)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,6 @@
1
+ # :nocov:
2
+ module Podspec
3
+ module Editor
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'podspec/editor/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'podspec-editor'
7
+ spec.version = Podspec::Editor::VERSION
8
+ spec.authors = ['X140Yu']
9
+ spec.email = ['zhaoxinyu1994@gmail.com']
10
+
11
+ spec.summary = 'Edit podspec'
12
+ spec.description = 'Edit podspecs'
13
+ spec.homepage = 'https://zhaoxinyu.me'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'cocoapods', '~> 1.5'
27
+ spec.add_development_dependency 'coveralls'
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: podspec-editor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - X140Yu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cocoapods
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Edit podspecs
84
+ email:
85
+ - zhaoxinyu1994@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".simplecov"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/podspec/TEMPLATE.podspec.json
102
+ - lib/podspec/editor.rb
103
+ - lib/podspec/editor/version.rb
104
+ - podspec-editor.gemspec
105
+ homepage: https://zhaoxinyu.me
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.6.14
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Edit podspec
129
+ test_files: []