pxg 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/bin/pxg +18 -1
  3. data/lib/pxg.rb +61 -4
  4. metadata +42 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjE5NDJmYWU2Mzk2YTQ3ZTM4NTkzZmIxYTIzZjgwMTQwYzc5MzhkZg==
4
+ YjEzYzYzYzkxZjU5MTFiYzA5NzY0YmY4N2JhNWYwMGZmNDY5ZWQ3Nw==
5
5
  data.tar.gz: !binary |-
6
- YzI3ZmNmNzNlMGYxOGUxNzJlOGFhZTA5ZTkyZDMwZDM5Y2RhNDcyNQ==
6
+ ZGZkYTFlMWI2N2Q1OTMzOGIxYzQ1MjBlNDRmODk2YTY0NjJmOTFiMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2M2OGJiZDAwNDNhNzM2MGMxODc5NmEwY2NiZmQxNjMyZjVjZGRiMDdjNTVh
10
- MmI4NDI4MDYyZDU3YmFkODkzMjUyOGNjODhkNmQ5Y2FmMmQ3N2JhODQwN2U4
11
- ZTRlNTliNDE2M2VkN2JlNGMyM2FiZThjNjdiMzhmM2E4MzEzMGU=
9
+ Y2I4YTNhYjI4YjQwY2VjNDVlY2FiMjQwNTU2NjdiY2ZjNWUwNzA1ZjE3MGQ1
10
+ MTdhMDlhNzMxZDU0Yjc2OTBlMWIyMTkyYWIxZjM2Mzc1MTFiYWYyOTI0ZTA4
11
+ MzA0MDMwNmI0M2RiYjY2ZDgzOTc3YjU2NDZjZDQ2ODBhNjVjNTQ=
12
12
  data.tar.gz: !binary |-
13
- NWYwYmJiMDY0NzYzYWViMTI3ODhhZWNlYWRmODAwYzgwMTk0NWYyNWZlMzJl
14
- YjE0ZTkyMGE2YzgxOGZlMTQwNGQwYjZlNjZmNzMzNjg1NTc5YzI4NDRlMjk0
15
- ZjgxZWMxZTNjYWNhZGI5MDUzOTIzOWZkYzFlYTdjODVmZjA4OTE=
13
+ OWQxNGY1MTM5MTAzNTQxZTA3MGZjNTFmY2I4NjhjMmEyZDZmMzE4ODM3YzE4
14
+ ZjBmZTI5MDkzNmIxY2U2ZTEzZWRiNjczMjBlMDQ5OWUyZjY3MGQ3MmMzOTFl
15
+ ODJiMjU1Y2M4ODVmNzViNDM2NDgwNjA3NWFjNmUyNWFhOGU3ODY=
data/bin/pxg CHANGED
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: utf-8
2
3
 
3
4
  require 'pxg'
4
- puts Pxg.hi(ARGV[0])
5
+
6
+ if ARGV.length > 0
7
+ pxg = Pxg.new;
8
+ command = ARGV.shift
9
+ if pxg.respond_to? command
10
+ pxg.send command, ARGV
11
+ end#if
12
+ else # ARGV.length == 0
13
+
14
+ puts
15
+ puts <<eos
16
+ Commands
17
+ ------------------------------------------------------------------------------
18
+ pxg compile <dir> - reads pxg.json from directory and resolves it
19
+ eos
20
+
21
+ end#if
data/lib/pxg.rb CHANGED
@@ -1,5 +1,62 @@
1
+ # native
2
+ require 'Logger'
3
+ require 'fileutils'
4
+
5
+ # gems
6
+ require 'git'
7
+ require 'json'
8
+
1
9
  class Pxg
2
- def self.hi(to)
3
- "hello #{to}"
4
- end
5
- end
10
+
11
+ def find_and_replace(path, search, replace)
12
+ clean_path = path.sub(/(\/)+$/, '') + '/'
13
+ Dir.glob "#{clean_path}**/*.php" do |file|
14
+ next if file == '.' or file == '..'
15
+ text = File.read file
16
+ text = text.gsub search, replace
17
+ File.write file, text
18
+ end
19
+ end#def
20
+
21
+ def wp_core(path, conf)
22
+ Dir.chdir path
23
+ core_path = conf['path'].sub(/(\/)+$/, '')
24
+ puts "processing #{core_path}"
25
+ # remove the core if it exists
26
+ FileUtils.rm_rf core_path
27
+ # clone a fresh copy
28
+ puts "cloning #{conf['repo']} -> #{conf['version']}"
29
+ g = Git.clone conf['repo'], core_path
30
+ g.checkout conf['version']
31
+ FileUtils.rm_rf core_path+'/.git'
32
+ # refactor name space
33
+ ns_src = conf['namespace']['src']
34
+ ns_target = conf['namespace']['target']
35
+ puts "refactoring #{core_path}"
36
+ self.find_and_replace core_path, ns_src, ns_target
37
+ self.find_and_replace core_path, ns_src.capitalize, ns_target.capitalize
38
+ end#def
39
+
40
+ def compile(args)
41
+ dirpath = args[0].sub(/(\/)+$/,'')+'/';
42
+ if ! File.exist? dirpath
43
+ puts 'Err: target directory does not exist.'
44
+ return;
45
+ end
46
+
47
+ jsonconfigfile = dirpath+'pxg.json';
48
+ if ! File.exist? jsonconfigfile
49
+ puts 'Err: Missing pxg.json file in target directory.'
50
+ return;
51
+ end
52
+
53
+ conf = JSON.parse(open(jsonconfigfile).read);
54
+
55
+ conf['wp-cores'].each do |wpcoreconf|
56
+ self.wp_core dirpath, wpcoreconf
57
+ end#each
58
+
59
+ puts 'fin'
60
+ end#def
61
+
62
+ end#class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - srcspider
@@ -9,7 +9,47 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-08-09 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.6
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.6
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: json
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '1.8'
40
+ - - <
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '1.8'
50
+ - - <
51
+ - !ruby/object:Gem::Version
52
+ version: '2.0'
13
53
  description: Pixelgrade Utilities
14
54
  email: source.spider@gmail.com
15
55
  executables: