raystool 1.1.8 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/__rays_exec.rb CHANGED
@@ -23,9 +23,12 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
23
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
24
  =end
25
25
 
26
- require 'rays/interface/commander'
27
-
28
26
  begin
27
+ $command = ARGV[0]
28
+ if '--debug'.eql? $command
29
+ $command = ARGV[1]
30
+ end
31
+ require 'rays/interface/commander'
29
32
  RaysCommand.run('rays', ARGV, {})
30
33
  rescue => e
31
34
  end
@@ -34,7 +34,13 @@ module Rays
34
34
  @silent = false
35
35
  $global_config_path ||= "#{ENV['HOME']}/.rays_config"
36
36
  @global_config_file = nil
37
- load_config
37
+
38
+ init_global_config
39
+
40
+ init_project_root
41
+ unless @project_root.nil?
42
+ load_project_config
43
+ end
38
44
  end
39
45
 
40
46
  #
@@ -58,8 +64,9 @@ module Rays
58
64
  # Set environment
59
65
  #
60
66
  def environment=(environment_name)
67
+ project_root # check if it's inside a project dir
61
68
  if environments.include?(environment_name)
62
- yaml_file = get_dot_rays_file
69
+ yaml_file = get_profile_file
63
70
  yaml_file.properties['environment'] = environment_name
64
71
  yaml_file.write
65
72
  Core.instance.reload
@@ -158,12 +165,12 @@ module Rays
158
165
  #
159
166
  # Initializes environments and project parameters.
160
167
  #
161
- def load_config
162
- log_block('process configuration file') do
163
- init_global_config
164
- init_project_root
165
- return if @project_root.nil?
166
-
168
+ def load_project_config
169
+ log_block('load project configuration') do
170
+ skip_version_check_commands = %w(go point points version)
171
+ unless skip_version_check_commands.include? $command
172
+ version_check
173
+ end
167
174
  init_environments
168
175
  end
169
176
  end
@@ -178,6 +185,13 @@ module Rays
178
185
  @project_root = Rays::Utils::FileUtils.find_up('.rays')
179
186
  end
180
187
 
188
+ #
189
+ # Check version
190
+ #
191
+ def version_check
192
+ Rays::Service::UpdateManager.new(get_dot_rays_file).check
193
+ end
194
+
181
195
  #
182
196
  # Main initialization method.
183
197
  # Load environments and set the first declared environment as default.
@@ -276,7 +290,7 @@ module Rays
276
290
 
277
291
 
278
292
  # load current environment
279
- yaml_file = get_dot_rays_file
293
+ yaml_file = get_profile_file
280
294
  env = yaml_file.properties['environment']
281
295
  if @environments.include?(env)
282
296
  @environment = @environments[env]
@@ -334,6 +348,12 @@ module Rays
334
348
  Utils::FileUtils::YamlFile.new dot_rays_file
335
349
  end
336
350
 
351
+ def get_profile_file
352
+ profile_file = File.join(project_root, 'config/.profile')
353
+ FileUtils.touch profile_file unless File.exists? profile_file
354
+ Utils::FileUtils::YamlFile.new profile_file
355
+ end
356
+
337
357
  #
338
358
  # GLOBAL CONFIGURATION PROCESSING
339
359
  #
@@ -0,0 +1 @@
1
+ version: 1.2.0
@@ -2,13 +2,14 @@ local:
2
2
  liferay:
3
3
  host: localhost
4
4
  port: 8080
5
- deploy: /opt/liferay-portal/deploy
6
- data: /opt/liferay-portal/data
5
+ root: /opt/liferay-portal
6
+ deploy: deploy
7
+ data: data
7
8
  java:
8
9
  home: /usr/lib/jvm/java-6-sun
9
10
  bin: /usr/bin/java
10
11
  service:
11
- path: /opt/liferay-portal/tomcat
12
+ path: tomcat
12
13
  start_command: bin/startup.sh
13
14
  debug_command: bin/catalina.sh jpda start
14
15
  stop_command: bin/shutdown.sh
data/lib/rays/core.rb CHANGED
@@ -84,6 +84,7 @@ module Rays
84
84
  require 'rays/services/application_service'
85
85
  require 'rays/services/scm'
86
86
  require 'rays/services/database'
87
+ require 'rays/services/update_manager'
87
88
  end
88
89
 
89
90
  def load_workers
@@ -307,9 +307,18 @@ class RaysCommand < Clamp::Command
307
307
  #
308
308
  # SYNC
309
309
  #
310
- subcommand 'sync', 'synchronize local environment with the current one' do
310
+ #subcommand 'sync', 'synchronize local environment with the current one' do
311
+ # def execute
312
+ # Rays::Controller.instance.sync
313
+ # end
314
+ #end
315
+
316
+ #
317
+ # UPDATE
318
+ #
319
+ subcommand 'update', 'update project configuration to the current version of rays' do
311
320
  def execute
312
- Rays::Controller.instance.sync
321
+ Rays::Controller.instance.update
313
322
  end
314
323
  end
315
324
 
@@ -209,13 +209,19 @@ module Rays
209
209
  end
210
210
  end
211
211
 
