socky-client-rails 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 0.4.3 / 2010-11-05
5
+
6
+ - new features:
7
+ - generator for Rails 2
8
+ - download socky.js instead of including it in this lib
9
+ - bugfixes:
10
+ - none
11
+
4
12
  ## 0.4.2 / 2010-11-04
5
13
 
6
14
  - new features:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
@@ -0,0 +1,10 @@
1
+ class SockyGenerator < Rails::Generator::Base
2
+
3
+ def manifest # this method is default entrance of generator
4
+ record do |m|
5
+ m.directory File.join('lib', 'tasks')
6
+ m.template 'socky.rake', File.join('lib', 'tasks', 'socky.rake')
7
+ end
8
+ end
9
+
10
+ end
@@ -0,0 +1,5 @@
1
+ begin
2
+ Dir["#{Gem.searcher.find('socky-client-rails').full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext }
3
+ rescue
4
+ puts 'You are missing socky-client-rails gem. Please install it.'
5
+ end
@@ -1,8 +1,14 @@
1
1
  require 'fileutils'
2
2
 
3
- SOCKY_SCRIPTS = ['/socky.js', '/socky']
4
- SOURCE_PREFIX = File.join(File.dirname(__FILE__), '..', '..', 'assets')
5
- DEST_PREFIX = Rails.root.join('public', 'javascripts').to_s
3
+ SOCKY_JS_VERSION = File.read(File.dirname(__FILE__) + '/../../VERSION').strip.split('.')[0,2].join('.')
4
+ SOCKY_JS_SERVER = 'https://github.com/socky/socky-js/raw'
5
+ SOCKY_JS_DEST = Rails.root.join('public', 'javascripts').to_s
6
+ SOCKY_JS_FILES = {
7
+ 'socky.js' => 'socky.js',
8
+ 'WebSocketMain.swf' => 'socky/WebSocketMain.swf'
9
+ }
10
+
11
+ CONFIG_PATH = File.join(File.dirname(__FILE__), '..', '..', 'assets', 'socky_hosts.yml')
6
12
 
7
13
  namespace :socky do
8
14
  desc 'Install the Socky scripts and create configuration file'
@@ -15,56 +21,62 @@ namespace :socky do
15
21
  task :uninstall => [:remove_scripts]
16
22
 
17
23
  task :create_config do
18
- source = SOURCE_PREFIX + '/socky_hosts.yml'
19
24
  dest = Rails.root.join('config', 'socky_hosts.yml').to_s
20
25
  if File.exists?(dest)
21
- puts "Removing #{dest}."
22
26
  FileUtils.rm_rf dest
23
27
  end
24
28
  begin
25
- puts "Copying to #{dest}."
26
- FileUtils.cp_r source, dest
27
- puts "Successfully updated #{dest}."
29
+ puts "Copying config..."
30
+ FileUtils.cp_r CONFIG_PATH, dest
31
+ puts "Done"
28
32
  rescue
29
- puts "ERROR: Problem creating config. Please manually copy " + source + " to " + dest
33
+ puts "ERROR: Problem creating config. Please manually copy " + CONFIG_PATH + " => " + dest
30
34
  end
31
35
  end
32
36
 
33
37
 
34
38
  task :create_scripts do
35
- SOCKY_SCRIPTS.each do |file_suffix|
36
- source = SOURCE_PREFIX + file_suffix
37
- dest = DEST_PREFIX + file_suffix
38
- if File.exists?(dest)
39
- puts "Removing #{dest}."
40
- FileUtils.rm_rf dest
41
- end
39
+ require 'open-uri'
40
+ puts 'Downloading files...'
41
+ SOCKY_JS_FILES.each do |source, dest|
42
42
  begin
43
- puts "Copying to #{dest}."
44
- FileUtils.cp_r source, dest
45
- puts "Successfully updated #{dest}."
43
+ uri = URI.parse(SOCKY_JS_SERVER + '/v' + SOCKY_JS_VERSION + '-stable/' + source)
44
+ file = File.join(SOCKY_JS_DEST, dest)
45
+ puts ' + ' + dest
46
+ FileUtils.mkdir_p(File.dirname(file))
47
+ open(uri) do |data|
48
+ open(file, "wb") do |f|
49
+ f.write(data.read)
50
+ end
51
+ end
46
52
  rescue
47
- puts "ERROR: Problem updating scripts. Please manually copy " + source + " to " + dest
53
+ puts "ERROR: Problem downloading script. Please manually copy " + uri.to_s + " => " + file
54
+ end
55
+ end
56
+ script_file = File.join(SOCKY_JS_DEST, 'socky.js').to_s
57
+ if File.exists?(script_file)
58
+ puts 'Updating assets info'
59
+ text = File.read(script_file)
60
+ open(script_file, 'wb') do |f|
61
+ f.write text.gsub('WEB_SOCKET_SWF_LOCATION = "WebSocketMain.swf"', 'WEB_SOCKET_SWF_LOCATION = "/javascripts/socky/WebSocketMain.swf"')
48
62
  end
49
63
  end
64
+ puts "Done"
50
65
  end
51
66
 
52
67
  task :remove_scripts do
53
- SOCKY_SCRIPTS.each do |dest_suffix|
54
- dest = DEST_PREFIX + dest_suffix
55
- if File.exists?(dest)
56
- begin
57
- puts "Removing #{dest}..."
58
- FileUtils.rm_rf dest
59
- puts "Successfully removed #{dest}"
60
- rescue
61
- puts "ERROR: Problem removing #{dest}. Please remove manually."
62
- end
63
- else
64
- puts "ERROR: #{dest} not found."
68
+ puts 'Removing files...'
69
+ SOCKY_JS_FILES.each do |source, dest|
70
+ file = SOCKY_JS_DEST + dest
71
+ if File.exists?(file)
72
+ begin
73
+ FileUtils.rm_rf file
74
+ rescue
75
+ puts "ERROR: Problem removing #{file}. Please remove manually."
76
+ end
65
77
  end
66
78
  end
67
79
  puts "Successfully removed Socky."
68
80
  end
69
81
 
70
- end
82
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socky-client-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bernard Potocki
@@ -62,9 +62,9 @@ files:
62
62
  - README.md
63
63
  - Rakefile
64
64
  - VERSION
65
- - assets/socky.js
66
- - assets/socky/WebSocketMain.swf
67
65
  - assets/socky_hosts.yml
66
+ - generators/socky/socky_generator.rb
67
+ - generators/socky/templates/socky.rake
68
68
  - init.rb
69
69
  - lib/socky-client-rails.rb
70
70
  - lib/socky-client-rails/helper.rb
Binary file