repoaccessor 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/lib/repoaccessor.rb +1 -1
- data/lib/repoaccessor/bundle.rb +2 -2
- data/lib/repoaccessor/repo.rb +1 -0
- data/lib/repoaccessor/tester.rb +89 -2
- data/lib/repoaccessor/version.rb +1 -1
- data/lib/repoaccessor/xmlfile.rb +44 -6
- data/lib/repoaccessor/xmlparser.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51103cd85124144ccf57adf8e02a097fce7650e4
|
4
|
+
data.tar.gz: 3bf88d761ff1683fd00d979c1b2b94947e74b26c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad0847bddbf60e5b758f9ea5f3dfbdd0a809e842a8dc5da78622fbdc2f1e6c71e2c5762d7783f950d7c76eb988845f69518a98cfa9d6109aa21bc3ead8738e9
|
7
|
+
data.tar.gz: 4ed943e96229403849a5eddc7e1744569e34edd404629f674cce633c6ff04871161e19b85469cbf2243e15d4f32e31905e77b2525c225f0be4571ddde778786e
|
data/README.md
CHANGED
@@ -22,8 +22,15 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
```
|
26
|
+
|
27
|
+
require "repoaccessor"
|
28
|
+
|
29
|
+
Repoaccessor::checkout("usrname","password","repo-url","path/to/working-copy") # success:0
|
30
|
+
p Repoaccessor::inspect_repo("path/to/working-copy") #json format
|
26
31
|
|
32
|
+
|
33
|
+
```
|
27
34
|
## Development
|
28
35
|
|
29
36
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake true` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/repoaccessor.rb
CHANGED
data/lib/repoaccessor/bundle.rb
CHANGED
@@ -52,7 +52,7 @@ module Repoaccessor
|
|
52
52
|
proj_name[0]
|
53
53
|
end
|
54
54
|
elsif @platform == "android"
|
55
|
-
|
55
|
+
#TODO: 需要通过目录操作,找到对应的工程.
|
56
56
|
else
|
57
57
|
"unkonwn"
|
58
58
|
end
|
@@ -74,7 +74,7 @@ module Repoaccessor
|
|
74
74
|
resource_file_paths.each { |file|
|
75
75
|
file_hash = {}
|
76
76
|
file_hash[:lang] = File.basename(file,".*")
|
77
|
-
file_hash[:kv_pairs] = XMLParser::parse(file).to_hash
|
77
|
+
file_hash[:kv_pairs] = XMLParser::parse(file).to_hash(:with_comments => with_comments)
|
78
78
|
@resources_files << file_hash
|
79
79
|
}
|
80
80
|
else
|
data/lib/repoaccessor/repo.rb
CHANGED
data/lib/repoaccessor/tester.rb
CHANGED
@@ -1,5 +1,92 @@
|
|
1
|
+
# require "repoaccessor"
|
1
2
|
|
2
|
-
|
3
|
-
|
3
|
+
# Repoaccessor::checkout("lj94409","qwpoplko12..","http://svnhz.alipay.net/svn/ios-phone-mobilecommon/branches/cp_daily_project_489839_20151008_ios-phone-mobilecommon","Users/Jason/Documents/Jason/9-3mobile-common")
|
4
|
+
# p Repoaccessor::inspect_repo("Users/Jason/Documents/Jason/9-3mobile-common")
|
5
|
+
|
6
|
+
|
7
|
+
# require "rexml/document"
|
8
|
+
|
9
|
+
# class KV_pair
|
10
|
+
# attr_accessor :key
|
11
|
+
# attr_accessor :value
|
12
|
+
# attr_accessor :comment
|
13
|
+
|
14
|
+
# def initialize(key,value,comment)
|
15
|
+
# @key = key
|
16
|
+
# @value = value
|
17
|
+
# @comment = comment
|
18
|
+
# end
|
19
|
+
|
20
|
+
|
21
|
+
# def to_hash
|
22
|
+
# {
|
23
|
+
# :key => @key,
|
24
|
+
# :value => @value,
|
25
|
+
# :comment => @comment
|
26
|
+
# }
|
27
|
+
|
28
|
+
# end
|
29
|
+
|
30
|
+
# end
|
31
|
+
|
32
|
+
|
33
|
+
# class XMLFile
|
34
|
+
# attr_accessor :kv_pairs
|
35
|
+
|
36
|
+
# def initialize
|
37
|
+
# @kv_pairs = []
|
38
|
+
# end
|
39
|
+
|
40
|
+
# def key_values
|
41
|
+
# #TODO
|
42
|
+
# end
|
43
|
+
|
44
|
+
# def keys
|
45
|
+
# @kv_pairs.each { |e|
|
46
|
+
|
47
|
+
# }
|
48
|
+
# end
|
49
|
+
|
50
|
+
# def values
|
51
|
+
# #TODO
|
52
|
+
# end
|
53
|
+
|
54
|
+
# def to_hash(args={})
|
55
|
+
# with_comments = args[:with_comments].nil? ? true : args[:with_comments]
|
56
|
+
# build_hash { |hash, pair|
|
57
|
+
# hash_value = with_comments ? { pair.value => pair.comment } : pair.value
|
58
|
+
# hash[pair.key] = hash_value
|
59
|
+
# }
|
60
|
+
# end
|
61
|
+
|
62
|
+
# def to_json
|
63
|
+
# #TODO
|
64
|
+
# end
|
65
|
+
|
66
|
+
# def build_hash(&block)
|
67
|
+
# hash = {}
|
68
|
+
# @kv_pairs.each do |pair|
|
69
|
+
# yield hash, pair
|
70
|
+
# end
|
71
|
+
# hash
|
72
|
+
# end
|
73
|
+
|
74
|
+
# end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
# # file = File.new("/Users/Jason/Downloads/share_2/api/res/values-en/strings-en.xml")
|
80
|
+
# # doc = REXML::Document.new file
|
81
|
+
# xmlfile = XMLFile.new()
|
82
|
+
# resourcefile = File.new("/Users/Jason/Downloads/share_2/api/res/values-en/strings-en.xml")
|
83
|
+
# doc = REXML::Document.new resourcefile
|
84
|
+
# doc.elements.each("resources/string") { |e|
|
85
|
+
# key = e.attributes["name"]
|
86
|
+
# value = e.text
|
87
|
+
# kv = KV_pair.new(key,value,"")
|
88
|
+
# xmlfile.kv_pairs << kv
|
89
|
+
# }
|
90
|
+
# p xmlfile.to_hash(:with_comments => false)
|
4
91
|
|
5
92
|
|
data/lib/repoaccessor/version.rb
CHANGED
data/lib/repoaccessor/xmlfile.rb
CHANGED
@@ -1,6 +1,32 @@
|
|
1
1
|
|
2
2
|
module Repoaccessor
|
3
3
|
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
class KV_pair
|
7
|
+
attr_accessor :key
|
8
|
+
attr_accessor :value
|
9
|
+
attr_accessor :comment
|
10
|
+
|
11
|
+
def initialize(key,value,comment)
|
12
|
+
@key = key
|
13
|
+
@value = value
|
14
|
+
@comment = comment
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def to_hash
|
19
|
+
{
|
20
|
+
:key => @key,
|
21
|
+
:value => @value,
|
22
|
+
:comment => @comment
|
23
|
+
}
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
4
30
|
class XMLFile
|
5
31
|
attr_accessor :kv_pairs
|
6
32
|
|
@@ -9,24 +35,36 @@ module Repoaccessor
|
|
9
35
|
end
|
10
36
|
|
11
37
|
def key_values
|
12
|
-
#TODO
|
38
|
+
#TODO:不影响主功能
|
13
39
|
end
|
14
40
|
|
15
41
|
def keys
|
16
|
-
#TODO
|
42
|
+
#TODO:不影响主功能
|
17
43
|
end
|
18
44
|
|
19
45
|
def values
|
20
|
-
#TODO
|
46
|
+
#TODO:不影响主功能
|
21
47
|
end
|
22
48
|
|
23
|
-
def to_hash
|
24
|
-
|
49
|
+
def to_hash(args={})
|
50
|
+
with_comments = args[:with_comments].nil? ? true : args[:with_comments]
|
51
|
+
build_hash { |hash, pair|
|
52
|
+
hash_value = with_comments ? { pair.value => pair.comment } : pair.value
|
53
|
+
hash[pair.key] = hash_value
|
54
|
+
}
|
25
55
|
end
|
26
56
|
|
27
57
|
def to_json
|
28
|
-
|
58
|
+
self.to_hash(:with_comments => false).to_json
|
29
59
|
end
|
60
|
+
|
61
|
+
def build_hash(&block)
|
62
|
+
hash = {}
|
63
|
+
@kv_pairs.each do |pair|
|
64
|
+
yield hash, pair
|
65
|
+
end
|
66
|
+
hash
|
67
|
+
end
|
30
68
|
|
31
69
|
end
|
32
70
|
|
@@ -1,12 +1,22 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
module Repoaccessor
|
4
|
+
require "rexml/document"
|
4
5
|
require "repoaccessor/xmlfile"
|
5
6
|
|
6
7
|
class XMLParser
|
7
8
|
#returning an XMLFile object , with to_hash to_json method.
|
8
9
|
def self.parse(file)
|
9
|
-
|
10
|
+
xmlfile = XMLFile.new()
|
11
|
+
resourcefile = File.new(file)
|
12
|
+
doc = REXML::Document.new resourcefile
|
13
|
+
doc.elements.each("resources/string") { |e|
|
14
|
+
key = e.attributes["name"]
|
15
|
+
value = e.text
|
16
|
+
kv = KV_pair.new(key,value,"")
|
17
|
+
xmkfile.kv_pairs << kv
|
18
|
+
}
|
19
|
+
xmlfile
|
10
20
|
end
|
11
21
|
end
|
12
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repoaccessor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 卡迩
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|