repoaccessor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c83898680ee4af27afe897f9a7d57dc2fa872a52
4
+ data.tar.gz: f0f9539685529a563ba02c486741be6aa003602f
5
+ SHA512:
6
+ metadata.gz: d12ef35d1a7b5e0031903e8e643b3ee8c7b5a1676ed9923709fe55651771b381553c34d35cd885a596a2bb57e41455b1ccedbaed17fd13fc8d9275efd842b026
7
+ data.tar.gz: d1c1b22e3c68c72338e0027581270e8957accada006cb93b6867fe4c8bdae0b982a0daf0c361fa1ea559857f194b40a934786326641c5c60a97693522e377df3
@@ -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,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.6
@@ -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 repoaccessor.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
+ # Repoaccessor
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/repoaccessor`. 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 'repoaccessor'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install repoaccessor
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. Then, run `rake true` to run the tests. 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]/repoaccessor. 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 "repoaccessor"
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,29 @@
1
+
2
+ require "repoaccessor/version"
3
+
4
+
5
+ module Repoaccessor
6
+ require "repoaccessor/repo"
7
+ require "repoaccessor/configuration"
8
+ require "repoaccessor/subversion"
9
+ require "repoaccessor/git"
10
+ require "json"
11
+
12
+ def self.checkout(usrname,pwd,url,dstPath,force = true,type = "svn")
13
+ if type == "svn"
14
+ client = Svn.new(usrname,pwd)
15
+ client.checkout(url,dstPath)
16
+ else
17
+ # TODO : Git ...
18
+ end
19
+ end
20
+
21
+
22
+ def self.inspect_repo(path,platform = "ios")
23
+ repo = Repo.new(path,platform)
24
+ repo.to_hash.to_json
25
+ end
26
+
27
+ end
28
+
29
+
@@ -0,0 +1,107 @@
1
+ module Repoaccessor
2
+ require "apstrings"
3
+ require "repoaccessor/stringsparser"
4
+ require "repoaccessor/xmlparser"
5
+
6
+ class Bundle
7
+ attr_accessor :bundle_path
8
+ attr_accessor :platform
9
+ attr_accessor :name
10
+ attr_accessor :resources_files
11
+ attr_accessor :parsed
12
+ attr_accessor :host_project
13
+
14
+ def initialize(path,platform = "ios")
15
+ @bundle_path = path
16
+ @platform = platform
17
+ @name = File.basename(path)
18
+ @resources_files = []
19
+ @parsed = false
20
+ @host_project = self.host_project
21
+ end
22
+
23
+ def reourcefile_extention
24
+ if @platform == "ios"
25
+ "*.strings"
26
+ elsif @platform == "android"
27
+ "*.xml"
28
+ end
29
+ end
30
+
31
+
32
+ def resource_file_paths
33
+ Dir.chdir(@bundle_path)
34
+ files = []
35
+ extention = reourcefile_extention
36
+ Dir.glob(File.join("**", "#{extention}")) { |file|
37
+ files << File.expand_path(file)
38
+ }
39
+ files
40
+ end
41
+
42
+ def host_project
43
+ if @platform == "ios"
44
+ p @bundle_path
45
+ Dir.chdir(@bundle_path)
46
+ Dir.chdir(File.expand_path("..", Dir.pwd))
47
+ Dir.chdir(File.expand_path("..", Dir.pwd))
48
+ proj_name = Dir.glob("*.xcodeproj")
49
+ if !proj_name && proj_name.empty?
50
+ "unkonwn"
51
+ else
52
+ proj_name[0]
53
+ end
54
+ elsif @platform == "android"
55
+
56
+ else
57
+ "unkonwn"
58
+ end
59
+ end
60
+
61
+
62
+ def parse(args = {})
63
+ @parsed = true
64
+ with_comments = args[:with_comments].nil? ? false : args[:with_comments]
65
+ if @platform == "ios"
66
+ resource_file_paths.each { |file|
67
+ file_hash = {}
68
+ file_hash[:lang] = File.basename(file,".*")
69
+ file_hash[:kv_pairs] = StringsParser::parse(file).to_hash(:with_comments => with_comments)
70
+ @resources_files << file_hash
71
+ }
72
+
73
+ elsif @platform == "android"
74
+ resource_file_paths.each { |file|
75
+ file_hash = {}
76
+ file_hash[:lang] = File.basename(file,".*")
77
+ file_hash[:kv_pairs] = XMLParser::parse(file).to_hash
78
+ @resources_files << file_hash
79
+ }
80
+ else
81
+ raise "Unsupported platform"
82
+ end
83
+
84
+ end
85
+
86
+ def to_hash(args={})
87
+
88
+ if @parsed == false then
89
+ self.parse(args)
90
+ end
91
+ {
92
+ :name => @name,
93
+ :host_project => @host_project,
94
+ :path => @bundle_path,
95
+ :platform => @platform,
96
+ :parsed => @parsed,
97
+ :resources_files => @resources_files
98
+ }
99
+ end
100
+
101
+ def to_json(args={})
102
+ self.to_hash.to_json
103
+ end
104
+
105
+ end
106
+
107
+ end
@@ -0,0 +1,17 @@
1
+
2
+ module Repoaccessor
3
+ require "yaml"
4
+ class Configuration
5
+ def initialize(config_file_path = nil)
6
+ @config = YAML.load_file(config_file_path)
7
+ end
8
+
9
+ def repo_info(repo_name,version = @config["version"])
10
+ module_for_name = @config["modules"].select {
11
+ |m| m["name"] == repo_name && m["version"] == version
12
+ }
13
+ module_for_name[0]
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,11 @@
1
+ module Repoaccessor
2
+
3
+ class Git
4
+ def initialize(args)
5
+ #TODO
6
+ end
7
+
8
+ end
9
+
10
+
11
+ end
@@ -0,0 +1,58 @@
1
+
2
+
3
+ module Repoaccessor
4
+
5
+ require "json"
6
+ require "repoaccessor/bundle"
7
+
8
+ class Repo
9
+
10
+ attr_accessor :rootpath
11
+ attr_accessor :platform
12
+ attr_accessor :resource_file_extention
13
+ attr_accessor :branch_url
14
+ attr_accessor :repo_name
15
+
16
+ def initialize(path,platform = "ios")
17
+ @rootpath = path
18
+ @platform = platform
19
+ @resource_file_extention = (platform == "ios" ? "*.strings" : "*.xml")
20
+ @repo_name = File.basename(path,".*")
21
+ end
22
+
23
+ def bundle_paths
24
+ Dir.chdir(@rootpath)
25
+ paths = []
26
+ Dir.glob(File.join("**", "*.bundle")) { |file|
27
+ paths << File.expand_path(file)
28
+ }
29
+ paths
30
+ end
31
+
32
+ def parsed_bundles
33
+ bundles = []
34
+ self.bundle_paths.each {
35
+ |path|
36
+ Dir.chdir(path)
37
+ file_pattern = File.join("**", "#{@resource_file_extention}")
38
+ resource_files = Dir.glob(file_pattern)
39
+ if !resource_files.empty?
40
+ bundles << (Bundle.new(path,@platform).to_hash())
41
+ end
42
+ }
43
+ bundles
44
+ end
45
+
46
+
47
+ def to_hash
48
+ {
49
+ :repo_name => @repo_name,
50
+ :platform => @platform,
51
+ :resource_file_extention => @resource_file_extention,
52
+ :bunldes => self.parsed_bundles
53
+ }
54
+
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,50 @@
1
+
2
+
3
+ module Repoaccessor
4
+
5
+ require "json"
6
+ require "repoaccessor/bundle"
7
+
8
+ class Repo
9
+
10
+ attr_accessor :rootpath
11
+ attr_accessor :platform
12
+ attr_accessor :resource_file_extention
13
+ attr_accessor :branch_url
14
+ attr_accessor :repo_name
15
+
16
+ def initialize(path,platform = "ios")
17
+ @rootpath = path
18
+ @platform = platform
19
+ @resource_file_extention = (platform == "ios" ? "*.strings" : "*.xml")
20
+ end
21
+
22
+ def bundle_paths
23
+ Dir.chdir(@rootpath)
24
+ paths = []
25
+ Dir.glob(File.join("**", "*.bundle")) { |file|
26
+ bundle_name = File.basename(file)
27
+ puts " \n \n------------------"
28
+ puts "Found #{bundle_name}...."
29
+ puts "-------------------------"
30
+ paths << File.expand_path(file)
31
+ }
32
+ paths
33
+ end
34
+
35
+ def parse_repo
36
+ bundles = []
37
+ self.bundle_paths.each {
38
+ |path|
39
+ Dir.chdir(path)
40
+ file_pattern = File.join("**", "#{@resource_file_extention}")
41
+ resource_files = Dir.glob(file_pattern)
42
+ if !resource_files.empty?
43
+ bundles << (Bundle.new(path,@platform).to_hash())
44
+ end
45
+ }
46
+ bundles
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,13 @@
1
+
2
+ module Repoaccessor
3
+ require 'apstrings'
4
+ class StringsParser
5
+ #returning an DotStringFile object , with to_hash to_json method.
6
+ def self.parse(file)
7
+ Apstrings::parse(file)
8
+ end
9
+ end
10
+
11
+ end
12
+
13
+
@@ -0,0 +1,45 @@
1
+ require 'yaml'
2
+
3
+ module Repoaccessor
4
+ class Svn
5
+ attr :repository_base
6
+ attr :svnadmin
7
+ attr :svn
8
+
9
+ def initialize(username,pwd)
10
+ @svn = `which svn`.strip
11
+ @svnadmin = `which svnadmin`.strip
12
+ @username = username
13
+ @password = pwd
14
+ end
15
+
16
+ def commit(working_copy, message)
17
+ `cd #{working_copy} && #{@svn} commit -m "#{message}"`
18
+ end
19
+
20
+ def add(working_copy, file)
21
+ `cd #{working_copy} && #{@svn} add #{file}`
22
+ end
23
+
24
+ def update(working_copy)
25
+ `cd #{working_copy} && #{@svn} up`
26
+ end
27
+
28
+ def checkout(repository, working_copy_path)
29
+ `mkdir -p "#{working_copy_path}"`
30
+ system "svn", "co", "#{repository}", "#{working_copy_path}", "--username", "#{@username}", "--password", "#{@password}", "--no-auth-cache", "--non-interactive" # checkout
31
+ $?.success?
32
+ end
33
+
34
+ def info(working_copy)
35
+ result = `#{@svn} info #{working_copy}`
36
+ yaml = YAML.load(result)
37
+ yaml['Revision'].to_s
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+
44
+
45
+
@@ -0,0 +1,5 @@
1
+
2
+ require "yaml"
3
+ require "json"
4
+
5
+
@@ -0,0 +1,3 @@
1
+ module Repoaccessor
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,34 @@
1
+
2
+ module Repoaccessor
3
+
4
+ class XMLFile
5
+ attr_accessor :kv_pairs
6
+
7
+ def initialize
8
+ @kv_pairs = []
9
+ end
10
+
11
+ def key_values
12
+ #TODO
13
+ end
14
+
15
+ def keys
16
+ #TODO
17
+ end
18
+
19
+ def values
20
+ #TODO
21
+ end
22
+
23
+ def to_hash
24
+ #TODO
25
+ end
26
+
27
+ def to_json
28
+ #TODO
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
@@ -0,0 +1,13 @@
1
+
2
+
3
+ module Repoaccessor
4
+ require "repoaccessor/xmlfile"
5
+
6
+ class XMLParser
7
+ #returning an XMLFile object , with to_hash to_json method.
8
+ def self.parse(file)
9
+ raise "Not implemented yet ..."
10
+ end
11
+ end
12
+
13
+ end
@@ -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 'repoaccessor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "repoaccessor"
8
+ spec.version = Repoaccessor::VERSION
9
+ spec.authors = ["卡迩"]
10
+ spec.email = ["lj94409@alipay.com"]
11
+
12
+ spec.summary = %q{Repo accessor.}
13
+ spec.description = %q{Repo accessor.}
14
+ spec.homepage = "https://github.com/JasonWorking"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
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.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "true"
26
+ spec.add_development_dependency "json"
27
+ spec.add_development_dependency "yaml"
28
+ spec.add_development_dependency "apstring"
29
+
30
+
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: repoaccessor
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-10-19 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
+ - !ruby/object:Gem::Dependency
42
+ name: 'true'
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yaml
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
+ - !ruby/object:Gem::Dependency
84
+ name: apstring
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Repo accessor.
98
+ email:
99
+ - lj94409@alipay.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - CODE_OF_CONDUCT.md
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/repoaccessor.rb
114
+ - lib/repoaccessor/bundle.rb
115
+ - lib/repoaccessor/configuration.rb
116
+ - lib/repoaccessor/git.rb
117
+ - lib/repoaccessor/repo.rb
118
+ - lib/repoaccessor/repo_parser.rb
119
+ - lib/repoaccessor/stringsparser.rb
120
+ - lib/repoaccessor/subversion.rb
121
+ - lib/repoaccessor/tester.rb
122
+ - lib/repoaccessor/version.rb
123
+ - lib/repoaccessor/xmlfile.rb
124
+ - lib/repoaccessor/xmlparser.rb
125
+ - repoaccessor.gemspec
126
+ homepage: https://github.com/JasonWorking
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.0.14
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: Repo accessor.
150
+ test_files: []