tdiary 3.2.2.20130617 → 3.2.2.20130720

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,76 +1,16 @@
1
- # src_files
2
- #
3
- # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
- # Default: []
5
- #
6
- # EXAMPLE:
7
- #
8
- # src_files:
9
- # - lib/source1.js
10
- # - lib/source2.js
11
- # - dist/**/*.js
12
- #
13
1
  src_files:
14
- - vendor/jquery-1.8/jquery.js # load first
15
- - vendor/jasmine-jquery-1.4.2/jasmine-jquery.js
16
- - js/00default.js
17
- # - js/**/*.js
2
+ - "spec/javascripts/jquery.js"
3
+ - "js/**/*.js"
18
4
 
19
- # stylesheets
20
- #
21
- # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
22
- # Default: []
23
- #
24
- # EXAMPLE:
25
- #
26
- # stylesheets:
27
- # - css/style.css
28
- # - stylesheets/*.css
29
- #
30
5
  stylesheets:
6
+ - "theme/**/*.css"
31
7
 
32
- # helpers
33
- #
34
- # Return an array of filepaths relative to spec_dir to include before jasmine specs.
35
- # Default: ["helpers/**/*.js"]
36
- #
37
- # EXAMPLE:
38
- #
39
- # helpers:
40
- # - helpers/**/*.js
41
- #
42
8
  helpers:
9
+ - "helpers/**/*.js"
43
10
 
44
- # spec_files
45
- #
46
- # Return an array of filepaths relative to spec_dir to include.
47
- # Default: ["**/*[sS]pec.js"]
48
- #
49
- # EXAMPLE:
50
- #
51
- # spec_files:
52
- # - **/*[sS]pec.js
53
- #
54
11
  spec_files:
12
+ - "**/*_[sS]pec.js"
55
13
 
56
- # src_dir
57
- #
58
- # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
59
- # Default: project root
60
- #
61
- # EXAMPLE:
62
- #
63
- # src_dir: public
64
- #
65
14
  src_dir:
66
15
 
67
- # spec_dir
68
- #
69
- # Spec directory path. Your spec_files must be returned relative to this path.
70
- # Default: spec/javascripts
71
- #
72
- # EXAMPLE:
73
- #
74
- # spec_dir: spec/javascripts
75
- #
76
- spec_dir:
16
+ spec_dir: spec/javascripts
@@ -2,7 +2,6 @@
2
2
  require 'rack/builder'
3
3
  require 'tdiary/application/configuration'
4
4
  require 'tdiary/rack'
5
- require 'sprockets'
6
5
 
7
6
  # FIXME too dirty hack :-<
8
7
  class CGI
data/tdiary/core_ext.rb CHANGED
@@ -94,6 +94,8 @@ class CGI
94
94
  end
95
95
  end
96
96
 
97
+ class RackCGI < CGI; end
98
+
97
99
  =begin
98
100
  == Safe module
99
101
  =end
data/tdiary/dispatcher.rb CHANGED
@@ -18,11 +18,11 @@ module TDiary
18
18
 
19
19
  def call( env )
20
20
  req = adopt_rack_request_to_plain_old_tdiary_style( env )
21
- dispatch_cgi( req )
21
+ dispatch_cgi(req, RackCGI.new)
22
22
  end
23
23
 
24
24
  # FIXME rename method name to more suitable one.
25
- def dispatch_cgi( request, cgi = CGI.new )
25
+ def dispatch_cgi(request, cgi)
26
26
  result = @target.run( request, cgi )
27
27
  result.headers.reject!{|k,v| k.to_s.downcase == "status" }
28
28
  result.to_a
@@ -30,11 +30,12 @@ module TDiary
30
30
 
31
31
  class << self
32
32
  # stolen from Rack::Handler::CGI.send_headers
33
- def send_headers( status, headers )
33
+ def send_headers(status, headers)
34
34
  begin
35
- $stdout.print CGI.new.header( {'Status'=>status}.merge(headers) )
35
+ headers['type'] = headers.delete('Content-Type')
36
+ $stdout.print CGI.new.header({'Status'=>status}.merge(headers))
36
37
  rescue EOFError
37
- charset = headers.delete( 'charset' )
38
+ charset = headers.delete('charset')
38
39
  headers['Content-Type'] ||= headers.delete( 'type' )
