jdl 0.0.1
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.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +1 -0
- data/bin/jdl +60 -0
- data/jdl.gemspec +23 -0
- data/lib/jdl/version.rb +3 -0
- data/lib/jdl.rb +53 -0
- data/test/collection.js +1154 -0
- data/test/environment.js +35 -0
- data/test/events.js +452 -0
- data/test/index.html +29 -0
- data/test/model.coffee +43 -0
- data/test/model.js +1110 -0
- data/test/noconflict.js +12 -0
- data/test/router.js +689 -0
- data/test/sync.js +210 -0
- data/test/vendor/backbone.js +1582 -0
- data/test/vendor/jquery.js +9472 -0
- data/test/vendor/json2.js +481 -0
- data/test/vendor/qunit.css +244 -0
- data/test/vendor/qunit.js +2212 -0
- data/test/vendor/runner.js +127 -0
- data/test/vendor/underscore.js +1222 -0
- data/test/view.js +330 -0
- metadata +128 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 shiren1118
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Jdl
|
2
|
+
|
3
|
+
<!-- TODO: Write a gem description -->
|
4
|
+
根据指定目录,扫描内部扩展名为*的所有文件,并输出到jdl.js内,主要用于js测试
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'jdl'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install jdl
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
|
23
|
+
➜ jdl git:(master) ✗ jdl --help
|
24
|
+
import js from directory loader .
|
25
|
+
-p, --path Set options as path
|
26
|
+
-e, --file_ex Set options as file_ex
|
27
|
+
-o, --output Set options as :output_name
|
28
|
+
|
29
|
+
|
30
|
+
- '-p' 指定扫描路径 : 默认值 .
|
31
|
+
- '-e' 指定扫描文件的扩展名 : 默认值 js
|
32
|
+
- '-o' 指定输出文件名称 : 默认值 jdl.js
|
33
|
+
|
34
|
+
## Test
|
35
|
+
|
36
|
+
ruby -Ilib bin/jdl
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
this project is released under the MIT license:
|
49
|
+
|
50
|
+
http://www.opensource.org/licenses/mit-license.php
|
51
|
+
|
52
|
+
|
53
|
+
## 欢迎fork和反馈
|
54
|
+
在issue提问或邮件shiren1118@126.com
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/jdl
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'jdl'
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
option_parser = OptionParser.new do |opts|
|
10
|
+
# 这里是这个命令行工具的帮助信息
|
11
|
+
opts.banner = 'import js from directory loader .'
|
12
|
+
|
13
|
+
# opts.on('-f sourceFileNAME', '--name sourceFileNAME', 'Pass-in source file name') do |value|
|
14
|
+
# # options[:fname] = value
|
15
|
+
#
|
16
|
+
# # Mdpreview.hi(path+'/'+value)
|
17
|
+
# end
|
18
|
+
options[:path] = '.'
|
19
|
+
options[:file_ex] = 'js'
|
20
|
+
options[:output_name] = 'jdl.js'
|
21
|
+
# Option 作为flag,带一组用逗号分割的arguments,用于将arguments作为数组解析
|
22
|
+
opts.on('-t path,file_ex,output_name', '--tranfer path,file_ex,output_name', Array, 'List of 3 arguments') do |value|
|
23
|
+
options[:array] = value
|
24
|
+
# p 'start'
|
25
|
+
#Dir.foreach(".") {|x| puts "Got #{x}" }
|
26
|
+
options[:path] = options[:array][0]
|
27
|
+
options[:file_ex] = options[:array][1]
|
28
|
+
options[:output_name] = options[:array][2]
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on('-p', '--path', 'Set options as path') do |value|
|
32
|
+
# 这个部分就是使用这个Option后执行的代码
|
33
|
+
options[:path] = value
|
34
|
+
|
35
|
+
end
|
36
|
+
opts.on('-e', '--file_ex', 'Set options as file_ex') do |value|
|
37
|
+
# 这个部分就是使用这个Option后执行的代码
|
38
|
+
options[:file_ex] = value
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on('-o', '--output', 'Set options as output_name') do |value|
|
42
|
+
# 这个部分就是使用这个Option后执行的代码
|
43
|
+
options[:output_name] = value
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
path = options[:path]
|
48
|
+
file_ex = options[:file_ex]
|
49
|
+
output_name = options[:output_name]
|
50
|
+
|
51
|
+
File.delete(output_name) if File.exist?(output_name)
|
52
|
+
Jdl.getfiles(path ,file_ex ,output_name)
|
53
|
+
|
54
|
+
end.parse!
|
55
|
+
|
56
|
+
# puts options.inspect
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
data/jdl.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jdl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jdl"
|
8
|
+
spec.version = Jdl::VERSION
|
9
|
+
spec.authors = ["shiren1118"]
|
10
|
+
spec.email = ["shiren1118@126.com"]
|
11
|
+
spec.description = %q{根据指定目录,扫描内部扩展名为*的所有文件,并输出到jdl.js内}
|
12
|
+
spec.summary = %q{根据指定目录,扫描内部扩展名为*的所有文件,并输出到jdl.js内,主要用于js测试}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/jdl/version.rb
ADDED
data/lib/jdl.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "jdl/version"
|
2
|
+
|
3
|
+
module Jdl
|
4
|
+
# Your code goes here...
|
5
|
+
# create runtest.rb for rails.
|
6
|
+
# e.g. :(the name of this file is createruntest.rb)
|
7
|
+
# #>ruby createruntest.rb ./test > runtest.sh
|
8
|
+
# #>chmod 777 runtest.sh
|
9
|
+
#
|
10
|
+
def self.getfiles(path,fname,output_name)
|
11
|
+
re = []
|
12
|
+
allre = []
|
13
|
+
ff = []
|
14
|
+
Dir.foreach(path) do |f|
|
15
|
+
allre << f
|
16
|
+
end
|
17
|
+
allre.each do |f|
|
18
|
+
fullfilename = path + "/" + f
|
19
|
+
|
20
|
+
# p fullfilename
|
21
|
+
|
22
|
+
if f == "." or f == ".."
|
23
|
+
|
24
|
+
elsif File.directory?(fullfilename)
|
25
|
+
resub = []
|
26
|
+
resub = getfiles(fullfilename,fname,output_name)
|
27
|
+
|
28
|
+
if resub.length > 0
|
29
|
+
ref = {}
|
30
|
+
ref[f] = resub
|
31
|
+
re << ref
|
32
|
+
end
|
33
|
+
|
34
|
+
elsif File.exist?(fullfilename) and (f =~ /\.#{fname}$/) # only rb file
|
35
|
+
self.print_arr(fullfilename,output_name)
|
36
|
+
# p ff
|
37
|
+
re << f
|
38
|
+
ff << fullfilename
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# p extname
|
43
|
+
return re
|
44
|
+
# return ff
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def self.print_arr(content,filename='jdl.js')
|
49
|
+
f=open(filename,"a")
|
50
|
+
f.puts(content)
|
51
|
+
f.close
|
52
|
+
end
|
53
|
+
end
|