daddy 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmRjODU2MzVhNDE2MjdmNTBkNjI3ZjY0MzAzNjJjYjZhMjhhMTE1Zg==
4
+ Yjc0ZGJlZjU5MTRlN2E0NmUyMmM0NmU4MGMyMWVjZmZkMGQyZmQ0Nw==
5
5
  data.tar.gz: !binary |-
6
- ZjJkOTQ1ODc3NGM5MmE3ZjcxMjIyOTg2N2FmZWU4ZDVkYmUzM2UwNg==
6
+ OWI0M2NkNjhiYTI0ODJjODQzMzk0NjU2ZGE3MTU4NDIwZDAyOTI2OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZThlM2MyMWJmMDAzNzA3OTlkODYyMjc0MjRkNmYyMGNkNDNjMzc3Nzg4OTgw
10
- NjcwZGM5MmI4OGUyYzJhODFhZmRlZGQ5YjIwNzZjZWFjNDdjMjdiMjMxM2Yy
11
- M2E1MzAyNTdlODRjNzNkOTFkODM3ZGQzMDM2OTRmNWE4OGY4ZTI=
9
+ ZGVmOWU1MzFlNTNiMzc0NGEwNDVmN2VmNWQ2ZTRhNzk1MThjZDYxYTAzOTA2
10
+ ZDIzZmQ5YTQ2NzRmZWVkMjkyNjQxNjkzYzQ0NTQwYWY0Y2FmYmE0N2VhNzVi
11
+ MGJiYTE0MjkxMmI1OWY5YjAwNWJlYzBmZGE2MjRhNDAzMTZiMGM=
12
12
  data.tar.gz: !binary |-
13
- ZmMwMDBmZGYyMGVjZDg3NjFiOTgzYTMwZGFkYTE0MmM2NTYyYmQ3Y2U3YzUx
14
- YmQ1MmMwOTE4YmJjOWI5ODM3YjAzMjc1MmM0MmM4ZmFjMzljNjI0OTBjNmQy
15
- MWNjMWViYjYwNjY0ZmYzZTdhMzY1OWRmZGQ1ZWU5NjdjYzhkMTA=
13
+ YTRhNTc2MDQwYzQwOTkzZjI5MDhhOWE5Y2I2OTNhNzBjNzYyZDAyZmUwN2Qy
14
+ ODgzYTIzNDA4YTZhMGQ1NmQ5Njk5MTE5ZjZjYWMwMzNlMTg4NDRjY2ViNTk0
15
+ NDQwNjllNjIzYmI0ZTc1MTYzZDljZDg0Nzk4MDYxYTNlOGY2MmQ=
@@ -1,19 +1,19 @@
1
1
  # coding: UTF-8
2
2
 
3
3
  require 'cucumber/rails'
4
- require "capybara/webkit"
4
+ require 'capybara/webkit'
5
+ require 'differ'
6
+
7
+ Differ.format :html
5
8
 
6
9
  Capybara.default_driver = (ENV['DRIVER'] || :selenium).to_sym
7
10
  Capybara.default_selector = :css
8
11
 
9
12
  ActionController::Base.allow_rescue = false
10
13
 
11
- require 'daddy/cucumber/assert'
12
- require 'daddy/cucumber/capture'
13
- require 'daddy/cucumber/table'
14
- World(Daddy::Cucumber::Assert)
15
- World(Daddy::Cucumber::Capture)
16
- World(Daddy::Cucumber::Table)
14
+ Dir::glob(File.dirname(__FILE__) + '/cucumber/*.rb').each do |file|
15
+ require file
16
+ end
17
17
 
18
18
  Dir::glob(File.dirname(__FILE__) + '/cucumber/step_definitions/*.rb').each do |file|
19
19
  load file
@@ -46,3 +46,10 @@ AfterConfiguration do |configuration|
46
46
  sorted_files
47
47
  }
48
48
  end
49
+
50
+ Before do
51
+ ActiveRecord::Fixtures.reset_cache
52
+ fixtures_folder = File.join(Rails.root, 'test', 'fixtures')
53
+ fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') }
54
+ ActiveRecord::Fixtures.create_fixtures(fixtures_folder, fixtures)
55
+ end
@@ -119,3 +119,5 @@ module Daddy
119
119
  end
120
120
  end
121
121
  end
122
+
123
+ World(Daddy::Cucumber::Assert)
@@ -9,6 +9,7 @@ module Daddy
9
9
  @@_screen_count = 0
10
10
 
11
11
  def capture(url = nil)
12
+ pause
12
13
 
13
14
  url ||= remove_domain(current_url)
