ustate-client 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,6 +62,7 @@ module UState
62
62
 
63
63
  # Send state to client
64
64
  def flush
65
+ @state.time = Time.now.to_i
65
66
  @client << @state
66
67
  end
67
68
 
@@ -91,6 +92,7 @@ module UState
91
92
  end
92
93
  flush
93
94
  end
95
+ alias << merge
94
96
 
95
97
  # Issues an immediate update of the state with the :once option
96
98
  # set, but does not update the local state. Useful for transient errors.
@@ -100,6 +102,7 @@ module UState
100
102
  opts.each do |k, v|
101
103
  o.send "#{k}=", v
102
104
  end
105
+ o.time = Time.now.to_i
103
106
  o.once = true
104
107
  @client << o
105
108
  end
@@ -100,6 +100,12 @@ module UState
100
100
  end
101
101
  end
102
102
 
103
+ # Add an additional public directory.
104
+ def self.public_dir(dir)
105
+ require 'ustate/dash/rack/static'
106
+ use UState::Dash::Static, :root => dir
107
+ end
108
+
103
109
  def client
104
110
  self.class.client
105
111
  end
@@ -1,7 +1,7 @@
1
1
  module UState
2
2
  class Dash
3
3
  helpers do
4
- include Rack::Utils
4
+ include ::Rack::Utils
5
5
 
6
6
  alias_method :h, :escape_html
7
7
 
@@ -0,0 +1,16 @@
1
+ class UState::Dash::Static
2
+ def initialize(app, options = {})
3
+ @app = app
4
+ @root = options[:root] or raise ArgumentError, "no root"
5
+ @file_server = ::Rack::File.new(@root)
6
+ end
7
+
8
+ def call(env)
9
+ r = @file_server.call env
10
+ if r[0] == 404
11
+ @app.call env
12
+ else
13
+ r
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module UState
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ustate-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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: 2011-09-17 00:00:00.000000000Z
12
+ date: 2011-09-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beefcake
16
- requirement: &73107330 !ruby/object:Gem::Requirement
16
+ requirement: &76033910 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.3.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *73107330
24
+ version_requirements: *76033910
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: trollop
27
- requirement: &73106920 !ruby/object:Gem::Requirement
27
+ requirement: &76033510 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.16.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *73106920
35
+ version_requirements: *76033510
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mtrc
38
- requirement: &73106530 !ruby/object:Gem::Requirement
38
+ requirement: &76033170 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.0.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *73106530
46
+ version_requirements: *76033170
47
47
  description:
48
48
  email: aphyr@aphyr.com
49
49
  executables: []
@@ -70,6 +70,7 @@ files:
70
70
  - lib/ustate/query.rb
71
71
  - lib/ustate/client/query.rb
72
72
  - lib/ustate/client.rb
73
+ - lib/ustate/dash/rack/static.rb
73
74
  - lib/ustate/dash/views/index.erubis
74
75
  - lib/ustate/dash/views/layout.erubis
75
76
  - lib/ustate/dash/views/css.scss