daddy 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/daddy/formatter/daddy.js +5 -0
- data/lib/daddy/formatter/html.rb +19 -43
- data/lib/daddy/http_client.rb +7 -4
- data/lib/daddy/utils/string_utils.rb +45 -0
- data/lib/tasks/publish.rake +20 -7
- metadata +3 -2
@@ -1,3 +1,8 @@
|
|
1
1
|
function toggle_feature_dir(feature_dir) {
|
2
2
|
$(feature_dir).parent('div.feature_dir').nextUntil('div.feature_dir').toggle(250);
|
3
3
|
};
|
4
|
+
|
5
|
+
function toggle_step_file(step_file) {
|
6
|
+
$(step_file).closest('li').next('.step_contents').toggle(250);
|
7
|
+
event.stopPropagation();
|
8
|
+
};
|
data/lib/daddy/formatter/html.rb
CHANGED
@@ -5,6 +5,7 @@ require 'cucumber/formatter/ordered_xml_markup'
|
|
5
5
|
require 'cucumber/formatter/duration'
|
6
6
|
require 'cucumber/formatter/io'
|
7
7
|
require 'daddy/formatter/daddy_html'
|
8
|
+
require 'daddy/utils/string_utils'
|
8
9
|
|
9
10
|
module Daddy
|
10
11
|
module Formatter
|
@@ -29,23 +30,6 @@ module Daddy
|
|
29
30
|
@inside_outline = false
|
30
31
|
end
|
31
32
|
|
32
|
-
def embed(src, mime_type, label)
|
33
|
-
case(mime_type)
|
34
|
-
when /^image\/(png|gif|jpg|jpeg)/
|
35
|
-
embed_image(src, label)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def embed_image(src, label)
|
40
|
-
id = "img_#{@img_id}"
|
41
|
-
@img_id += 1
|
42
|
-
@builder.span(:class => 'embed') do |pre|
|
43
|
-
pre << %{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false">#{label}</a><br>
|
44
|
-
<img id="#{id}" style="display: none" src="#{src}"/>}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
33
|
def before_features(features)
|
50
34
|
@step_count = features.step_count
|
51
35
|
|
@@ -250,7 +234,7 @@ module Daddy
|
|
250
234
|
end
|
251
235
|
|
252
236
|
def before_step(step)
|
253
|
-
@step_id = step.dom_id
|
237
|
+
@step_id = step.dom_id + '_' + Daddy::Utils::StringUtils.current_time
|
254
238
|
@step_number += 1
|
255
239
|
@step = step
|
256
240
|
end
|
@@ -521,21 +505,11 @@ module Daddy
|
|
521
505
|
step_file = "daddy: " + $1[index..-1]
|
522
506
|
end
|
523
507
|
|
524
|
-
step_file = "<span
|
508
|
+
step_file = "<span style=\"cursor: pointer;\" onclick=\"toggle_step_file(this);\">#{step_file}:#{$2}</span>"
|
525
509
|
end
|
526
510
|
|
527
511
|
@builder.div(:class => 'step_file') do |div|
|
528
|
-
@builder
|
529
|
-
@builder << step_file
|
530
|
-
@builder.script do |script|
|
531
|
-
script << "$(function() {"
|
532
|
-
script << " $('#step_file_#{@step_id}').css('cursor', 'pointer').click(function(e) {"
|
533
|
-
script << " $(this).closest('li').next('.step_contents').toggle(250);"
|
534
|
-
script << " e.stopImmediatePropagation();"
|
535
|
-
script << " });"
|
536
|
-
script << "});"
|
537
|
-
end
|
538
|
-
end
|
512
|
+
@builder << step_file
|
539
513
|
end
|
540
514
|
end
|
541
515
|
|
@@ -560,16 +534,8 @@ module Daddy
|
|
560
534
|
def inline_js
|
561
535
|
@builder.script(:type => 'text/javascript') do
|
562
536
|
@builder << inline_jquery
|
563
|
-
@builder << inline_daddy
|
564
537
|
@builder << inline_js_content
|
565
|
-
|
566
|
-
if should_expand
|
567
|
-
@builder << %w{
|
568
|
-
$(document).ready(function() {
|
569
|
-
$('#expander').click();
|
570
|
-
});
|
571
|
-
}.join
|
572
|
-
end
|
538
|
+
@builder << inline_daddy
|
573
539
|
end
|
574
540
|
end
|
575
541
|
|
@@ -578,13 +544,23 @@ module Daddy
|
|
578
544
|
end
|
579
545
|
|
580
546
|
def inline_daddy
|
581
|
-
File.read(File.dirname(__FILE__) + '/daddy.js')
|
547
|
+
ret = File.read(File.dirname(__FILE__) + '/daddy.js')
|
548
|
+
|
549
|
+
if should_expand
|
550
|
+
ret << %w{
|
551
|
+
$(document).ready(function() {
|
552
|
+
$('#expander').click();
|
553
|
+
});
|
554
|
+
}.join
|
555
|
+
end
|
556
|
+
|
557
|
+
ret
|
582
558
|
end
|
583
559
|
|
584
560
|
def inline_js_content
|
585
561
|
<<-EOF
|
586
562
|
|
587
|
-
SCENARIOS = "h3
|
563
|
+
SCENARIOS = "div.scenario h3";
|
588
564
|
|
589
565
|
$(document).ready(function() {
|
590
566
|
$(SCENARIOS).css('cursor', 'pointer');
|
@@ -602,7 +578,7 @@ module Daddy
|
|
602
578
|
$("#expander").click(function() {
|
603
579
|
$(SCENARIOS).siblings().show();
|
604
580
|
});
|
605
|
-
})
|
581
|
+
});
|
606
582
|
|
607
583
|
function moveProgressBar(percentDone) {
|
608
584
|
$("cucumber-header").css('width', percentDone +"%");
|
@@ -724,4 +700,4 @@ module Daddy
|
|
724
700
|
end
|
725
701
|
end
|
726
702
|
end
|
727
|
-
end
|
703
|
+
end
|
data/lib/daddy/http_client.rb
CHANGED
@@ -8,7 +8,7 @@ module Daddy
|
|
8
8
|
def initialize(url, options = {})
|
9
9
|
@url = url
|
10
10
|
@options = options
|
11
|
-
@cookie =
|
11
|
+
@cookie = options[:cookie]
|
12
12
|
Rails.logger.debug "[HttpClient] url: #{@url}"
|
13
13
|
end
|
14
14
|
|
@@ -18,11 +18,14 @@ module Daddy
|
|
18
18
|
|
19
19
|
response = connection.get(path, params) do |request|
|
20
20
|
if @options[:auth_user] and @options[:auth_password]
|
21
|
-
basic = Base64.encode64(@options[:auth_user] + ':' + @options[:auth_password])
|
22
|
-
|
21
|
+
basic = 'Basic ' + Base64.encode64(@options[:auth_user] + ':' + @options[:auth_password])
|
22
|
+
Rails.logger.debug "[HttpClient] authorization: #{basic}"
|
23
|
+
|
24
|
+
request.headers['Authorization'] = basic
|
23
25
|
end
|
24
26
|
|
25
27
|
if @cookie
|
28
|
+
Rails.logger.debug "[HttpClient] cookie: #{@cookie}"
|
26
29
|
request.headers['Cookie'] = @cookie
|
27
30
|
end
|
28
31
|
|
@@ -44,7 +47,7 @@ module Daddy
|
|
44
47
|
def post(path, params = {})
|
45
48
|
response = connection.post(path, params)
|
46
49
|
end
|
47
|
-
|
50
|
+
|
48
51
|
private
|
49
52
|
|
50
53
|
def connection
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require 'nkf'
|
4
|
+
|
5
|
+
module Daddy
|
6
|
+
module Utils
|
7
|
+
class StringUtils
|
8
|
+
|
9
|
+
def self.to_hiragana(s)
|
10
|
+
return s if is_empty(s)
|
11
|
+
NKF::nkf('-Ww --hiragana', s)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.to_katakana(s)
|
15
|
+
return s if is_empty(s)
|
16
|
+
NKF::nkf('-Ww --katakana', s)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.to_zen(s)
|
20
|
+
return s if is_empty(s)
|
21
|
+
NKF::nkf('-WwXm0', s)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.to_han(s)
|
25
|
+
return s if is_empty(s)
|
26
|
+
NKF::nkf('-Wwxm0Z0', s)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.current_time(now = nil)
|
30
|
+
now = Time.now unless now
|
31
|
+
now.instance_eval { '%s%03d' % [strftime('%Y%m%d%H%M%S'), (usec / 1000.0).round] }
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.rand(length = 8)
|
35
|
+
chars = ("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a
|
36
|
+
ret = []
|
37
|
+
length.times do |i|
|
38
|
+
ret[i] = chars[rand(chars.size)]
|
39
|
+
end
|
40
|
+
ret.join
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/tasks/publish.rake
CHANGED
@@ -42,11 +42,18 @@ namespace :dad do
|
|
42
42
|
|
43
43
|
# 開発日記を統合
|
44
44
|
if branch == 'master'
|
45
|
-
features =
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
features = {}
|
46
|
+
dad_publish_sprint_dirs(base_dir).each do |dir|
|
47
|
+
dad_publish_extract_features(dir).each do |div|
|
48
|
+
feature = features[div['id']]
|
49
|
+
if feature
|
50
|
+
div.css('div.scenario').each do |scenario|
|
51
|
+
feature.add_child(scenario)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
features[div['id']] = div
|
55
|
+
end
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
# 空HTMLを生成
|
@@ -54,8 +61,8 @@ namespace :dad do
|
|
54
61
|
|
55
62
|
doc = Nokogiri::HTML(File.read('features/reports/index.html'))
|
56
63
|
contents_div = doc.css('div.contents').first
|
57
|
-
features.sort
|
58
|
-
contents_div.add_child(
|
64
|
+
features.keys.sort.each do |key|
|
65
|
+
contents_div.add_child(features[key])
|
59
66
|
end
|
60
67
|
File.write("#{base_dir}/index.html", doc)
|
61
68
|
end
|
@@ -63,6 +70,12 @@ namespace :dad do
|
|
63
70
|
|
64
71
|
end
|
65
72
|
|
73
|
+
def self.dad_publish_sprint_dirs(base_dir)
|
74
|
+
ret = Dir[base_dir + '/p*'].sort{|a, b| File.basename(a)[1..-1].to_i <=> File.basename(b)[1..-1].to_i}
|
75
|
+
ret << base_dir + '/master'
|
76
|
+
ret
|
77
|
+
end
|
78
|
+
|
66
79
|
def self.dad_publish_extract_features(dir)
|
67
80
|
ret = []
|
68
81
|
return [] unless File.exist?(dir) and File.directory?(dir)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daddy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|
@@ -328,6 +328,7 @@ files:
|
|
328
328
|
- lib/daddy/capistrano/remote_cache_subdir.rb
|
329
329
|
- lib/daddy/helpers/html_helper.rb
|
330
330
|
- lib/daddy/utils/sql_utils.rb
|
331
|
+
- lib/daddy/utils/string_utils.rb
|
331
332
|
- lib/daddy/http_client.rb
|
332
333
|
- lib/daddy/model.rb
|
333
334
|
- lib/daddy/cucumber.rb
|