14
15
 
@@ -30,3 +31,5 @@ module Daddy
30
31
  end
31
32
  end
32
33
  end
34
+
35
+ World(Daddy::Cucumber::Capture)
@@ -0,0 +1,56 @@
1
+ # coding: UTF-8
2
+
3
+ module Daddy
4
+ module Cucumber
5
+ module Html
6
+
7
+ def find_tr(table_selector, text, fail_on_missing = true)
8
+ within table_selector do
9
+ all('tr').each do |tr|
10
+ if tr.text.include?(text)
11
+ if block_given?
12
+ within tr do
13
+ yield tr
14
+ end
15
+ end
16
+ return tr
17
+ end
18
+ end
19
+ end
20
+
21
+ fail "テーブル #{table_selector} 内に #{text} を含む行が見つかりませでした。" if fail_on_missing
22
+ end
23
+
24
+ def find_option(select_selector, text, fail_on_missing = true)
25
+ within select_selector do
26
+ all('option').each do |option|
27
+ if option.text.include?(text)
28
+ if block_given?
29
+ within option do
30
+ yield
31
+ end
32
+ end
33
+ return option
34
+ end
35
+ end
36
+ end
37
+
38
+ fail "セレクトボックス #{select_selector} 内に #{text} を含むオプションが見つかりませでした。" if fail_on_missing
39
+ end
40
+
41
+ def confirm(ok = true)
42
+ puts("確認ダイアログで #{ok ? 'OK' : 'キャンセル'} をクリック")
43
+ return unless Capybara.current_driver == :selenium
44
+
45
+ if ok
46
+ page.driver.browser.switch_to.alert.accept
47
+ else
48
+ page.driver.browser.switch_to.alert.deny
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+
56
+ World(Daddy::Cucumber::Html)
@@ -0,0 +1,25 @@
1
+ # coding: UTF-8
2
+
3
+ module Daddy
4
+ module Cucumber
5
+ module Pause
6
+
7
+ def pause(second = nil)
8
+ duration = (second || ENV['PAUSE'] || 1).to_i
9
+ sleep(duration) if duration > 0
10
+ end
11
+
12
+ def wait_until
13
+ pause_count = 5
14
+ while pause_count > 0 do
15
+ break if yield
16
+ pause
17
+ pause_count -= 1
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+
25
+ World(Daddy::Cucumber::Pause)
@@ -22,3 +22,5 @@ module Daddy
22
22
  end
23
23
  end
24
24
  end
25
+
26
+ World(Daddy::Cucumber::Table)
@@ -1,6 +1,6 @@
1
1
  #menu {
2
+ width: 100px;
2
3
  float: left;
3
- margin-right: 10px;
4
4
  background: #FFFFFF;
5
5
  color: #000000;
6
6
  }
@@ -23,17 +23,18 @@
23
23
 
24
24
  #menu ol li.sub_menu {
25
25
  margin: 0;
26
- padding: 0 20px 0 20px;
26
+ padding: 0 5px;
27
27
  border-left: 5px solid #65c400;
28
28
  border-bottom: 1px solid #65c400;
29
- line-height: 40px;
29
+ line-height: 30px;
30
+ text-align: right;
30
31
  vertical-align: middle;
31
32
  font-size: 1.2em;
32
33
  font-weight: bold;
33
34
  }
34
35
 
35
36
  .contents {
36
- margin-left: 120px;
37
+ margin-left: 100px;
37
38
  }
38
39
 
