bait 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3c5af67ed0329a0614ff18ff0a026a99319e0ba
4
- data.tar.gz: 982fcc03f85c56a2601599fd2c7666fe7ad1f26e
3
+ metadata.gz: f731d3eadd100d677db8a67aea6e93cfb2fb7e71
4
+ data.tar.gz: c46a0e68d7812ea7107eeb91c50e8066733574f1
5
5
  SHA512:
6
- metadata.gz: ac1219d79448efc9c7756acf63eb1778ab53c9394a0f833467f92985477ed2d43f72a51fe19289b91f4ef82aa52bbb495222ff6dc48d5c645be9c6a5417a3df5
7
- data.tar.gz: bd5b7a3855e2e09d797b850baa0649500cc9dc984ddd82d7c85bc851ac852818daa74b69fdcdafd7781ed4e81eec1f0e5cd82a88825ad16380b8c6ae9a418289
6
+ metadata.gz: f262d95d082542abb556dd864e610614057f50f63400b6a7878ffffb9a50ee244436551b7e0a01be4ddfd41df3987bc178329177028112c57e7599cdaa376912
7
+ data.tar.gz: 60ccfa1b81f4b92dabe717b75d88e64c5c6c14771d3c75147452e63f8bc830270f1f1511db0fc6ff7374259aa2609600d06b9bf6a1483a9e22c1b0e0b6ec0146
@@ -5,4 +5,4 @@ cd $project_dir
5
5
 
6
6
  echo "bundling"
7
7
  bundle > /dev/null 2>&1
8
- bundle exec rspec spec
8
+ bundle exec rspec spec --color --format documentation
@@ -1,11 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bait (0.4.1)
4
+ bait (0.5.0)
5
5
  git
6
6
  haml
7
7
  moneta
8
8
  sinatra
9
+ sinatra-asset-snack
10
+ sinatra-contrib
11
+ sucker_punch
9
12
  thin
10
13
  toystore
11
14
 
@@ -19,11 +22,20 @@ GEM
19
22
  i18n (~> 0.6, >= 0.6.4)
20
23
  multi_json (~> 1.0)
21
24
  adapter (0.7.0)
25
+ backports (3.3.3)
22
26
  builder (3.0.4)
27
+ celluloid (0.14.1)
28
+ timers (>= 1.0.0)
23
29
  coderay (1.0.9)
30
+ coffee-script (2.2.0)
31
+ coffee-script-source
32
+ execjs
33
+ coffee-script-source (1.6.3)
24
34
  daemons (1.1.9)
25
35
  diff-lcs (1.2.4)
26
36
  eventmachine (1.0.3)
37
+ execjs (1.4.0)
38
+ multi_json (~> 1.0)
27
39
  ffi (1.9.0)
28
40
  formatador (0.2.4)
29
41
  git (1.2.5)
@@ -36,7 +48,7 @@ GEM
36
48
  guard-rspec (3.0.2)
37
49
  guard (>= 1.8)
38
50
  rspec (~> 2.13)
39
- haml (4.0.2)
51
+ haml (4.0.3)
40
52
  tilt
41
53
  i18n (0.6.4)
42
54
  listen (1.2.2)
@@ -45,6 +57,7 @@ GEM
45
57
  rb-kqueue (>= 0.2)
46
58
  lumberjack (1.0.4)
47
59
  method_source (0.8.1)
60
+ mime-types (1.23)
48
61
  moneta (0.7.19)
49
62
  multi_json (1.7.7)
50
63
  pry (0.9.12.2)
@@ -70,6 +83,7 @@ GEM
70
83
  rspec-expectations (2.14.0)
71
84
  diff-lcs (>= 1.1.3, < 2.0)
72
85
  rspec-mocks (2.14.1)
86
+ sass (3.2.10)
73
87
  simple_uuid (0.3.0)
74
88
  simplecov (0.7.1)
75
89
  multi_json (~> 1.0)
@@ -79,13 +93,28 @@ GEM
79
93
  rack (~> 1.4)
80
94
  rack-protection (~> 1.4)
81
95
  tilt (~> 1.3, >= 1.3.4)
