strobe 0.2.0.beta.1 → 0.2.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/strobe/association.rb +22 -0
- data/lib/strobe/cli/main.rb +8 -1
- data/lib/strobe/cli/preview.rb +23 -4
- data/lib/strobe/collection.rb +4 -2
- data/lib/strobe/connection.rb +20 -1
- data/lib/strobe/resource/base.rb +12 -2
- data/lib/strobe/resource/collection.rb +24 -4
- data/lib/strobe/resource/singleton.rb +5 -0
- data/lib/strobe/resources/application.rb +5 -0
- data/lib/strobe/resources/me.rb +1 -1
- data/lib/strobe/resources/membership.rb +2 -2
- data/lib/strobe/resources/signup.rb +2 -2
- metadata +26 -15
data/lib/strobe/association.rb
CHANGED
@@ -13,6 +13,10 @@ module Strobe
|
|
13
13
|
'Strobe::Resources::' + name.to_s.classify
|
14
14
|
end
|
15
15
|
|
16
|
+
def target_pluralized
|
17
|
+
name.to_s.pluralize
|
18
|
+
end
|
19
|
+
|
16
20
|
def target
|
17
21
|
@target ||= target_name.constantize
|
18
22
|
end
|
@@ -25,10 +29,28 @@ module Strobe
|
|
25
29
|
!options.key?(:autoload) || options[:autoload]
|
26
30
|
end
|
27
31
|
|
32
|
+
def nested?
|
33
|
+
options[:nested]
|
34
|
+
end
|
35
|
+
|
28
36
|
def include?
|
29
37
|
options[:include]
|
30
38
|
end
|
31
39
|
|
40
|
+
def denormalize_params(item, params)
|
41
|
+
return item unless targets = params[target_pluralized]
|
42
|
+
|
43
|
+
if collection?
|
44
|
+
raise NotImplemented
|
45
|
+
else
|
46
|
+
if id = item["#{name}_id"]
|
47
|
+
return item.merge(name.to_s => targets.find { |t| t["id"] == id })
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
item
|
52
|
+
end
|
53
|
+
|
32
54
|
def reader
|
33
55
|
ruby = []
|
34
56
|
ruby << "def #{name}"
|
data/lib/strobe/cli/main.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "bpm"
|
2
|
+
|
1
3
|
module Strobe
|
2
4
|
class CLI::Main < CLI
|
3
5
|
include CLI::Preview
|
@@ -159,7 +161,8 @@ module Strobe
|
|
159
161
|
|
160
162
|
host = resource.deploy! :environment => options[:staging] && 'staging',
|
161
163
|
:callback => CLI::DeployProgress.new,
|
162
|
-
:sproutcore => is_sproutcore
|
164
|
+
:sproutcore => is_sproutcore?,
|
165
|
+
:bpm_project => bpm_project
|
163
166
|
|
164
167
|
say "The application has successfully been deployed and is available at #{host}"
|
165
168
|
end
|
@@ -257,6 +260,10 @@ module Strobe
|
|
257
260
|
File.exist?("#{path}/Buildfile")
|
258
261
|
end
|
259
262
|
|
263
|
+
def bpm_project
|
264
|
+
BPM::Project.nearest_project Dir.pwd
|
265
|
+
end
|
266
|
+
|
260
267
|
def determine_application_root
|
261
268
|
if is_sproutcore?
|
262
269
|
return "#{path}/tmp/build"
|
data/lib/strobe/cli/preview.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rack'
|
2
|
+
require 'bpm'
|
2
3
|
|
3
4
|
module Strobe
|
4
5
|
module CLI::Preview
|
@@ -16,11 +17,29 @@ module Strobe
|
|
16
17
|
is_sproutcore?? preview_sproutcore_application : preview_html_application
|
17
18
|
end
|
18
19
|
|
20
|
+
def bpm_project
|
21
|
+
@bpm_project ||= BPM::Project.nearest_project(Dir.pwd)
|
22
|
+
end
|
23
|
+
|
19
24
|
def preview_html_application
|
20
|
-
|
21
|
-
|
22
|
-
app =
|
23
|
-
|
25
|
+
project = bpm_project
|
26
|
+
|
27
|
+
app = Rack::Builder.new do
|
28
|
+
use Middleware::Proxy
|
29
|
+
use Middleware::Addons
|
30
|
+
use Middleware::Rewrite
|
31
|
+
|
32
|
+
if project
|
33
|
+
map "/assets" do
|
34
|
+
run BPM::Pipeline.new project
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
map "/" do
|
39
|
+
run Rack::Static.new lambda { |e| [] }, :urls => [ '/' ], :root => '.'
|
40
|
+
end
|
41
|
+
end.to_app
|
42
|
+
|
24
43
|
Server.start :app => app, :host => '0.0.0.0', :server => "thin", :Port => 9292
|
25
44
|
end
|
26
45
|
|
data/lib/strobe/collection.rb
CHANGED
@@ -14,11 +14,13 @@ module Strobe
|
|
14
14
|
|
15
15
|
def to_a
|
16
16
|
@to_a ||= begin
|
17
|
-
resp = Strobe.connection.get klass.
|
17
|
+
resp = Strobe.connection.get klass.collection_uri, params
|
18
18
|
resp.validate!
|
19
19
|
|
20
20
|
if resp.status == 200
|
21
|
-
resp.body
|
21
|
+
denormalized = klass.denormalize_params(resp.body)
|
22
|
+
|
23
|
+
denormalized.map do |hash|
|
22
24
|
klass.new(hash)
|
23
25
|
end
|
24
26
|
else
|
data/lib/strobe/connection.rb
CHANGED
@@ -117,7 +117,7 @@ module Strobe
|
|
117
117
|
|
118
118
|
def initialize(connection, method, path, body, headers)
|
119
119
|
@connection, @path, @body, @headers = connection, path, body, headers
|
120
|
-
@method = method
|
120
|
+
@method = method
|
121
121
|
end
|
122
122
|
|
123
123
|
def host; connection.host end
|
@@ -157,6 +157,9 @@ module Strobe
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def request(method, path, body = nil, headers = {})
|
160
|
+
path = path.dup
|
161
|
+
method = method.to_s.upcase
|
162
|
+
|
160
163
|
headers.keys.each do |key|
|
161
164
|
headers[key.to_s.downcase] = headers.delete(key)
|
162
165
|
end
|
@@ -169,6 +172,22 @@ module Strobe
|
|
169
172
|
|
170
173
|
headers['authorization'] ||= authorization_header
|
171
174
|
|
175
|
+
if method == "GET" || method == "HEAD"
|
176
|
+
|
177
|
+
case body
|
178
|
+
when Hash
|
179
|
+
qs = body.map { |k,v| "#{k}=#{v}" }.join('&')
|
180
|
+
|
181
|
+
if path.include?('?')
|
182
|
+
path << "&#{qs}"
|
183
|
+
else
|
184
|
+
path << "?#{qs}"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
body = nil
|
189
|
+
end
|
190
|
+
|
172
191
|
if body
|
173
192
|
headers['content-type'] ||= 'application/json'
|
174
193
|
|
data/lib/strobe/resource/base.rb
CHANGED
@@ -31,7 +31,7 @@ module Strobe
|
|
31
31
|
class_eval(assoc.reader)
|
32
32
|
class_eval(assoc.writer)
|
33
33
|
|
34
|
-
if assoc.
|
34
|
+
if assoc.nested?
|
35
35
|
validates_with AssociationValidator, :attributes => [name]
|
36
36
|
end
|
37
37
|
|
@@ -71,6 +71,16 @@ module Strobe
|
|
71
71
|
@root = root if root
|
72
72
|
@root
|
73
73
|
end
|
74
|
+
|
75
|
+
def include_query_string
|
76
|
+
to_include = associations.map do |n, assoc|
|
77
|
+
assoc.target_pluralized if assoc.include?
|
78
|
+
end.compact
|
79
|
+
|
80
|
+
if to_include.any?
|
81
|
+
"include=#{to_include.join(',')}"
|
82
|
+
end
|
83
|
+
end
|
74
84
|
end
|
75
85
|
|
76
86
|
attr_reader :response
|
@@ -93,7 +103,7 @@ module Strobe
|
|
93
103
|
def params
|
94
104
|
@params.dup.tap do |params|
|
95
105
|
self.class.associations.each do |name, assoc|
|
96
|
-
next unless assoc.
|
106
|
+
next unless assoc.nested? and inst = send(name)
|
97
107
|
params.deep_merge! name => inst.params
|
98
108
|
end
|
99
109
|
end
|
@@ -31,8 +31,12 @@ module Strobe
|
|
31
31
|
root.pluralize
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
uri_prefix
|
34
|
+
def collection_uri
|
35
|
+
[ uri_prefix, include_query_string ].compact.join('?')
|
36
|
+
end
|
37
|
+
|
38
|
+
def resource_uri(id)
|
39
|
+
[ "#{uri_prefix}/#{id}", include_query_string ].compact.join('?')
|
36
40
|
end
|
37
41
|
|
38
42
|
def collection
|
@@ -80,6 +84,22 @@ module Strobe
|
|
80
84
|
inst
|
81
85
|
end
|
82
86
|
end
|
87
|
+
|
88
|
+
def denormalize_params(params)
|
89
|
+
if coll = params[pluralized_root]
|
90
|
+
coll.map do |item|
|
91
|
+
associations.each do |n, assoc|
|
92
|
+
item = assoc.denormalize_params(item, params)
|
93
|
+
end
|
94
|
+
item
|
95
|
+
end
|
96
|
+
elsif item = params[root]
|
97
|
+
associations.each do |n, assoc|
|
98
|
+
item = assoc.denormalize_params(item, params)
|
99
|
+
end
|
100
|
+
item
|
101
|
+
end
|
102
|
+
end
|
83
103
|
end
|
84
104
|
|
85
105
|
def id
|
@@ -95,11 +115,11 @@ module Strobe
|
|
95
115
|
end
|
96
116
|
|
97
117
|
def reload(opts = {})
|
98
|
-
resp = Strobe.connection.get
|
118
|
+
resp = Strobe.connection.get self.class.resource_uri(key)
|
99
119
|
resp.validate! if opts[:validate]
|
100
120
|
|
101
121
|
if resp.success?
|
102
|
-
self.params =
|
122
|
+
self.params = self.class.denormalize_params(resp.body)
|
103
123
|
self
|
104
124
|
end
|
105
125
|
end
|
@@ -68,6 +68,11 @@ module Strobe
|
|
68
68
|
|
69
69
|
picked_root_app = false
|
70
70
|
|
71
|
+
if project = opts[:bpm_project]
|
72
|
+
project.rebuild_dependency_list(nil, false)
|
73
|
+
project.build :production, true
|
74
|
+
end
|
75
|
+
|
71
76
|
if opts[:sproutcore]
|
72
77
|
Dir["static/*"].each do |appdir|
|
73
78
|
next if File.file?(appdir)
|
data/lib/strobe/resources/me.rb
CHANGED
@@ -3,8 +3,8 @@ module Strobe
|
|
3
3
|
class Signup
|
4
4
|
include Resource::Singleton
|
5
5
|
|
6
|
-
has 1, :user, :
|
7
|
-
has 1, :account, :
|
6
|
+
has 1, :user, :nested => true, :autoload => false
|
7
|
+
has 1, :account, :nested => true, :autoload => false
|
8
8
|
|
9
9
|
filter :password_confirmation
|
10
10
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: strobe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 0.2.0.beta.
|
5
|
+
version: 0.2.0.beta.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Carl Lerche
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-18 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,29 +25,29 @@ dependencies:
|
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bpm
|
29
29
|
prerelease: false
|
30
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 1.
|
35
|
+
version: 1.0.0.beta.3.pre
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
|
-
name:
|
39
|
+
name: mime-types
|
40
40
|
prerelease: false
|
41
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 1.16.0
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
50
|
+
name: rack
|
51
51
|
prerelease: false
|
52
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
@@ -58,49 +58,60 @@ dependencies:
|
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id004
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
61
|
+
name: thin
|
62
62
|
prerelease: false
|
63
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.2.0
|
69
69
|
type: :runtime
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
72
|
+
name: em-http-request
|
73
73
|
prerelease: false
|
74
74
|
requirement: &id006 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ~>
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
79
|
+
version: 1.0.0.beta
|
80
80
|
type: :runtime
|
81
81
|
version_requirements: *id006
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
|
-
name:
|
83
|
+
name: thor
|
84
84
|
prerelease: false
|
85
85
|
requirement: &id007 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
90
|
+
version: 0.14.0
|
91
91
|
type: :runtime
|
92
92
|
version_requirements: *id007
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
|
-
name:
|
94
|
+
name: oauth
|
95
95
|
prerelease: false
|
96
96
|
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.4.4
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id008
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: launchy
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
97
108
|
none: false
|
98
109
|
requirements:
|
99
110
|
- - ">="
|
100
111
|
- !ruby/object:Gem::Version
|
101
112
|
version: "0"
|
102
113
|
type: :runtime
|
103
|
-
version_requirements: *
|
114
|
+
version_requirements: *id009
|
104
115
|
description: The client library for deploying applications to Strobe's HTML5 deployment platform
|
105
116
|
email:
|
106
117
|
- carl@strobecorp.com
|