pushify 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
data/bin/pushify CHANGED
@@ -30,6 +30,7 @@ else
30
30
  print "Installing Pushify..."
31
31
  Pushify::Install.install!
32
32
  puts "success!"
33
+
33
34
  ARGV.clear
34
35
  ARGV.push("start")
35
36
  end
@@ -40,11 +41,12 @@ else
40
41
  print "Stopping pushify server..."
41
42
  system("kill #{File.read(pid)}")
42
43
  system("rm #{pid}")
44
+ system("killall pushify_server.rb")
43
45
  else
44
46
  print "Starting pushify server..."
45
47
  config = File.exist?("config/juggernaut.yml") ? "config/juggernaut.yml" : File.join(File.dirname(__FILE__), "..", "install", "juggernaut.yml")
46
48
  system("juggernaut -c#{config} -d -P #{pid}")
49
+ Daemons.run_proc(File.join(pids, 'pushify_server.rb')) { Pushify::Server.run }
47
50
  end
48
- Daemons.run_proc(File.join(pids, 'pushify_server.rb')) { Pushify::Server.run }
49
51
  puts "success!"
50
52
  end
@@ -19,7 +19,14 @@ module Pushify
19
19
  return false if File.open('Gemfile', 'r').read.match(/\s*gem\s+['"]pushify['"]/)
20
20
 
21
21
  File.open('Gemfile', 'a') do |f|
22
- f.write("\n\ngem 'pushify'\n")
22
+ f.write("\n\ngroup :development do\n gem 'pushify'\nend\n")
23
+ end
24
+
25
+ split_on = "Demo3::Application.configure do"
26
+ parts = File.read('config/environments/development.rb').split(split_on)
27
+
28
+ File.open('config/environments/development.rb', "w") do |f|
29
+ f.puts parts.join(split_on + "\n\n config.middleware.use Pushify::Rack")
23
30
  end
24
31
  true
25
32
  end
data/lib/pushify/rack.rb CHANGED
@@ -6,17 +6,17 @@ module Pushify
6
6
 
7
7
  def call(env)
8
8
  path = env["REQUEST_URI"]
9
+
9
10
  if (Pushify::Rails::Assets.includes?(path))
10
11
  Pushify::Rails::Assets.response(path)
11
12
  else
12
13
  status, headers, response = @app.call(env)
13
14
 
14
15
  is_html = !response.is_a?(Array) && (headers["Content-Type"].nil? || headers["Content-Type"].include?("text/html"))
15
-
16
16
  if (is_html && response.body.match(/<\/body>/))
17
17
  pushify_src = Pushify.javascript_src
18
18
  response.body = response.body.gsub(/(<\/body>)/, "#{pushify_src}</body>")
19
- headers["Content-Length"] = (headers["Content-Length"].to_i + pushify_src.size).to_s
19
+ headers["Content-Length"] = (response.body.size).to_s
20
20
  end
21
21
 
22
22
  [status, headers, response]
data/lib/pushify/rails.rb CHANGED
@@ -6,8 +6,11 @@ module Pushify
6
6
  def self.initialize
7
7
  ActionView::Base.send(:include, Pushify::Helper)
8
8
 
9
- if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
10
- ::Rails.configuration.middleware.use("Pushify::Rack")
9
+
10
+ if (::Rails.version.start_with?("2"))
11
+ if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
12
+ ::Rails.configuration.middleware.use("Pushify::Rack")
13
+ end
11
14
  end
12
15
  end
13
16
 
@@ -39,12 +42,17 @@ module Pushify
39
42
  end
40
43
  end
41
44
 
45
+ def self.just_the_path(path)
46
+ m = path.match(/https?:\/\/[-A-Za-z0-9\.:]*(\/.*)/)
47
+ m ? m[1] : path
48
+ end
49
+
42
50
  def self.includes?(path)
43
- self.assets.keys.include?(path)
51
+ self.assets.keys.include?(just_the_path(path))
44
52
  end
45
53
 
46
54
  def self.response(path)
47
- asset = self.assets[path]
55
+ asset = self.assets[just_the_path(path)]
48
56
  [200, {"Content-Type" => asset[0]}, [self.asset_body(asset[1])]]
49
57
  end
50
58
  end
Binary file
data/pushify.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
@@ -15,34 +15,33 @@ Gem::Specification.new do |s|
15
15
  s.executables = ["pushify"]
16
16
  s.files = [
17
17
  ".specification",
18
- "LICENSE",
19
- "README.markdown",
20
- "ROADMAP",
21
- "Rakefile",
22
- "VERSION",
23
- "bin/pushify",
24
- "install/expressinstall.swf",
25
- "install/json.js",
26
- "install/juggernaut.js",
27
- "install/juggernaut.swf",
28
- "install/juggernaut.yml",
29
- "install/juggernaut_hosts.yml",
30
- "install/pushify.js",
31
- "install/swfobject.js",
32
- "lib/pushify.rb",
33
- "lib/pushify/helper.rb",
34
- "lib/pushify/install.rb",
35
- "lib/pushify/juggernaut.rb",
36
- "lib/pushify/rack.rb",
37
- "lib/pushify/rails.rb",
38
- "lib/pushify/server.rb",
39
- "pkg/pushify-1.0.0.gem",
40
- "pushify.gemspec",
41
- "spec/css_push_spec.rb",
42
- "spec/spec_helper.rb"
18
+ "LICENSE",
19
+ "README.markdown",
20
+ "ROADMAP",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "bin/pushify",
24
+ "install/expressinstall.swf",
25
+ "install/json.js",
26
+ "install/juggernaut.js",
27
+ "install/juggernaut.swf",
28
+ "install/juggernaut.yml",
29
+ "install/juggernaut_hosts.yml",
30
+ "install/pushify.js",
31
+ "install/swfobject.js",
32
+ "lib/pushify.rb",
33
+ "lib/pushify/helper.rb",
34
+ "lib/pushify/install.rb",
35
+ "lib/pushify/juggernaut.rb",
36
+ "lib/pushify/rack.rb",
37
+ "lib/pushify/rails.rb",
38
+ "lib/pushify/server.rb",
39
+ "pkg/pushify-1.0.0.gem",
40
+ "pushify.gemspec",
41
+ "spec/css_push_spec.rb",
42
+ "spec/spec_helper.rb"
43
43
  ]
44
44
  s.homepage = %q{http://github.com/tilleryj/pushify}
45
- s.rdoc_options = ["--charset=UTF-8"]
46
45
  s.require_paths = ["lib"]
47
46
  s.rubygems_version = %q{1.3.7}
48
47
  s.summary = %q{See updates you make to css, html, javascript, and images appear immediately in all of your browsers without having to refresh.}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Tillery
@@ -59,8 +59,8 @@ homepage: http://github.com/tilleryj/pushify
59
59
  licenses: []
60
60
 
61
61
  post_install_message:
62
- rdoc_options:
63
- - --charset=UTF-8
62
+ rdoc_options: []
63
+
64
64
  require_paths:
65
65
  - lib
66
66
  required_ruby_version: !ruby/object:Gem::Requirement