39
40
  headers['Content-Type'] += "; charset=#{charset}" if charset
40
41
  $stdout.print headers.map{|k,v| "#{k}: #{v}\r\n"}.join << "\r\n"
@@ -42,14 +43,6 @@ module TDiary
42
43
  $stdout.flush
43
44
  end
44
45
 
45
- # stolen from Rack::Handler::CGI.send_body
46
- def send_body( body )
47
- body.lines.each { |part|
48
- $stdout.print part
49
- $stdout.flush
50
- }
51
- end
52
-
53
46
  # FIXME temporary method during (scratch) refactoring
54
47
  def extract_status_for_legacy_tdiary( head )
55
48
  status_str = head.delete('status')
@@ -69,6 +62,7 @@ module TDiary
69
62
  def update
70
63
  new( :update )
71
64
  end
65
+
72
66
  private :new
73
67
  end
74
68
 
@@ -83,11 +77,11 @@ module TDiary
83
77
  req
84
78
  end
85
79
 
80
+ # FIXME dirty hack
86
81
  def fake_stdin_as_params
87
- stdin_spy = StringIO.new( "" )
88
- # FIXME dirty hack
82
+ stdin_spy = StringIO.new
89
83
  if $RACK_ENV && $RACK_ENV['rack.input']
90
- stdin_spy.print( $RACK_ENV['rack.input'].read )
84
+ stdin_spy.print($RACK_ENV['rack.input'].read)
91
85
  stdin_spy.rewind
92
86
  end
93
87
  $stdin = stdin_spy
data/tdiary/request.rb CHANGED
@@ -1,25 +1,18 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # stolen from okkez http://github.com/hiki/hiki/blob/rack/hiki/request.rb
3
3
  module TDiary
4
- if Object.const_defined?( :Rack )
5
- Request = ::Rack::Request
6
- class ::Rack::Request
7
- alias remote_addr ip
8
- end
9
- Request.class_eval { include RequestExtension }
10
- else
11
- raise RuntimeError, 'Do not use CGI class!' if Object.const_defined?( :Rack )
12
- # CGI を Rack::Request っぽいインターフェイスに変換する
13
- class Request
14
- include RequestExtension
4
+ class Request < ::Rack::Request
5
+ include RequestExtension
15
6
 
16
- attr_reader :env, :cgi
17
- def initialize( env, cgi = CGI.new )
18
- @cgi = cgi
19
- @env = env
20
- end
7
+ attr_reader :env, :cgi
8
+
9
+ def initialize( env, cgi = nil )
10
+ @env = env
11
+ @cgi = cgi
12
+ end
21
13
 
22
- def params
14
+ def params
15
+ if @cgi
23
16
  return @params if @params
24
17
  @params = { }
25
18
  @cgi.params.each{|k, v|
@@ -34,73 +27,141 @@ module TDiary
34
27
  end
35
28
  }
36
29
  @params
30
+ else
31
+ super
37
32
  end
33
+ end
38
34
 
39
- def []( key )
35
+ def []( key )
36
+ if @cgi
40
37
  params[key.to_s]
38
+ else
39
+ super
41
40
  end
41
+ end
42
42
 
43
- def []=( key, val )
43
+ def []=( key, val )
44
+ if @cgi
44
45
  params[key.to_s] = val
46
+ else
47
+ super
45
48
  end
49
+ end
46
50
 
47
- def request_method
51
+ def request_method
52
+ if @cgi
48
53
  @env['REQUEST_METHOD']
54
+ else
55
+ super
49
56
  end
57
+ end
50
58
 
51
- def header( header )
59
+ def header( header )
60
+ if @cgi
52
61
  @cgi.header( header )
62
+ else
63
+ super
53
64
  end
65
+ end
54
66
 
55
- def get?
67
+ def get?
68
+ if @cgi
56
69
  request_method == 'GET'
70
+ else
71
+ super
57
72
  end
73
+ end
58
74
 
59
- def head?
75
+ def head?
76
+ if @cgi
60
77
  request_method == 'HEAD'
78
+ else
79
+ super
61
80
  end
81
+ end
62
82
 
63
- def post?
83
+ def post?
84
+ if @cgi
64
85
  request_method == 'POST'