96
+ sinatra-asset-snack (0.1.5)
97
+ coffee-script
98
+ mime-types
99
+ sass
100
+ sinatra
101
+ sinatra-contrib (1.4.0)
102
+ backports (>= 2.0)
103
+ eventmachine
104
+ rack-protection
105
+ rack-test
106
+ sinatra (~> 1.4.2)
107
+ tilt (~> 1.3)
82
108
  slop (3.4.6)
109
+ sucker_punch (1.0.1)
110
+ celluloid (~> 0.14.1)
83
111
  thin (1.5.1)
84
112
  daemons (>= 1.0.9)
85
113
  eventmachine (>= 0.12.6)
86
114
  rack (>= 1.0.0)
87
115
  thor (0.18.1)
88
116
  tilt (1.4.1)
117
+ timers (1.1.0)
89
118
  toystore (0.13.2)
90
119
  activemodel (~> 3.0)
91
120
  activesupport (~> 3.0)
data/README.md CHANGED
@@ -20,32 +20,26 @@ You may also test manually by inputting a clone URL within the UI
20
20
  # Architectural Overview
21
21
 
22
22
  ```
23
- Github POST bait:8417/
24
- ______________________ \./
25
- | Mac OS X 10.8 | |
26
- | w/ RubyMotion | |
27
- | ---------------- +---------+----------------+
28
- | +---+---+ |
29
- | | API |----[haml]------- you
30
- | +---+---+ |
31
- | | |
32
- | +---------+--+ |
33
- | |Bait::Build | |
34
- | +---+-----+--+ |
35
- | \|/ /|\ |
36
- | \|/ /|\ |
37
- | \[build]\ |
38
- | \|/ /|\ |
39
- | _____________ \|/ /|\ |
40
- | [ your project] +------------+ |
41
- | [.bait/test.sh]------|Bait::Tester| |
42
- | [status/output] +------------+ |
23
+ Github POST bait:8417/--------+
24
+ |
25
+ +----------------------------------------|------+
26
+ | +------------+ +--\|/--+ | +-------------+
27
+ | | new Build <------------------| API <----| Browser |
28
+ | +-----+------+ | | | | |
29
+ | | | | | | |
30
+ | | +-------------+ | | | | |
31
+ | | | EventStream | | | | | |
32
+ | +---\|/----+ | Connection <------+ | | | |
33
+ | |Queue Job | | | | | | | | |
34
+ | +----+-----+ |Build Events | | | | | | |
35
+ | | |Subscription | | | | | | |
36
+ | | +--+------+---+ |/events----->[EventSource]|
37
+ | +----\|/-----+ | | +---+---+ | +-------------+
38
+ | | Test Build | | | | |
39
+ | |[subprocess]+----+ +----------+ |
40
+ | +------------+ |
43
41
  | |
44
42
  +-----------------------------------------------+
45
-
46
- Bait::Build -- Persistent ToyStore
47
-
48
- Bait::Tester -- Runs your tests and persists results in Bait::Build
49
43
  ```
50
44
 
