raystool 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/bin/__rays_exec.rb +31 -0
  2. data/bin/__rays_init +79 -0
  3. data/lib/rays/config/backup.rb +42 -0
  4. data/lib/rays/config/configuration.rb +376 -0
  5. data/lib/rays/config/environment.rb +73 -0
  6. data/lib/rays/config/templates/global/global.yml +3 -0
  7. data/lib/rays/config/templates/global/scripts/rays +187 -0
  8. data/lib/rays/config/templates/project/.rays +0 -0
  9. data/lib/rays/config/templates/project/config/environment.yml +68 -0
  10. data/lib/rays/config/templates/project/config/project.yml +4 -0
  11. data/lib/rays/core.rb +128 -0
  12. data/lib/rays/exceptions/rays_exception.rb +25 -0
  13. data/lib/rays/interface/commander.rb +394 -0
  14. data/lib/rays/interface/controller.rb +365 -0
  15. data/lib/rays/loaders/highline.rb +24 -0
  16. data/lib/rays/loaders/logging.rb +60 -0
  17. data/lib/rays/models/appmodule/base.rb +185 -0
  18. data/lib/rays/models/appmodule/content.rb +35 -0
  19. data/lib/rays/models/appmodule/ext.rb +36 -0
  20. data/lib/rays/models/appmodule/hook.rb +36 -0
  21. data/lib/rays/models/appmodule/layout.rb +36 -0
  22. data/lib/rays/models/appmodule/manager.rb +130 -0
  23. data/lib/rays/models/appmodule/portlet.rb +36 -0
  24. data/lib/rays/models/appmodule/servicebuilder.rb +36 -0
  25. data/lib/rays/models/appmodule/theme.rb +36 -0
  26. data/lib/rays/models/project.rb +116 -0
  27. data/lib/rays/servers/base.rb +70 -0
  28. data/lib/rays/servers/database.rb +73 -0
  29. data/lib/rays/servers/liferay.rb +64 -0
  30. data/lib/rays/servers/solr.rb +111 -0
  31. data/lib/rays/services/application_service.rb +116 -0
  32. data/lib/rays/services/backup_service.rb +94 -0
  33. data/lib/rays/services/database.rb +59 -0
  34. data/lib/rays/services/remote.rb +75 -0
  35. data/lib/rays/services/scm.rb +92 -0
  36. data/lib/rays/services/sync.rb +90 -0
  37. data/lib/rays/utils/common_utils.rb +153 -0
  38. data/lib/rays/utils/file_utils.rb +118 -0
  39. data/lib/rays/utils/network_utils.rb +50 -0
  40. data/lib/rays/workers/base.rb +134 -0
  41. data/lib/rays/workers/builder.rb +63 -0
  42. data/lib/rays/workers/cleaner.rb +42 -0
  43. data/lib/rays/workers/deployer.rb +92 -0
  44. data/lib/rays/workers/generator.rb +49 -0
  45. metadata +175 -0
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env bash
2
+
3
+ rays() {
4
+ if [[ $# > 0 && "go" == $1 ]] ;then
5
+ cd `__rays_exec.rb $@`
6
+ else
7
+ __rays_exec.rb $@
8
+ fi
9
+ }
10
+
11
+ #
12
+ # Completion
13
+ #
14
+
15
+ # Borrowed from tig, which borrowed from git
16
+ _rayscomp () {
17
+ local all c s=$'\n' IFS=' '$'\t'$'\n'
18
+ local cur="${COMP_WORDS[COMP_CWORD]}"
19
+ if [ $# -gt 2 ]; then
20
+ cur="$3"
21
+ fi
22
+ for c in $1; do
23
+ case "$c$4" in
24
+ --*=*) all="$all$c$4$s" ;;
25
+ *.) all="$all$c$4$s" ;;
26
+ *) all="$all$c$4 $s" ;;
27
+ esac
28
+ done
29
+ IFS=$s
30
+ COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
31
+ return
32
+ }
33
+
34
+ _rays_dir () {
35
+ local cwd="$(pwd)" dir=
36
+
37
+ while true; do
38
+ if [ -e "$cwd/.rays" ]; then
39
+ echo "$cwd"
40
+ return
41
+ else
42
+ cd "$cwd/.."
43
+ fi
44
+ if [ "$cwd" -eq "$(pwd)" ]; then
45
+ return
46
+ fi
47
+ cwd="$(pwd)"
48
+ done
49
+ }
50
+
51
+ _rays_module_types="portlet hook theme layout ext"
52
+
53
+ _rays_module_find () {
54
+ local dir="$1/$2s" glob="*-$2"
55
+
56
+ case "$2" in ext) dir="$1/$2" ;; esac
57
+
58
+ if [ -d "$dir" ]; then
59
+ find "$dir/" -maxdepth 1 -type d -name "$glob" -printf "%f "
60
+ fi
61
+ }
62
+
63
+ # Completes module by type
64
+ _rays_module () {
65
+ local i=$1 c=$((++i)) module_dir='' module_glob=
66
+ local dir="$(_rays_dir)"
67
+
68
+ while [[ $c -lt $COMP_CWORD ]] && [ -z "$module_dir" ]; do
69
+ case "${COMP_WORDS[c]}" in
70
+ portlet|hook|theme|layout|ext|servicebuilder)
71
+ _rays_module_find "$dir" "${COMP_WORDS[c]}"
72
+ return
73
+ ;;
74
+ esac
75
+ c=$((++c))
76
+ done
77
+
78
+ if [ -n "$dir" ]; then
79
+ echo "$_rays_module_types"
80
+ for i in $_rays_module_types; do
81
+ _rays_module_find "$dir" "$i"
82
+ done
83
+ fi
84
+ }
85
+
86
+ _rays_complete () {
87
+ local i c=1 command
88
+ local default_args="
89
+ --silent --debug -h --help
90
+ "
91
+
92
+ # Search for command
93
+ while [ $c -lt $COMP_CWORD ]; do
94
+ i="${COMP_WORDS[c]}"
95
+ case "$i" in
96
+ -*) ;;
97
+ *) command="$i"; break ;;
98
+ esac
99
+ c=$((++c))
100
+ done
101
+
102
+ # No command
103
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
104
+ _rayscomp "
105
+ $default_args
106
+ new
107
+ init
108
+ g
109
+ build
110
+ deploy
111
+ clean
112
+ env
113
+ point
114
+ points
115
+ go
116
+ liferay
117
+ solr
118
+ modules
119
+ "
120
+ return
121
+ fi
122
+
123
+ case "$command" in
124
+ new|init|points|modules)
125
+ _rayscomp "
126
+ $default_args
127
+ "
128
+ ;;
129
+ g)
130
+ _rayscomp "
131
+ $_rays_module_types
132
+ $default_args
133
+ "
134
+ ;;
135
+ build)
136
+ _rayscomp "
137
+ $(_rays_module "$c")
138
+ $default_args
139
+ "
140
+ ;;
141
+ deploy)
142
+ _rayscomp "
143
+ $(_rays_module "$c")
144
+ --skip-test $default_args
145
+ "
146
+ ;;
147
+ clean)
148
+ _rayscomp "
149
+ $(_rays_module "$c")
150
+ $default_args
151
+ "
152
+ ;;
153
+ env)
154
+ local envs="$(rays env --list)"
155
+ if [ "$envs" != "Cannot find project root." ]; then
156
+ _rayscomp "
157
+ $envs --list $default_args
158
+ "
159
+ fi
160
+ ;;
161
+ point)
162
+ _rayscomp "
163
+ --remove $default_args
164
+ "
165
+ ;;
166
+ go)
167
+ if [ $c -eq $((COMP_CWORD - 1)) ]; then
168
+ _rayscomp "$(rays points | cut -f 1 -d':')"
169
+ fi
170
+ ;;
171
+
172
+ liferay)
173
+ _rayscomp "
174
+ start debug stop status log
175
+ --force $default_args
176
+ "
177
+ ;;
178
+ solr)
179
+ _rayscomp "
180
+ clean start debug stop log status
181
+ $default_args
182
+ "
183
+ ;;
184
+ esac
185
+ }
186
+
187
+ complete -o default -o nospace -F _rays_complete rays
File without changes
@@ -0,0 +1,68 @@
1
+ local:
2
+ liferay:
3
+ host: localhost
4
+ port: 8080
5
+ deploy: /opt/liferay-portal/deploy
6
+ data: /opt/liferay-portal/data
7
+ java:
8
+ home: /usr/lib/jvm/java-6-sun
9
+ bin: /usr/bin/java
10
+ service:
11
+ path: /opt/liferay-portal/tomcat
12
+ start_command: bin/startup.sh
13
+ debug_command: bin/catalina.sh jpda start
14
+ stop_command: bin/shutdown.sh
15
+ log_file: logs/catalina.out
16
+ database:
17
+ host: localhost
18
+ port: 3306
19
+ type: mysql
20
+ name: liferay
21
+ username: root
22
+ password: ""
23
+ solr:
24
+ host: localhost
25
+ port: 8085
26
+ url: solr
27
+ service:
28
+ path: /opt/solr-server/apache-tomcat
29
+ start_command: bin/startup.sh
30
+ stop_command: bin/shutdown.sh
31
+ log_file: logs/catalina.out
32
+ backup:
33
+ directory: /tmp/backup
34
+ stop: false
35
+ test:
36
+ liferay:
37
+ host: 127.0.0.1
38
+ port: 8080
39
+ deploy: /opt/liferay-portal/deploy
40
+ data: /opt/liferay-portal/data
41
+ java:
42
+ home: /usr/lib/jvm/java-6-sun
43
+ bin: /usr/bin/java
44
+ service:
45
+ path: /opt/liferay-portal/tomcat
46
+ start_command: bin/startup.sh
47
+ debug_command: bin/catalina.sh jpda start
48
+ stop_command: bin/shutdown.sh
49
+ log_file: logs/catalina.out
50
+ database:
51
+ host: localhost
52
+ port: 3306
53
+ type: mysql
54
+ name: liferay
55
+ username: root
56
+ password: ""
57
+ solr:
58
+ host: localhost
59
+ port: 8085
60
+ url: solr
61
+ service:
62
+ path: /opt/solr-server/apache-tomcat
63
+ start_command: bin/startup.sh
64
+ stop_command: bin/shutdown.sh
65
+ log_file: logs/catalina.out
66
+ backup:
67
+ directory: /tmp/backup
68
+ stop: false
@@ -0,0 +1,4 @@
1
+ name: project
2
+ liferay: 6.1.0
3
+ package: com.example.liferay
4
+
data/lib/rays/core.rb ADDED
@@ -0,0 +1,128 @@
1
+ =begin
2
+ Copyright (c) 2012 Dmitri Carpov
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ =end
23
+ require 'singleton'
24
+
25
+ module Rays
26
+
27
+ class Core
28
+ include Singleton
29
+
30
+ def initialize
31
+ load_third_party_dependencies
32
+ load_system_wide_dependencies
33
+ load_external_loaders
34
+ load_system_wide_utilities
35
+ load_servers
36
+ load_services
37
+
38
+ configure
39
+
40
+ load_workers
41
+ load_models
42
+ end
43
+
44
+ def reload
45
+ $rays_config = Rays::Configuration.new
46
+ end
47
+
48
+ private
49
+ def configure
50
+ $rays_config = Rays::Configuration.new
51
+ end
52
+
53
+ def load_system_wide_dependencies
54
+ require 'rays/exceptions/rays_exception'
55
+ require 'rays/config/backup'
56
+ require 'rays/config/environment'
57
+ require 'rays/config/configuration'
58
+ end
59
+
60
+ def load_external_loaders
61
+ # loaders
62
+ Dir[File.dirname(__FILE__) + '/loaders/*.rb'].each do |file|
63
+ require "rays/loaders/#{File.basename(file)}"
64
+ end
65
+ end
66
+
67
+ def load_system_wide_utilities
68
+ require 'rays/utils/common_utils'
69
+ require 'rays/utils/file_utils'
70
+ require 'rays/utils/network_utils'
71
+ end
72
+
73
+ def load_servers
74
+ require 'rays/servers/base'
75
+ require 'rays/servers/liferay'
76
+ require 'rays/servers/database'
77
+ require 'rays/servers/solr'
78
+ end
79
+
80
+ def load_services
81
+ require 'rays/services/sync'
82
+ require 'rays/services/backup_service'
83
+ require 'rays/services/remote'
84
+ require 'rays/services/application_service'
85
+ require 'rays/services/scm'
86
+ require 'rays/services/database'
87
+ end
88
+
89
+ def load_workers
90
+ require 'rays/workers/base'
91
+ require 'rays/workers/generator'
92
+ require 'rays/workers/builder'
93
+ require 'rays/workers/deployer'
94
+ require 'rays/workers/cleaner'
95
+ end
96
+
97
+ def load_models
98
+ require 'rays/models/appmodule/manager'
99
+ require 'rays/models/appmodule/base'
100
+ require 'rays/models/appmodule/portlet'
101
+ require 'rays/models/appmodule/servicebuilder'
102
+ require 'rays/models/appmodule/ext'
103
+ require 'rays/models/appmodule/hook'
104
+ require 'rays/models/appmodule/theme'
105
+ require 'rays/models/appmodule/layout'
106
+ require 'rays/models/appmodule/content'
107
+ require 'rays/models/project'
108
+ end
109
+
110
+ def load_third_party_dependencies
111
+ require 'fileutils'
112
+ require 'find'
113
+ require 'yaml'
114
+ require 'logger'
115
+ require 'colorize'
116
+ require 'net/ssh'
117
+ require 'rsolr'
118
+ require 'socket'
119
+ require 'timeout'
120
+ require 'highline'
121
+ require 'safe_shell'
122
+ require 'nokogiri'
123
+ end
124
+ end
125
+ end
126
+
127
+ # Load core
128
+ Rays::Core.instance
@@ -0,0 +1,25 @@
1
+ =begin
2
+ Copyright (c) 2012 Dmitri Carpov
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ =end
23
+
24
+ class RaysException < RuntimeError
25
+ end