elm_plugin 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: 6c7a85e7d70f565ab825ca017467e63410918469
4
+ data.tar.gz: c912d5591faa97b9c0081e9d2d6cce8b0f20e6a8
5
+ SHA512:
6
+ metadata.gz: 83a1bc7aa2c638d1b75a91688e7b14e8a2589fa1766acfafe251a5b94a9519a76a628efdeba22bff971f8f7911db04a4605e51eb4651dd353d55a398b32f8700
7
+ data.tar.gz: 926858a5db1005bcdf9c428d618c875b08ae024d1e336ba1b63afe22849c95041ec28275a1ee17a583ec598a9f09dfbb760c483fd2e75ec36f06bb7a07973378
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in elm_plugin.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 沈强
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,41 @@
1
+ # ElmPlugin
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/elm_plugin`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'elm_plugin'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install elm_plugin
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/elm_plugin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "elm_plugin"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'elm_plugin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "elm_plugin"
8
+ spec.version = ElmPlugin::VERSION
9
+ spec.authors = ["沈强"]
10
+ spec.email = ["qiang.shen@ele.me"]
11
+
12
+ spec.summary = %q{"elm_plugin"}
13
+ spec.description = %q{"elm_plugin"}
14
+ spec.homepage = "http://git.elenet.me/cordova/ios_cordova-plugin-installer"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem 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 public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ end
@@ -0,0 +1,275 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'xcodeproj'
4
+ require 'Find'
5
+ require 'FileUtils'
6
+ require 'colorize'
7
+ require 'rexml/document'
8
+ include REXML
9
+
10
+ def main_dir
11
+ Dir::entries($project_dic).each do |f|
12
+ if f =~ /\.xcodeproj$/i
13
+ main_dir = File.basename($project_dic+"/"+f, '.xcodeproj')
14
+ return main_dir
15
+ end
16
+ end
17
+ end
18
+
19
+ def copyjs
20
+
21
+ if !File::exist?($project_dic+'www')
22
+ Dir.mkdir($project_dic+'www')
23
+ end
24
+
25
+
26
+ if !File::exist?($project_dic+'www/'+$plugin_name)
27
+ Dir.mkdir($project_dic+'www/'+$plugin_name)
28
+ end
29
+
30
+ if !File::exist?($project_dic+'www/'+'plugins/'+$plugin_name)
31
+ Dir.mkdir($project_dic+'www/'+'plugins/'+$plugin_name)
32
+ end
33
+ FileUtils.cp_r(Dir[$tmpPath+'/www'], $project_dic+'www/'+'plugins/'+$plugin_name)
34
+ Dir::entries($project_dic+'www/'+'plugins/'+$plugin_name+'/www').each do |f|
35
+ if f =~ /\.js$/
36
+ file = File.open($project_dic+'www/'+'plugins/'+$plugin_name+'/www'+'/'+f, "rb")
37
+ contents = file.read
38
+ file.close
39
+ if contents =~ /^\s*cordova.define\s*\(\s*\"\s*cordova-plugin-console.logger\s*\"\s*,\s*function\s*\(\s*require\s*,\s*exports\s*,\s*module\s*\)\s*\{/
40
+ puts 'has cordova.define'
41
+ else
42
+ contents = "cordova.define(\"cordova-plugin-console.logger\", function(require, exports, module) {\n" +contents +"\n});"
43
+ file=File.new($project_dic+'www/'+'plugins/'+$plugin_name+'/www'+'/'+f, 'w+')
44
+ file.write(contents)
45
+ puts 'dont match'
46
+ end
47
+ file.close
48
+ end
49
+
50
+ end
51
+ end
52
+
53
+
54
+ def copySource
55
+
56
+ if !File::exist?($project_dic+$main_dir+'/Plugins')
57
+ error = 'error: you project don\'t have '+$main_dir+'/Plugins'+'in workspace'
58
+ puts error.red
59
+ exit(0)
60
+ end
61
+
62
+ if !File::exist?($project_dic+$main_dir+'/Plugins/'+$plugin_name)
63
+ Dir.mkdir($project_dic+$main_dir+'/Plugins/'+$plugin_name)
64
+ end
65
+ Dir::entries($tmpPath+'/src'+'/ios').each do |f|
66
+ puts 'copy source to plugins dic'
67
+ if f =~ /\.[hm]$/i
68
+ FileUtils.cp($tmpPath+'/src'+'/ios/'+f, $project_dic+$main_dir+'/Plugins/'+$plugin_name)
69
+ end
70
+ end
71
+ end
72
+
73
+
74
+ def writePodfileAndUpdate
75
+
76
+ puts $project_dic+'Podfile'
77
+
78
+ if File::exist?($project_dic+'Podfile')
79
+ f=File.new($project_dic+'Podfile', 'a+')
80
+ f.puts "\npod \'" +$plugin_name+'\''
81
+ f.close
82
+ puts 'update pod........................'.green
83
+ result =`pod update`
84
+ puts result
85
+ else
86
+ puts 'create Podfile.....'
87
+ `touch Podfile`
88
+ f=File.new($project_dic+'Podfile', 'a+')
89
+ f.puts "source \'git@git.elenet.me:arch.mobile/iOS_specs.git\'\nsource \'https://github.com/CocoaPods/Specs.git\'\nplatform :ios, \'7.0\'"
90
+ f.puts "\npod \'" +$plugin_name+'\''
91
+ f.close
92
+ puts 'update pod........................'.green
93
+ result =`pod install`
94
+ puts result
95
+ end
96
+ end
97
+
98
+ def findXmlConfig
99
+
100
+ Dir::entries($project_dic).each do |f|
101
+ if f == 'config.xml'
102
+ writeConfigXml($project_dic + 'config.xml')
103
+ return
104
+ end
105
+ end
106
+
107
+ Find.find($project_dic+$main_dir) do |f|
108
+
109
+ if f =~ /config.xml$/i
110
+ writeConfigXml(f)
111
+ break
112
+ end
113
+ end
114
+ end
115
+
116
+
117
+ def writeConfigXml(fileName)
118
+ puts 'config'+fileName
119
+ fw = File.open(fileName)
120
+ docw = Document.new(fw)
121
+ root = docw.root
122
+ puts root
123
+ f = File.open($project_dic+'ELMPlugins/'+$plugin_name+'/plugin.xml')
124
+ doc = Document.new(f)
125
+ doc.elements.each("*/platform") { |e|
126
+
127
+ if e.attributes["name"] == 'ios'
128
+ e.elements.each('config-file/feature') { |se|
129
+ puts se
130
+ root.add_element se
131
+ puts root
132
+
133
+ }
134
+ end
135
+
136
+ }
137
+ docw.write(File.open(fileName,"w"), 2)
138
+ fw.close
139
+ f.close
140
+ end
141
+
142
+ # cordova.define('cordova/plugin_list', function(require, exports, module) {
143
+ # module.exports = [
144
+ # {
145
+ # "file": "plugins/cordova-plugin-device/www/device.js",
146
+ # "id": "cordova-plugin-device.device",
147
+ # "clobbers": [
148
+ # "device"
149
+ # ]
150
+ # },
151
+ # <js-module src="www/logger.js" name="logger">
152
+ # <clobbers target="cordova.logger" />
153
+ # </js-module>
154
+
155
+ def writeJs
156
+ write = false
157
+ tempfile=File.new($project_dic+'www/'+'temp.js', 'w+')
158
+ f=File.new($project_dic+'www/'+'cordova_plugins.js')
159
+ xmlf = File.open($project_dic+'ELMPlugins/'+$plugin_name+'/plugin.xml')
160
+ doc = Document.new(xmlf)
161
+ id = doc.root.attributes['id']
162
+ version = doc.root.attributes['version']
163
+ f.each do |line|
164
+ if line =~ /^(\s)*module.exports(\s)*=(\s)*\[(\s)*\]/
165
+ doc.elements.each("*/js-module") { |e|
166
+ puts e
167
+ jsId = id + '.' + e.attributes['name']
168
+ jssSrc = 'plugins/'+$plugin_name +'/'+e.attributes['src']
169
+ e.elements.each('clobbers') { |se|
170
+
171
+ clobbers = se.attributes['target']
172
+ tempfile<<"module.exports = \[ \n {\n \"File\": "+"\""+jssSrc+"\",\n"+" \"id\": "+"\""+jsId+"\",\n"+" \"clobbers\": "+"[\n"+" \""+clobbers+"\"\n"+" ]\n"+" }\n\];\n"
173
+ }
174
+ }
175
+ else
176
+ tempfile<<line
177
+ if line.downcase=~ /^(\s)*module.exports(\s)*=(\s)*/
178
+ doc.elements.each("*/js-module") { |e|
179
+ puts e
180
+ jsId = id + '.' + e.attributes['name']
181
+ jssSrc = 'plugins/'+$plugin_name +'/'+e.attributes['src']
182
+ e.elements.each('clobbers') { |se|
183
+
184
+ clobbers = se.attributes['target']
185
+ tempfile<<" {\n \"File\": "+"\""+jssSrc+"\",\n"+" \"id\": "+"\""+jsId+"\",\n"+" \"clobbers\": "+"[\n"+" \""+clobbers+"\"\n"+" ]\n"+" },\n"
186
+
187
+ }
188
+ }
189
+ end
190
+ end
191
+ if write
192
+ write = false
193
+ # "org.apache.cordova.device": "0.2.14-dev"
194
+ tempfile<< " \""+id+"\": "+"\""+version+"\",\n"
195
+ end
196
+
197
+ if line =~/^(\s)*\/\/ (\s)*TOP (\s)*OF(\s)* METADATA(\s)*/
198
+ write = true
199
+ end
200
+ end
201
+ f.close
202
+ tempfile.close
203
+ FileUtils.mv($project_dic+'www/'+'temp.js', $project_dic+'www/'+'cordova_plugins.js')
204
+ end
205
+
206
+
207
+ def addXcodeproj
208
+
209
+ project = Xcodeproj::Project.open($project_dic.to_s+$projectName.to_s)
210
+ target = project.targets.first
211
+ group = project.main_group.find_subpath(File.join('Plugins'), true)
212
+ group.set_source_tree('SOURCE_ROOT')
213
+ Dir::entries($project_dic.to_s+$main_dir.to_s+'/Plugins/'+$plugin_name.to_s).each do |f|
214
+ if f =~ /\.m$/i
215
+ file_ref = group.new_reference($project_dic.to_s+$main_dir.to_s+'/Plugins/'+$plugin_name.to_s+'/'+f)
216
+ target.add_file_references([file_ref])
217
+ end
218
+ if f =~ /\.h$/i
219
+ file_ref = group.new_reference($project_dic.to_s+$main_dir.to_s+'/Plugins/'+$plugin_name.to_s+'/'+f)
220
+ end
221
+ end
222
+ project.save
223
+
224
+ end
225
+
226
+
227
+
228
+ $project_dic = Dir::pwd+'/'
229
+ $operation = ARGV[0]
230
+ $plugin_name = ARGV[1]
231
+ $plugin_address = ARGV[2]
232
+ $projectName
233
+ $main_dir = main_dir
234
+ $tmpPath = $project_dic.to_s+'ELMPlugins/'+$plugin_name.to_s
235
+
236
+ if $operation != 'add' and $operation != 'pod'
237
+
238
+ print "\n\nUsage:\n"
239
+ print " $ELMPlugin command\n".green
240
+ print " add plugin for cordova\n\n "
241
+ print " add+".green
242
+ print " add plugin source files to project, argvs: pluginName and gitAddress\n"
243
+ print " pod+".green
244
+ print " add pod to you project manager source files, argvs: pluginName and gitAddress\n"
245
+ exit(0)
246
+ end
247
+
248
+
249
+ puts 'downloading plugin.............. '
250
+
251
+ `git clone #{$plugin_address} #{$tmpPath}`
252
+
253
+ Dir::entries($project_dic).each do |f|
254
+ if f =~ /\.xcodeproj$/i
255
+ $projectName = f
256
+ puts 'will add plugin to '+f+' project'
257
+ break
258
+ end
259
+ end
260
+
261
+ copyjs
262
+
263
+ findXmlConfig
264
+
265
+ writeJs
266
+
267
+ if $operation == 'add'
268
+ copySource
269
+ addXcodeproj
270
+ else
271
+ writePodfileAndUpdate
272
+ end
273
+ `rm -rf ELMPlugins`
274
+
275
+
@@ -0,0 +1,3 @@
1
+ module ElmPlugin
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elm_plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - 沈强
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-17 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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
+ description: '"elm_plugin"'
42
+ email:
43
+ - qiang.shen@ele.me
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - CODE_OF_CONDUCT.md
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - elm_plugin.gemspec
57
+ - lib/elm_plugin.rb
58
+ - lib/elm_plugin/version.rb
59
+ homepage: http://git.elenet.me/cordova/ios_cordova-plugin-installer
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.14
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: '"elm_plugin"'
84
+ test_files: []