86
+ else
87
+ super
65
88
  end
89
+ end
66
90
 
67
- def put?
91
+ def put?
92
+ if @cgi
68
93
  request_method == 'PUT'
94
+ else
95
+ super
69
96
  end
97
+ end
70
98
 
71
- def delete?
99
+ def delete?
100
+ if @cgi
72
101
  request_method == 'DELETE'
102
+ else
103
+ super
73
104
  end
105
+ end
74
106
 
75
- def xhr?
107
+ def xhr?
108
+ if @cgi
76
109
  @env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
110
+ else
111
+ super
77
112
  end
113
+ end
78
114
 
79
- def accept_encoding
115
+ def accept_encoding
116
+ if @cgi
80
117
  raise NameError, 'not implemented : accept_encoding'
118
+ else
119
+ super
81
120
  end
121
+ end
82
122
 
83
- def body
123
+ def body
124
+ if @cgi
84
125
  raise NameError, 'not implemented : body'
126
+ else
127
+ super
85
128
  end
129
+ end
86
130
 
87
- def content_charset
131
+ def content_charset
132
+ if @cgi
88
133
  @env['CONTENT_CHARSET']
134
+ else
135
+ super
89
136
  end
137
+ end
90
138
 
91
- def content_length
139
+ def content_length
140
+ if @cgi
92
141
  @env['CONTENT_LENGTH']
142
+ else
143
+ super
93
144
  end
145
+ end
94
146
 
95
- def content_type
147
+ def content_type
148
+ if @cgi
96
149
  @env['CONTENT_TYPE']
150
+ else
151
+ super
97
152
  end
153
+ end
98
154
 
99
- def remote_addr
155
+ def remote_addr
156
+ if @cgi
100
157
  @env['REMOTE_ADDR']
158
+ else
159
+ super
101
160
  end
161
+ end
102
162
 
103
- def cookies
163
+ def cookies
164
+ if @cgi
104
165
  return @cookies if @cookies
105
166
  @cookies = { }
106
167
  @cgi.cookies.each{|k, v|
@@ -114,96 +175,187 @@ module TDiary
114
175
  end
115
176
  }
116
177
  @cookies
178
+ else
179
+ super
117
180
  end
181
+ end
118
182
 
119
- def form_data?
183
+ def form_data?
184
+ if @cgi
120
185
  raise NameError, 'not implemented : form_data?'
186
+ else
187
+ super
121
188
  end
189
+ end
122
190
 
123
- def fullpath
191
+ def fullpath
192
+ if @cgi
124
193
  raise NameError, 'not implemented : fullpath'
194
+ else
195
+ super
125
196
  end
197
+ end
126
198
 
127
- def host
199
+ def host
200
+ if @cgi
128
201
  # Remove port number.from Rack::Response
129
202
  ( @env["HTTP_HOST"] || @env["SERVER_NAME"] ).gsub( /:\d+\z/, '' )
203
+ else
204
+ super
130
205
  end
206
+ end
131
207
 
132
- def ip
208
+ def ip
209
+ if @cgi
133
210
  raise NameError, 'not implemented : ip'
211
+ else
212
+ super
134
213
  end
214
+ end
215
+ alias remote_addr ip
135
216
 
136
- def media_type
217
+ def media_type
218
+ if @cgi
137
219
  raise NameError, 'not implemented : madia_type'
220
+ else
221
+ super
138
222
  end
223
+ end
139
224
 
140
- def media_type_params
225
+ def media_type_params
226
+ if @cgi
141
227
  raise NameError, 'not implemented : media_type_params'
228
+ else
229
+ super
142
230
  end
231
+ end
143
232
 
144
- def openid_request
233
+ def openid_request
234
+ if @cgi
145
235
  raise NameError, 'not implemented : openid_request'
236
+ else
237
+ super
146
238
  end
239
+ end
147
240
 
148
- def openid_response
241
+ def openid_response
242
+ if @cgi
149
243
  raise NameError, 'not implemented : openid_response'
244
+ else
245
+ super
150
246
  end
247
+ end
151
248
 
152
- def parseable_data?
249
+ def parseable_data?
250
+ if @cgi
153
251
  raise NameError, 'not implemented : parseable_data?'
252
+ else
253
+ super
154
254
  end
255
+ end
155
256
 
