pxg 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/pxg +8 -3
- data/lib/pxg.rb +28 -1
- metadata +32 -4
- checksums.yaml +0 -15
data/bin/pxg
CHANGED
@@ -5,9 +5,12 @@ require 'pxg'
|
|
5
5
|
|
6
6
|
if ARGV.length > 0
|
7
7
|
pxg = Pxg.new;
|
8
|
-
|
8
|
+
actual_command = ARGV.shift
|
9
|
+
command = actual_command.gsub ':', '_'
|
9
10
|
if pxg.respond_to? command
|
10
11
|
pxg.send command, ARGV
|
12
|
+
else # ! nyx.respond_to? command
|
13
|
+
puts " err: unknown command #{actual_command}"
|
11
14
|
end#if
|
12
15
|
else # ARGV.length == 0
|
13
16
|
|
@@ -15,8 +18,10 @@ puts
|
|
15
18
|
puts <<eos
|
16
19
|
Commands
|
17
20
|
------------------------------------------------------------------------------
|
18
|
-
pxg version
|
19
|
-
pxg compile [<dir>]
|
21
|
+
pxg version - current interface version
|
22
|
+
pxg compile [<dir>] - reads pxg.json from directory and resolves it
|
23
|
+
pxg reimage [<xml>] [new-urls.txt] - reads urls from new-urls.txt replaces all attachment
|
24
|
+
images with urls in new urls
|
20
25
|
eos
|
21
26
|
|
22
27
|
end#if
|
data/lib/pxg.rb
CHANGED
@@ -5,11 +5,38 @@ require 'fileutils'
|
|
5
5
|
# gems
|
6
6
|
require 'git'
|
7
7
|
require 'json'
|
8
|
+
require 'xmlsimple'
|
8
9
|
|
9
10
|
class Pxg
|
10
11
|
|
11
12
|
VERSION = '1.1.0'
|
12
13
|
|
14
|
+
def reimage(argv)
|
15
|
+
xml = argv[0]
|
16
|
+
new_images = argv[1]
|
17
|
+
text = File.read new_images
|
18
|
+
text.strip!
|
19
|
+
image_urls = text.split "\n"
|
20
|
+
# read xml
|
21
|
+
xml_data = File.read xml
|
22
|
+
# eg image: http://pixelgrade.com/demos/bucket/wp-content/uploads/2013/10/kelly-brooks.jpg
|
23
|
+
# locate all images
|
24
|
+
rimages = xml_data.scan /(http(s){0,1}:\/\/[^"<>]*\/[0-9]{4}\/[0-9]{2}\/[^"<>]+\.(jpg|png|tiff|gif))/
|
25
|
+
targets = []
|
26
|
+
rimages.each do |arr|
|
27
|
+
match_data = arr[0].match /(http(s){0,1}:\/\/[^"<>]*\/)([0-9]{4}\/[0-9]{2}\/[^"<>]+\.(jpg|png|tiff|gif))/
|
28
|
+
targets.push([match_data[0], match_data[1], arr[0].gsub(match_data[1], '')])
|
29
|
+
end#each
|
30
|
+
|
31
|
+
targets.each do |img|
|
32
|
+
random_image = image_urls.sample.split ' '
|
33
|
+
xml_data.gsub! img[0], random_image[1]
|
34
|
+
xml_data.gsub! img[2], img[2][0..7] + random_image[0]
|
35
|
+
end#each
|
36
|
+
|
37
|
+
puts xml_data
|
38
|
+
end#def
|
39
|
+
|
13
40
|
def find_and_replace(path, search, replace)
|
14
41
|
clean_path = path.sub(/(\/)+$/, '') + '/'
|
15
42
|
Dir.glob "#{clean_path}**/*.php" do |file|
|
@@ -43,7 +70,7 @@ class Pxg
|
|
43
70
|
srcpath = File.expand_path(rawsrcpath) + '/'
|
44
71
|
localpath = File.expand_path(rawlocalpath) + '/'
|
45
72
|
themepath = File.expand_path(rawthemepath) + '/'
|
46
|
-
Dir.glob
|
73
|
+
Dir.glob("#{srcpath}**/*", File::FNM_DOTMATCH) do |file|
|
47
74
|
next if file == '.' or file == '..'
|
48
75
|
filepath = File.expand_path(file)
|
49
76
|
filesubpath = filepath.sub srcpath, ''
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pxg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- srcspider
|
@@ -13,6 +14,7 @@ dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: git
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -23,6 +25,7 @@ dependencies:
|
|
23
25
|
type: :runtime
|
24
26
|
prerelease: false
|
25
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
26
29
|
requirements:
|
27
30
|
- - ! '>='
|
28
31
|
- !ruby/object:Gem::Version
|
@@ -33,6 +36,7 @@ dependencies:
|
|
33
36
|
- !ruby/object:Gem::Dependency
|
34
37
|
name: json
|
35
38
|
requirement: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ! '>='
|
38
42
|
- !ruby/object:Gem::Version
|
@@ -43,6 +47,7 @@ dependencies:
|
|
43
47
|
type: :runtime
|
44
48
|
prerelease: false
|
45
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
46
51
|
requirements:
|
47
52
|
- - ! '>='
|
48
53
|
- !ruby/object:Gem::Version
|
@@ -50,6 +55,28 @@ dependencies:
|
|
50
55
|
- - <
|
51
56
|
- !ruby/object:Gem::Version
|
52
57
|
version: '2.0'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: xml-simple
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '1.1'
|
66
|
+
- - <
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.1'
|
77
|
+
- - <
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '2.0'
|
53
80
|
description: Pixelgrade Utilities
|
54
81
|
email: source.spider@gmail.com
|
55
82
|
executables:
|
@@ -62,25 +89,26 @@ files:
|
|
62
89
|
homepage: http://rubygems.org/gems/pxg
|
63
90
|
licenses:
|
64
91
|
- MIT
|
65
|
-
metadata: {}
|
66
92
|
post_install_message:
|
67
93
|
rdoc_options: []
|
68
94
|
require_paths:
|
69
95
|
- lib
|
70
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
71
98
|
requirements:
|
72
99
|
- - ! '>='
|
73
100
|
- !ruby/object:Gem::Version
|
74
101
|
version: '0'
|
75
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
76
104
|
requirements:
|
77
105
|
- - ! '>='
|
78
106
|
- !ruby/object:Gem::Version
|
79
107
|
version: '0'
|
80
108
|
requirements: []
|
81
109
|
rubyforge_project:
|
82
|
-
rubygems_version:
|
110
|
+
rubygems_version: 1.8.24
|
83
111
|
signing_key:
|
84
|
-
specification_version:
|
112
|
+
specification_version: 3
|
85
113
|
summary: Project managing helpers
|
86
114
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ZDNiM2M0YmM0MzYyMzY5ZGQ2NzdkYjhmZjVlZDIzNTNkOGRjOWU2Zg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NWIwNjczZDNmYTRlYTUyYmE5MDc2M2EwNTk0MzY4ZDY3NmFhYjZlZg==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
Mzc2M2QyZTUyNjIwMTZkNzc2YzgzMzM0ZDgxMWFhZWExODE2MzU3Mzk3NzZj
|
10
|
-
NDE4YzdjYjQ3MWZiYmFiYzBkMzNiYWY3MmFjM2FhZTYwYjcxMDY4MmZkM2Rh
|
11
|
-
YTE3ZDM0ODMwMTI2ZmFkNjEwOTk4ZDFkNDY1NWEzYzY0NWM4NDA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZmYwMmYwNmYyYTk4M2MxNzMwNjVjMDhmY2Y4NGNmZDA1NDAwNGYxOGVhY2Rj
|
14
|
-
OTFmZGE3ZWRkZGE5MmFiZTcxNGY5ZjU2MTUyYTM1ODI0OThjYmUzMDNkNDE1
|
15
|
-
ZWEzZWVkZTNlYjg4ZjYwOTE5M2RmN2QyNGY3MDdjYjllODlmOWE=
|