212
- def sync
213
- if 'local'.eql?($rays_config.environment.name)
214
- $log.warn("Select not local environment to import to local.")
215
- return
216
- end
217
- log_block("synchronize environments") do
218
- Rays::Service::Sync.new.sync
212
+ #def sync
213
+ # if 'local'.eql?($rays_config.environment.name)
214
+ # $log.warn("Select not local environment to import to local.")
215
+ # return
216
+ # end
217
+ # log_block("synchronize environments") do
218
+ # Rays::Service::Sync.new.sync
219
+ # end
220
+ #end
221
+
222
+ def update
223
+ log_block('update') do
224
+ Rays::Service::Updater.instance.update
219
225
  end
220
226
  end
221
227
 
@@ -0,0 +1,110 @@
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
+ module Rays
25
+ module Service
26
+ class UpdateManager
27
+
28
+ def initialize(rays_content)
29
+ @current_version = nil
30
+ @rays_content = rays_content
31
+
32
+ unless rays_content.nil?
33
+ version_string = rays_content.properties['version']
34
+ if !version_string.nil? and !version_string.strip.empty?
35
+ @current_version = Gem::Version.create version_string
36
+ end
37
+ end
38
+
39
+ if @current_version.nil?
40
+ @current_version ||= Gem::Version.create '1.1.9'
41
+ rays_content.properties['version'] = @current_version.to_s
42
+ rays_content.write
43
+ end
44
+
45
+ @updaters = Hash.new
46
+ @updaters[Gem::Version.create('1.2.0')] = 'update_1_2_0'
47
+ end
48
+
49
+ def check
50
+ if @current_version < @updaters.keys.max
51
+ $log.error "Your project version is #{@current_version.to_s}. Your rays version is #{@updaters.keys.max.to_s}. Press 'Enter' to update or 'ctrl+c' to abort."
52
+ begin
53
+ STDIN.gets.chomp
54
+ rescue Interrupt
55
+ exit
56
+ end
57
+ update
58
+ elsif @current_version > @updaters.keys.max
59
+ $log.error "Your project version is higher than rays one. It is highly recommended to upgrade your rays ('gem update raystool') before continue. Press 'Enter' to continue or 'ctrl+c' to abort."
60
+ begin
61
+ STDIN.gets.chomp
62
+ rescue Interrupt
63
+ exit
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ def update
70
+ @updaters.keys.sort.each do |version|
71
+ if @current_version < version
72
+ $log.info "Updating project to version #{version.to_s}"
73
+ begin
74
+ self.send @updaters[version]
75
+ sync_version version
76
+ rescue => e
77
+ $log.warn "Failed to update to version #{version.to_s}. Please report on http://github.com/dmitri-carpov/rays/issues"
78
+ $log.error "\n\n#{e}.\nBacktrace:\r\n#{e.backtrace.join("\r\n")}"
79
+ exit
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ private
86
+
87
+ def update_1_2_0
88
+ environment = @rays_content.properties['environment']
89
+ if !environment.nil? && !environment.empty?
90
+ project_dir = Utils::FileUtils::find_up '.rays'
91
+ config_dir = File.join(project_dir, 'config')
92
+ profile_file = File.join(config_dir, '.profile')
93
+ FileUtils.touch profile_file
94
+ profile = Utils::FileUtils::YamlFile.new profile_file
95
+ profile.properties['environment'] = environment
96
+ profile.write
97
+
98
+ $log.warn("Please add #{profile_file.sub(project_dir + '/', '')} to your scm ignore file.")
99
+ end
100
+ @rays_content.properties.delete('environment')
101
+ end
102
+
103
+ def sync_version version
104
+ @rays_content.properties['version'] = version.to_s
105
+ @rays_content.write
106
+ @current_version = version
107
+ end
108
+ end
109
+ end
110
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raystool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-25 00:00:00.000000000 Z
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
16
- requirement: &73584570 !ruby/object:Gem::Requirement
16
+ requirement: &85607120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *73584570
24
+ version_requirements: *85607120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rsolr
27
- requirement: &73584290 !ruby/object:Gem::Requirement
27
+ requirement: &85606900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *73584290
35
+ version_requirements: *85606900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: colorize
38
- requirement: &73583820 !ruby/object:Gem::Requirement
38
+ requirement: &85606690 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *73583820
46
+ version_requirements: *85606690
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: net-ssh
49
- requirement: &73583370 !ruby/object:Gem::Requirement
49
+ requirement: &85606480 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *73583370
57
+ version_requirements: *85606480
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: highline
60
- requirement: &73583140 !ruby/object:Gem::Requirement
60
+ requirement: &85606270 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *73583140
68
+ version_requirements: *85606270
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: safe_shell
71
- requirement: &73582910 !ruby/object:Gem::Requirement
71
+ requirement: &85606060 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *73582910
79
+ version_requirements: *85606060
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: nokogiri
82
- requirement: &73582620 !ruby/object:Gem::Requirement
82
+ requirement: &85605850 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *73582620
90
+ version_requirements: *85605850
91
91
  description: Command line tool to create and manage liferay projects
92
92
  email: dmitri.carpov@gmail.com
93
93
  executables:
@@ -121,6 +121,7 @@ files:
121
121
  - lib/rays/servers/solr.rb
122
122
  - lib/rays/servers/base.rb
123
123
  - lib/rays/services/application_service.rb
124
+ - lib/rays/services/update_manager.rb
124
125
  - lib/rays/services/remote.rb
125
126
  - lib/rays/services/database.rb
126
127
  - lib/rays/services/sync.rb