156
- def path
257
+ def path
258
+ if @cgi
157
259
  raise NameError, 'not implemented : path'
260
+ else
261
+ super
158
262
  end
263
+ end
159
264
 
160
- def path_info
161
- @env['PATH_INFO'].to_s
265
+ def path_info
266
+ if @cgi
267
+ raise NameError, 'not implemented : path'
268
+ else
269
+ super
162
270
  end
271
+ w end
163
272
 
164
- def path_info=( s )
273
+ def path_info=( s )
274
+ if @cgi
165
275
  raise NameError, 'not implemented : path_info='
276
+ else
277
+ super
166
278
  end
279
+ end
167
280
 
168
- def port
281
+ def port
282
+ if @cgi
169
283
  raise NameError, 'not implemented : port'
284
+ else
285
+ super
170
286
  end
287
+ end
171
288
 
172
- def query_string
289
+ def query_string
290
+ if @cgi
173
291
  raise NameError, 'not implemented : query_string'
292
+ else
293
+ super
174
294
  end
295
+ end
175
296
 
176
- def referer
297
+ def referer
298
+ if @cgi
177
299
  raise NameError, 'not implemented : referer'
300
+ else
301
+ super
178
302
  end
179
- alias referrer referer
303
+ end
304
+ alias referrer referer
180
305
 
181
- def schema
306
+ def schema
307
+ if @cgi
182
308
  raise NameError, 'not implemented : schema'
309
+ else
310
+ super
183
311
  end
312
+ end
184
313
 
185
- def script_name
314
+ def script_name
315
+ if @cgi
186
316
  @env['SCRIPT_NAME']
317
+ else
318
+ super
187
319
  end
320
+ end
188
321
 
189
- def session_options
322
+ def session_options
323
+ if @cgi
190
324
  raise NameError, 'not implemented : session_options'
325
+ else
326
+ super
191
327
  end
328
+ end
192
329
 
193
- def url
330
+ def url
331
+ if @cgi
194
332
  raise NameError, 'not implemented : url'
333
+ else
334
+ super
195
335
  end
336
+ end
196
337
 
197
- def user_agent
338
+ def user_agent
339
+ if @cgi
198
340
  @cgi.user_agent
341
+ else
342
+ super
199
343
  end
344
+ end
200
345
 
201
- def base_url
346
+ def base_url
347
+ if @cgi
202
348
  @cgi.base_url
349
+ else
350
+ super
203
351
  end
352
+ end
204
353
 
205
- def values_at( *keys )
354
+ def values_at( *keys )
355
+ if @cgi
206
356
  raise NameError, 'not implemented : values_at'
357
+ else
358
+ super
207
359
  end
208
360
  end
209
361
  end
data/tdiary/response.rb CHANGED
@@ -1,23 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # stolen from okkez http://github.com/hiki/hiki/blob/rack/hiki/response.rb
3
2
  module TDiary
4
- if Object.const_defined?(:Rack)
5
- Response = ::Rack::Response
6
- else
7
- class Response
8
- attr_reader :body, :status, :headers
9
- def initialize(body = [], status = 200, headers = {}, &block)
10
- @body = body
11
- @status = status
12
- @headers = headers
13
- yield self if block_given?
14
- end
15
-
16
- def finish
17
- [status, headers, body]
18
- end
19
- alias to_a finish
20
- end
3
+ class Response < ::Rack::Response
21
4
  end
22
5
  end
23
6
 
@@ -8,24 +8,15 @@ REPOS = %w(tdiary-core tdiary-theme tdiary-blogkit tdiary-contrib)
8
8
  DEST_DIR = "/var/www/tdiary.org/htdocs/download"
9
9
  TARBALLS = []
10
10
 
11
- #
12
- # utilities
13
- #
14
11
  def fetch_files( repo )
15
12
  Dir.chdir("tmp") do
16
13
  rm_rf repo rescue true
17
- sh "git clone --depth 1 git://github.com/tdiary/#{repo}.git #{repo}"
18
- end
19
- end
20
-
21
- REPOS.each_with_index do |repo, i|
22
- file REPOS[i] do |t|
23
- fetch_files(t.name)
14
+ sh "git clone --depth 10 https://github.com/tdiary/#{repo}.git #{repo}"
24
15
  end