51
45
  *Created with [JavE](http://www.jave.de/)*
data/Rakefile CHANGED
@@ -4,3 +4,7 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+
8
+ task :pry do
9
+ require 'pry'; binding.pry
10
+ end
data/VERSION CHANGED
@@ -1,3 +1,3 @@
1
- 0.4.1
1
+ 0.5.0
2
2
 
3
3
 
@@ -0,0 +1,11 @@
1
+ window.Bait =
2
+ # Wrap our usage of event source:
3
+ # Incoming data is always an Array, the
4
+ # first value indicates the scope
5
+ # the second value is the callback
6
+ subscribe: (handlers) ->
7
+ source = new EventSource('/events')
8
+ source.addEventListener "message", (e) ->
9
+ data = JSON.parse(e.data)
10
+ handler = handlers[data[0]][data[1]]
11
+ handler.apply(@, data.slice(2))
@@ -0,0 +1,67 @@
1
+ window.Build =
2
+ find: (id) -> $("##{id}")
3
+
4
+ all: (cb) -> $.getJSON '/build', (data) -> cb(data)
5
+
6
+ DOM:
7
+ UIHelper:
8
+ # Click log to expand/collapse
9
+ expand_toggle: (el) ->
10
+ el.on "click", (e) ->
11
+ if el.css("max-height") is "100px"
12
+ el.css "max-height", "100%"
13
+ else
14
+ el.css "max-height", "100px"
15
+
16
+ enable_links: (element) ->
17
+ element.find('a.remove').click ->
18
+ $.ajax
19
+ type: "DELETE"
20
+ url: $(@).data('url')
21
+ return false
22
+
23
+ element.find('a.retest').click ->
24
+ $(@).parents('.build').find('pre').html("")
25
+ $.post $(@).data('url')
26
+ return false
27
+
28
+ init: (build_id) ->
29
+ build = Build.find(build_id)
30
+
31
+ # Color the output logs
32
+ pre = build.find(".output pre")
33
+ output = pre.html()
34
+ if output? && output.size > 0
35
+ pre.html ansi2html(output)
36
+
37
+ # Enable expansion toggle
38
+ Build.DOM.UIHelper.expand_toggle pre
39
+ Build.DOM.UIHelper.enable_links build
40
+
41
+ List:
42
+ add: (build) ->
43
+ html = Build.to_html(build)
44
+ if $('.build').length > 0
45
+ $('.build').first().before html
46
+ else
47
+ $('ul#builds').append html
48
+ Build.DOM.init build.id
49
+
50
+ to_html: (build) ->
51
+ """
52
+ <li id="#{build.id}" class="build">
53
+ <div class="header #{build.status}">
54
+ <div class="status">#{build.status}</div>
55
+ <a href="#{build.clone_url}">#{build.name}</a>
56
+ <div class="ref">#{build.ref?=''}</div>
57
+ </div>
58
+ <div class="output">
59
+ <pre>#{build.output}</pre>
60
+ </div>
61
+ <div class="actions">
62
+ <a href="#" class="remove" data-url="/build/#{build.id}">Remove</a>
63
+ |
64
+ <a href="#" class="retest" data-url="/build/#{build.id}/retest">Retest</a>
65
+ </div>
66
+ </li>
67
+ """
@@ -0,0 +1,22 @@
1
+ Zepto ($) ->
2
+ ManualClone.init()
3
+
4
+ Build.all (builds) ->
5
+ $.each builds, (i,d) ->
6
+ Build.List.add d.build
7
+ $("#loading").remove()
8
+
9
+ Bait.subscribe
10
+ global:
11
+ new_build: (data) ->
12
+ Build.List.add data.build
13
+ build:
14
+ output: (id, text) ->
15
+ pre = Build.find(id).find('pre')
16
+ pre.append ansi2html(text)
17
+ status: (id, text) ->
18
+ header = Build.find(id).find(".header")
19
+ header.find(".status").html text
20
+ header.attr "class", "header #{text}"
21
+ remove: (id) ->
22
+ Build.find(id).remove()
@@ -0,0 +1,24 @@
1
+ window.ManualClone =
2
+ init: ->
3
+ form = $('.manual_clone')
4
+ field = form.find('input')
5
+ button = form.find('button')
6
+ manual_clone = ->
7
+ input = field.val()
8
+ if input.length > 0
9
+ if not button.attr('disabled')
10
+ button.attr('disabled', 'disabled')
11
+ $.post '/build/create', {clone_url: input}, (response) ->
12
+ console.log response
13
+ button.removeAttr('disabled')
14
+ else
15
+ alert "Enter a local path or remote url to a git repo, e.g.:\n
16
+ Local: /Users/your/project\n
17
+ Remote: https://github.com/your/project"
18
+
19
+ field.keypress (e) ->
20
+ if e.keyCode is 13
21
+ manual_clone()
22
+
23
+ button.on 'click', ->
24
+ manual_clone()
@@ -0,0 +1,30 @@
1
+ .build {
2
+ border-radius:12px;
3
+ border:2px solid RGB(201,49,20);
4
+ margin:20px;
5
+ .header {
6
+ border-top-left-radius: 10px;
7
+ border-top-right-radius: 10px;
8
+ padding: 5px;
9
+ position:relative;
10
+ .status {
11
+ top:4px;
12
+ right:4px;
13
+ position:absolute;
14
+ }
15
+ }
16
+ .header.passed {
17
+ background-color:RGB(71,213,86);
18
+ }
19
+ .header.failed {
20
+ background-color: RGB(247,65,67);
21
+ }
22
+ .output pre {
23
+ cursor:pointer;
24
+ color: white;
25
+ background-color:black;
26
+ max-height:100px;
27
+ overflow-y:hidden;
28
+ overflow-x:scroll;
29
+ }
30
+ }
@@ -0,0 +1,28 @@
1
+ @font-face {
2
+ font-family: 'Ubuntu';
3
+ font-style: normal;
4
+ font-weight: 400;
5
+ src: local('Ubuntu'), url(/fonts/ubuntu.woff) format('woff');
6
+ }
7
+
8
+ body {
9
+ font-family: 'Ubuntu';
10
+ background-color:RGB(255,254,254);
11
+ }
12
+
13
+ .actions {
14
+ background-color:RGB(254,238,195);
15
+ text-align:center;
16
+ border-bottom-left-radius: 10px;
17
+ border-bottom-right-radius: 10px;
18
+ a {
19
+ color: RGB(20,77,105);
20
+ text-decoration:none;
21
+ }
22
+ a:hover {
23
+ color: RGB(201,49,20);
24
+ }
25
+ }
26
+
27
+
28
+
@@ -27,9 +27,12 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'simplecov'
28
28
 
29
29
  spec.add_runtime_dependency "sinatra"
30
+ spec.add_runtime_dependency "sinatra-contrib"
31
+ spec.add_runtime_dependency 'sinatra-asset-snack'
30
32
  spec.add_runtime_dependency "moneta"
31
33
  spec.add_runtime_dependency "toystore"
32
34
  spec.add_runtime_dependency "git"
33
35
  spec.add_runtime_dependency "haml"
34
36
  spec.add_runtime_dependency "thin"
37
+ spec.add_runtime_dependency "sucker_punch"
35
38
  end
@@ -1,14 +1,22 @@
1
1
  require 'sinatra'
2
+ require 'sinatra/streaming'
3
+ require 'sinatra/asset_snack'
2
4
  require 'haml'
3
5
  require 'json'
6
+ require 'bait/pubsub'
4
7
  require 'bait/build'
5
8
 
6
9
  module Bait
7
10
  class Api < Sinatra::Base
11
+ register Sinatra::AssetSnack
8
12
  set :port, 8417
13
+ set server: 'thin'
14
+
15
+ asset_map '/javascript/application.js', ['assets/js/**/*.js', 'assets/js/**/*.coffee']
16
+ asset_map '/stylesheets/application.css', ['assets/stylesheets/**/*.css', 'assets/stylesheets/**/*.scss']
9
17
 
10
18
  get '/' do
11
- redirect '/build'
19
+ haml :builds
12
20
  end
13
21
 
14
22
  post '/' do
@@ -25,8 +33,9 @@ module Bait
25
33
  end
26
34
 
27
35
  get '/build' do
36
+ content_type :json
28
37
  @builds = Bait::Build.all
29
- haml :builds
38
+ @builds.to_json
30
39
  end
31
40
 
32
41
  post '/build/create' do
@@ -35,21 +44,26 @@ module Bait
35
44
  name:params["clone_url"].split('/').last
36
45
  })
37
46
  build.test_later
38
- redirect '/build'
39
47
  end
40
48
 
41
- get '/build/:id/remove' do
49
+ delete '/build/:id' do
42
50
  Build.destroy params["id"]
43
- redirect '/build'
44
51
  end
45
52
 
46
- get '/build/:id/retest' do
53
+ post '/build/:id/retest' do
47
54
  build = Build.find params['id']
48
- build.tested = false
49
- build.output = ""
50
- build.save
51
55
  build.test_later
52
- redirect '/build'
56
+ end
57
+
58
+ helpers Sinatra::Streaming
59
+
60
+ get '/events', provides: 'text/event-stream' do
61
+ stream(:keep_open) do |out|
62
+ Bait.add_subscriber out
63
+ out.callback do
64
+ Bait.remove_subscriber out
65
+ end
66
+ end
53
67
  end
54
68
  end
55
69
  end