39
40
  .cucumber .scenario h3, td .scenario h3, th .scenario h3, .background h3 {
@@ -1,35 +1,36 @@
1
1
  <%
2
- branches = []
3
- `git branch -a`.split("\n").each do |b|
4
- next if b.index('HEAD')
5
- next if b.index('gh-pages')
6
- next unless b.index('remotes/origin/')
7
- branches << b.strip.sub('remotes/origin/', '')
8
- end
9
-
10
- branches.sort! do |a, b|
11
- if a == 'master'
12
- -1
13
- elsif b == 'master'
14
- 1
15
- else
16
- b <=> a
17
- end
18
- end
19
- %>
20
- <% branches.each do |b| %>
2
+ load File.dirname(File.dirname(__FILE__)) + '/git.rb'
3
+ git = Daddy::Git.new
4
+ -%>
5
+
6
+ <script>
7
+ $(document).ready(function() {
8
+ $('.sprint').mouseover(function() {
9
+ $(this).css('background', '#F0F8FF').css('cursor', 'pointer');
10
+ }).mouseout(function() {
11
+ $(this).css('background', '#FFFFFF');
12
+ }).click(function() {
13
+ $(this).nextAll('.sub_menu').toggle(250);
14
+ });
15
+
16
+ $('.current').click();
17
+ });
18
+ </script>
19
+
20
+ <% git.branches.each do |b| %>
21
21
  <ol>
22
22
  <% title = (b == 'master' ? '最新' : 'スプリント ' + b.gsub(/[a-zA-Z]*/, '')) %>
23
- <li class="sprint">
23
+
24
+ <li class="sprint <%= 'current' if b == git.current_branch %>">
24
25
  <%= title %>
25
26
  </li>
26
- <li class="sprint sub_menu">
27
+ <li class="sub_menu" style="display: none;">
27
28
  <a href="../<%= b %>/index.html">仕様書</a>
28
29
  </li>
29
- <li class="sprint sub_menu">
30
+ <li class="sub_menu" style="display: none;">
30
31
  <a href="../<%= b %>/diary.html">開発日記</a>
31
32
  </li>
32
- <li class="sprint sub_menu">
33
+ <li class="sub_menu" style="display: none;">
33
34
  <a href="../<%= b %>/coverage/rcov/index.html" target="_blank">カバレッジ</a>
34
35
  </li>
35
36
  </ol>
data/lib/daddy/git.rb ADDED
@@ -0,0 +1,39 @@
1
+ # coding: UTF-8
2
+
3
+ Dir::glob(File.dirname(__FILE__) + '/git/*.rb').each do |file|
4
+ require file
5
+ end
6
+
7
+ module Daddy
8
+
9
+ class Git
10
+ def branches
11
+ branches = []
12
+ `git branch -a`.split("\n").each do |b|
13
+ next if b.index('HEAD')
14
+ next if b.index('gh-pages')
15
+ next unless b.index('remotes/origin/')
16
+ branches << b.strip.sub('remotes/origin/', '')
17
+ end
18
+
19
+ branches.sort! do |a, b|
20
+ if a == 'master'
21
+ -1
22
+ elsif b == 'master'
23
+ 1
24
+ else
25
+ b <=> a
26
+ end
27
+ end
28
+
29
+ branches
30
+ end
31
+
32
+ def current_branch
33
+ `git branch`.split("\n").each do |b|
34
+ return b.split.last if b.start_with?('*')
35
+ end
36
+ end
37
+ end
38
+
39
+ end
@@ -1,20 +1,21 @@
1
1
  # coding: UTF-8
2
2
 
3
+ require 'daddy/git'
4
+
3
5
  namespace :dad do
4
- task :publish do |t|
6
+ task :publish do
5
7
  system("mkdir -p features/reports")
6
8
  system("bundle exec rake db:test:prepare")
7
9
  system("bundle exec rake dad:cucumber PUBLISH=true OUTPUT_FILE=diary.html features/開発日記")
8
10
  system("bundle exec rake dad:cucumber PUBLISH=true OUTPUT_FILE=index.html features/仕様書")
9
11
 
10
12
  system("mkdir -p tmp")
11
- system("git branch > tmp/branches")
12
- current_branch = 'master'
13
- File.readlines('tmp/branches').each do |b|
14
- if b.start_with?('*')
15
- current_branch = b.split[1]
16
- break
17
- end
13
+
14
+ if ENV['BRANCH']
15
+ current_branch = ENV['BRANCH']
16
+ else
17
+ git = Daddy::Git.new
18
+ current_branch = git.current_branch
18
19
  end
19
20
 
20
21
  unless File.exist?('tmp/gh-pages')
@@ -34,4 +35,5 @@ namespace :dad do
34
35
  system("cd tmp/gh-pages && git commit -m 'publish'")
35
36
  system("cd tmp/gh-pages && git push")
36
37
  end
38
+
37
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-15 00:00:00.000000000 Z
11
+ date: 2013-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: differ
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: jquery-rails
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -187,10 +201,13 @@ extra_rdoc_files: []
187
201
  files:
188
202
  - lib/daddy.rb
189
203
  - lib/daddy/cucumber.rb
204
+ - lib/daddy/cucumber/pause.rb
190
205
  - lib/daddy/cucumber/capture.rb
206
+ - lib/daddy/cucumber/html.rb
191
207
  - lib/daddy/cucumber/step_definitions/common.rb
192
208
  - lib/daddy/cucumber/assert.rb
193
209
  - lib/daddy/cucumber/table.rb
210
+ - lib/daddy/git.rb
194
211
  - lib/daddy/formatter/menu.html.erb
195
212
  - lib/daddy/formatter/html.rb
196
213
  - lib/daddy/formatter/daddy.css