gogreen 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data/lib/gogreen.rb +105 -0
  4. data.tar.gz.sig +0 -0
  5. metadata +127 -0
  6. metadata.gz.sig +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2567506918651fb6e419a913a28f54b073b664b2
4
+ data.tar.gz: 60271864979e343fccd6500e34dd386945198561
5
+ SHA512:
6
+ metadata.gz: 5d2ae5ffc9a1220cd01f3451b40c0354735e76c55f41f6571720865c468e4c0b22447e0701a39c26565d310b013b1b549c815248779adad65ed1a4ee987dc26f
7
+ data.tar.gz: 6aabc752682293cdf67bac18a390e8180ee30ad43a31c92309de5a16cf3d10fa3ddc3120ce5cbdf0887ba25429f18a6f22b1b3168ab990ea8c769a8941513366
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ m�h�@�jv���P]b�Z/S,���+�{���"Ԑ�<����auv*#y�h��T6���~<��y�+x��.G�w>�S2�P��U��P��+B �q`V��.t��(�c�d^x��]�V�O@� ��"͘S���!�x�׬[F�Ir�ūV{�m�}��H�-�J@�k=b�����]�Raɱ�A(�v����J�f�%(�2w����Z�0��Ke�
data/lib/gogreen.rb ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: gogreen.rb
4
+
5
+ require 'rscript'
6
+ require 'dynarex'
7
+ require 'acronym'
8
+
9
+
10
+ class GoGreenException < Exception
11
+ end
12
+
13
+ class GoGreen
14
+
15
+ def initialize(alias_file, site=nil, subdomain=nil)
16
+
17
+ buffer = RXFHelper.read(alias_file).first
18
+
19
+ name = case buffer
20
+ when /^<\?dynarex/
21
+ @records = dxread(buffer)
22
+ when /^<\?polyrex/
23
+ @records, @conf = pxread(buffer, site, subdomain)
24
+ else
25
+ raise GoGreenException, 'alias file ' + alias_file + ' not recognised'
26
+ end
27
+
28
+ end
29
+
30
+ def execute(alias_name, job_args=[])
31
+
32
+ alias_found = @records[alias_name]
33
+ return 'job not found' unless alias_found
34
+
35
+ cmd = alias_found[:body][:command]
36
+ cmd += ' ' + @conf if @conf
37
+
38
+ if cmd[/^rcscript/] then
39
+
40
+ a = cmd.sub(/^rcscript /,'').split + job_args.map do |x|
41
+ x.sub(/^["'](.*)["']$/,'\1')
42
+ end
43
+
44
+ code2, args = RScript.new.read a
45
+
46
+ begin
47
+ eval(code2)
48
+ rescue
49
+ ($!).to_s[/^[^\n]+/].to_s
50
+ end
51
+
52
+ else
53
+ `#{cmd} #{job_args.join(' ')}`
54
+ end
55
+
56
+ end
57
+
58
+ private
59
+
60
+ def dxread(s)
61
+
62
+ dx = Dynarex.new
63
+ dx.parse s
64
+
65
+ records = if dx.summary.include? :include then
66
+
67
+ buffer = RXFHelper.read(dx.summary[:include]).first
68
+ dx2 = Dynarex.new.parse buffer
69
+ dx2.records.merge(dx.records)
70
+ else
71
+ dx.records
72
+ end
73
+
74
+ records
75
+ end
76
+
77
+ def pxread(alias_file, site, subdomain)
78
+
79
+ px = Polyrex.new
80
+ px.parse buffer2
81
+
82
+ a = px.rxpath "site[label='#{site}']/subdomain[label='#{subdomain}']"
83
+ raise GoGreenException, "site not found " if a.empty?
84
+
85
+ rec = a.first
86
+
87
+ [rec.to_dynarex.records, rec.conf]
88
+ end
89
+
90
+ end
91
+
92
+ if $0 == __FILE__ then
93
+
94
+ aliases_file, args = ARGV
95
+
96
+ gg = GoGreen.new aliases_file
97
+
98
+ if args.is_a?(String) then
99
+ puts gg.execute alias_name=args
100
+ else
101
+ alias_name = args.shift
102
+ puts gg.execute alias_name, args
103
+ end
104
+
105
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gogreen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autor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hvR8bqb54Z+64YIeseXVV/jheSoZ
28
+ yP/CKngHWvgTbII4kNpWKSuQQB4bcQ4N/Ti5Mx0G0XILB3kJinI+Od4I4nucwgcO
29
+ ScRR/L3yBTRUWJsBzKEwYu/pkJm4JF/h+DnhjFsK/Kl/aIJLHen6S8KwgGW2D4yZ
30
+ 5nmxFXbYqZr1wyy0b9HgTP66CO/ifkFlxnMDIlyHcg9ehxLxbo1zS7nCQ4yRQBzc
31
+ fxGSO2N1hJlOaabiyPprkSP8DNu8AkyuJ0CtzF003LE+iM/x/YbkXZKiN2/VSCII
32
+ fBUnJw9rwbKnlw==
33
+ -----END CERTIFICATE-----
34
+ date: 2015-01-19 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: rscript
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.1'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.27
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.1'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.1.27
56
+ - !ruby/object:Gem::Dependency
57
+ name: dynarex
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.3'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.3.5
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.3'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.5
76
+ - !ruby/object:Gem::Dependency
77
+ name: acronym
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.1'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.1.4
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.1'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.1.4
96
+ description:
97
+ email: james@r0bertson.co.uk
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - lib/gogreen.rb
103
+ homepage: https://github.com/jrobertson/gogreen
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Run RSF jobs from the command line using a Dynarex flavoured aliases file.
127
+ test_files: []
metadata.gz.sig ADDED
Binary file