emm 0.0.2 → 0.0.3

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: 83a9c36f7b11711fbfe06cc6fec424795dca7c1a
4
- data.tar.gz: 3494c22ec01e1f13ff8ad0996c6c4e202546d91c
3
+ metadata.gz: f79d8a08312c44b35838794545465532b92e9010
4
+ data.tar.gz: 3477af217ed32f2621241d5593b7e64ffffce6fd
5
5
  SHA512:
6
- metadata.gz: 8400ee128d447fd6d3696d2b7a75259963451d87573437cb743baf71233fd0df26852b701f82d3a9e35d9127021205f34b4d93cc9a2f99e06853b2c660dd1edc
7
- data.tar.gz: 4e701be89a5c1dfb089d6507688d24ffbdf0575fa52866195e4d59a6c899e680ed9a41ad32779ef45a0ec6af456339d9987fb3d05aae97c89976b56d21d92303
6
+ metadata.gz: 619bb59df1a624af2334670888df41c3163e562bc4b39b1c576f0d98c8b873034b9888391f329f999a11820c687b56eed38609f9327c8d1237c91365d693bcfa
7
+ data.tar.gz: 9c539988cb3456ec62451b75f18d1e823dea9bb071b4b17cacb87dfef5f34e05dc1ddfc09ffc3eadc2687fdc464259590d794ffe9f2c6aa57e5f661b90029dd5
data/bin/emm ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # rootPath = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
4
+ # puts rootPath
5
+ # $LOAD_PATH.unshift(rootPath) unless $LOAD_PATH.include?(rootPath)
6
+
7
+ require 'emm'
8
+
9
+ EMM.create_emm_project(ARGV[0], ARGV[1])
data/lib/emm/files.rb ADDED
@@ -0,0 +1,67 @@
1
+ require 'fileutils'
2
+ require 'json'
3
+
4
+ module EMMFiles
5
+
6
+ def self.create_podfile(configs, output_dir, proj_name)
7
+ # create_podfile : 通过 json 配置文件,创建一个 podfile
8
+ # configs : 项目配置
9
+ # output_dir : Podfile 文件导出目录
10
+ podfile = File.new(output_dir + "/Podfile", "w+")
11
+ podfile.syswrite("source 'https://github.com/CocoaPods/Specs.git'\n")
12
+ podfile.syswrite("source '" + configs["private_repo"] + "'\n")
13
+ podfile.syswrite("platform :ios, ‘" + configs["deployment_target"] + "’\n")
14
+ podfile.syswrite("target '" + proj_name + "' do\n")
15
+ for pod in configs["pods"]
16
+ podfile.syswrite(pod + "\n")
17
+ end
18
+ podfile.syswrite("end")
19
+ podfile.close
20
+ end
21
+
22
+ def self.copy_xcconfig(source_path, export_path)
23
+ # 从 pod 的 xcconfig 中提取出所需内容,生成项目所需的 xcconfig
24
+ # sourcePath : Cocoapods 生成的 xcconfig 文件
25
+ # outputPath : 导出的 xcconfig 文件
26
+ output_file = File.new(export_path, "w+")
27
+ IO.foreach(source_path) do |line|
28
+ if line.start_with?("OTHER_LDFLAGS")
29
+ output_file.syswrite(line)
30
+ end
31
+ end
32
+ output_file.syswrite("HEADER_SEARCH_PATHS = $(inherited) ${SRCROOT}/EMM_Pods/Headers/**\n")
33
+ output_file.syswrite("LIBRARY_SEARCH_PATHS = $(inherited) ${SRCROOT}/EMM_Pods/Libraries")
34
+ output_file.close
35
+ end
36
+
37
+ def self.copy_resources(pods_dir, pods_proj_name, export_dir)
38
+ # 从 pod 的 XXX_Proj-resources.sh 脚本文件中提取出资源文件的路径,并将资源文件拷贝到导出目录下
39
+ # source_path: Pods 文件夹路径
40
+ # export_dir: 资源文件导出目录
41
+ start_string = 'if [[ "$CONFIGURATION" == "Release" ]]; then'
42
+ end_string = 'fi'
43
+ writing = false
44
+ # 读取 Cocoapods 提供的 copy resources 的脚本文件
45
+ IO.foreach(pods_dir + "/Target Support Files/Pods-" + pods_proj_name + "/Pods-" + pods_proj_name + "-resources.sh") do |line|
46
+ if line.start_with?(start_string)
47
+ writing = true
48
+ next
49
+ end
50
+ if writing
51
+ if line.start_with?(end_string)
52
+ break
53
+ end
54
+ line = line.match("\".+\"")[0]
55
+ line = line.gsub("\"", "")
56
+ src = pods_dir + "/" + line
57
+ dst = export_dir + "/" + line
58
+ FileUtils.mkdir_p(File.dirname(dst))
59
+ if File.directory?(src)
60
+ FileUtils.cp_r(src, File.dirname(dst))
61
+ else
62
+ FileUtils.cp(src, dst)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
data/lib/emm/proj.rb ADDED
@@ -0,0 +1,96 @@
1
+ require "xcodeproj"
2
+ require "find"
3
+ require 'fileutils'
4
+
5
+ module EMMProj
6
+
7
+ def self.traverse(dirname, basename, super_group)
8
+ filepath = dirname + "/" + basename
9
+ refpath = "./" + @emm_pods_name + filepath[@libs_dir.length, filepath.length - @libs_dir.length]
10
+
11
+ if File.directory?(filepath)
12
+ group = super_group.new_group(basename)
13
+ Dir.foreach(filepath) do |filename|
14
+ if filename != "." and filename != ".." and filename != ".DS_Store"
15
+ traverse(filepath, filename, group)
16
+ end
17
+ end
18
+ else
19
+ ref = super_group.new_reference(refpath)
20
+ extname = File.extname(basename)
21
+ if !([".xcconfig", ".a", ".h"].include?(extname))
22
+ # 除去 [".a", ".xcconfig", ".h"] 文件外,都当做资源文件添加到 target 中
23
+ @target.add_resources([ref])
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.create_temp_proj(proj_name, output_dir)
29
+ # create_temp_proj : 创建一个临时项目
30
+ # proj_name : 项目名称
31
+ # output_dir : 项目导出目录
32
+ proj_path = output_dir + "/" + proj_name + ".xcodeproj"
33
+ Xcodeproj::Project.new(proj_path).save
34
+ project = Xcodeproj::Project.open(proj_path)
35
+ target = project.new_target(:application, proj_name, :ios)
36
+ project.save
37
+ end
38
+
39
+ def self.create_proj(proj_name, output_dir, emm_pods_name, configs)
40
+ # create_temp_proj : 创建一个正式项目
41
+ # proj_name : 项目名称
42
+ # output_dir : 项目导出目录
43
+ # emm_pods_name : EMM_Pods 文件夹的名称
44
+ # configs : 项目配置
45
+ proj_path = output_dir + "/" + proj_name + "/" + proj_name + ".xcodeproj"
46
+ # 创建工程文件,并保存
47
+ Xcodeproj::Project.new(proj_path).save
48
+ # 打开创建的文件
49
+ project = Xcodeproj::Project.open(proj_path)
50
+ # 创建@target,主要的参数 type: application :dynamic_library framework :static_library
51
+ # name:@target名称
52
+ # platform:平台 :ios或者:osx
53
+ @target = project.new_target(:application, proj_name, :ios)
54
+
55
+ # 创建一个分组,名称为proj_name,对应的路径为./proj_name
56
+ group = project.new_group(proj_name)
57
+ # 给分组添加文件引用
58
+ group.new_reference("./" + proj_name + "/AppDelegate.h")
59
+ @target.add_file_references(
60
+ [group.new_reference("./" + proj_name + "/AppDelegate.m")]
61
+ );
62
+ group.new_reference("./" + proj_name + "/ViewController.h")
63
+ @target.add_file_references(
64
+ [group.new_reference("./" + proj_name + "/ViewController.m")]
65
+ );
66
+
67
+ # 在分组下创建一个名字为Supporting Files的子分组,并给该子分组添加main和info.plist文件引用
68
+ supportGroup = group.new_group("Supporting Files")
69
+ supportGroup.new_reference("./" + proj_name + "/Info.plist")
70
+ @target.add_file_references(
71
+ [supportGroup.new_reference("./" + proj_name + "/main.m")]
72
+ );
73
+ @target.add_resources(
74
+ [supportGroup.new_reference("./" + proj_name + "/Base.lproj/LaunchScreen.storyboard"),
75
+ supportGroup.new_reference("./" + proj_name + "/Base.lproj/Main.storyboard"),
76
+ supportGroup.new_reference("./" + proj_name + "/Assets.xcassets")]
77
+ );
78
+
79
+ # 添加@target配置信息
80
+ @target.build_configuration_list.set_setting("INFOPLIST_FILE", "$(SRCROOT)/" + proj_name + "/Info.plist")
81
+ @target.build_configuration_list.set_setting("PRODUCT_BUNDLE_IDENTIFIER", configs["bundle_identifier"])
82
+ @target.build_configuration_list.set_setting("IPHONEOS_DEPLOYMENT_TARGET", configs["deployment_target"])
83
+
84
+ # 添加 EMM_Pods 文件夹到项目中
85
+ @libs_dir = output_dir + "/" + proj_name + "/" + emm_pods_name
86
+ @emm_pods_name = emm_pods_name
87
+
88
+ traverse(File.dirname(@libs_dir), File.basename(@libs_dir), project.main_group)
89
+
90
+ @target.build_configuration_list["Debug"].base_configuration_reference = project.reference_for_path(@libs_dir + "/EMM_Debug.xcconfig")
91
+ @target.build_configuration_list["Release"].base_configuration_reference = project.reference_for_path(@libs_dir + "/EMM_Release.xcconfig")
92
+
93
+ # 保存
94
+ project.save
95
+ end
96
+ end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - chenqmg
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
@@ -27,21 +27,17 @@ dependencies:
27
27
  description:
28
28
  email:
29
29
  - chenqmg@yonyou.com
30
- executables: []
30
+ executables:
31
+ - emm
31
32
  extensions: []
32
33
  extra_rdoc_files: []
33
34
  files:
34
- - ".gitignore"
35
- - ".travis.yml"
36
- - CODE_OF_CONDUCT.md
37
- - Gemfile
38
35
  - LICENSE.txt
39
36
  - README.md
40
- - Rakefile
41
- - bin/console
42
- - bin/setup
43
- - emm.gemspec
37
+ - bin/emm
44
38
  - lib/emm.rb
39
+ - lib/emm/files.rb
40
+ - lib/emm/proj.rb
45
41
  - lib/emm/version.rb
46
42
  homepage: http://rubygems.org/gems/emm
47
43
  licenses:
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.0
5
- before_install: gem install bundler -v 1.12.5
data/CODE_OF_CONDUCT.md DELETED
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at chenqmg@yonyou.com. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem "xcodeproj"
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "emm"
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
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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
data/emm.gemspec DELETED
@@ -1,21 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'emm/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "emm"
8
- spec.version = "0.0.2"
9
- spec.authors = ["chenqmg"]
10
- spec.email = ["chenqmg@yonyou.com"]
11
- spec.summary = "EMM 移动开发平台自动构建工具"
12
- spec.homepage = "http://rubygems.org/gems/emm"
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
- spec.bindir = "exe"
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_development_dependency "xcodeproj", "~> 1.1"
21
- end