25
16
  end
26
17
 
27
18
  def make_tarball( repo, version = nil )
28
- suffix = version ? "-#{version}" : ''
19
+ suffix = version ? "-#{version}" : '-snapshot'
29
20
  dest = "#{repo == 'tdiary-core' ? 'tdiary' : repo}#{suffix}"
30
21
 
31
22
  if version then
@@ -43,7 +34,7 @@ def make_tarball( repo, version = nil )
43
34
  sh "chmod +x index.rb index.fcgi update.rb update.fcgi"
44
35
  sh 'rake doc'
45
36
  Bundler.with_clean_env do
46
- sh 'bundle --path .bundle --without development:test'
37
+ sh 'bundle --path .bundle --without coffee:memcached:redis:gfm:server:development'
47
38
  end
48
39
  Dir.chdir 'misc/lib' do
49
40
  sh 'gem unpack bundler'
@@ -57,13 +48,30 @@ def make_tarball( repo, version = nil )
57
48
  TARBALLS << "#{dest}.tar.gz"
58
49
  end
59
50
 
60
- #
61
- # tasks
62
- #
51
+ def make_full_package(version = nil)
52
+ suffix = version ? "-#{version}" : '-snapshot'
53
+ Dir.chdir("tmp") do
54
+ TARBALLS.clear
55
+ REPOS.each do |repo|
56
+ make_tarball( repo, version )
57
+ end
58
+ Dir["tdiary-theme/*"].each do |d|
59
+ mv d, "tdiary-core/theme/" rescue true
60
+ end
61
+ mv "tdiary-core", "tdiary#{suffix}"
62
+ sh "tar zcf tdiary-full#{suffix}.tar.gz tdiary#{suffix}"
63
+ TARBALLS << "tdiary-full#{suffix}.tar.gz"
64
+ rm_rf "tdiary#{suffix}"
65
+ REPOS.each {|repo| rm_rf repo rescue true }
66
+ end
67
+ end
68
+
63
69
  task :default => :snapshot
64
70
 
65
71
  desc 'fetching all files from GitHub.'
66
- task :fetch => REPOS
72
+ task :fetch do
73
+ REPOS.each{|r| fetch_files(r) }
74
+ end
67
75
 
68
76
  desc 'releasing all files'
69
77
  task :release do
@@ -76,39 +84,13 @@ task :release do
76
84
  end
77
85
 
78
86
  desc 'making packages of snapshot.'
79
- task :snapshot => REPOS do
80
- Dir.chdir("tmp") do
81
- TARBALLS.clear
82
- REPOS.each do |repo|
83
- make_tarball( repo )
84
- end
85
- Dir["tdiary-theme/*"].each do |d|
86
- mv d, "tdiary-core/theme/"
87
- end
88
- mv "tdiary-core", "tdiary"
89
- sh "tar zcf tdiary-full.tar.gz tdiary"
90
- TARBALLS << "tdiary-full.tar.gz"
91
- rm_rf "tdiary"
92
- REPOS.each {|repo| rm_rf repo rescue true }
93
- end
87
+ task :snapshot => :fetch do
88
+ make_full_package
94
89
  end
95
90
 
96
91
  desc 'making packages of stable.'
97
- task :stable => REPOS do
98
- Dir.chdir("tmp") do
99
- TARBALLS.clear
100
- REPOS.each do |repo|
101
- make_tarball( repo, STABLE )
102
- end
103
- Dir["tdiary-theme/*"].each do |d|
104
- mv d, "tdiary-core/theme/" rescue true
105
- end
106
- mv "tdiary-core", "tdiary-#{STABLE}"
107
- sh "tar zcf tdiary-full-#{STABLE}.tar.gz tdiary-#{STABLE}"
108
- TARBALLS << "tdiary-full-#{STABLE}.tar.gz"
109
- rm_rf "tdiary-#{STABLE}"
110
- REPOS.each {|repo| rm_rf repo rescue true }
111
- end
92
+ task :stable => :fetch do
93
+ make_full_package(STABLE)
112
94
  end
113
95
 
114
96
  desc 'cleanup all files.'
data/tdiary/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TDiary
2
- VERSION = '3.2.2.20130617'
2
+ VERSION = '3.2.2.20130720'
3
3
  end