bushido 0.0.17 → 0.0.20
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.
- data/app/controllers/bushido/envs_controller.rb +36 -0
- data/bushido.gemspec +4 -4
- data/config/routes.rb +1 -0
- data/lib/bushido/hooks.rb +34 -0
- data/lib/bushido/middleware.rb +47 -0
- data/lib/bushido/user.rb +1 -1
- data/lib/bushido/version.rb +1 -1
- data/lib/bushido.rb +4 -1
- data/lib/engine.rb +13 -0
- data/lib/rails/routes.rb +13 -0
- data/test/routes_test.rb +12 -0
- metadata +14 -4
@@ -0,0 +1,36 @@
|
|
1
|
+
module Bushido
|
2
|
+
class EnvsController < ApplicationController
|
3
|
+
#GET /bushido/envs/:id
|
4
|
+
def show
|
5
|
+
@value = ENV[params[:id]]
|
6
|
+
respond_to do |format|
|
7
|
+
if @value.nil?
|
8
|
+
format.html{render :file => "#{Rails.root}/public/404.html", :status => :not_found}
|
9
|
+
format.json{render :status => :not_found}
|
10
|
+
else
|
11
|
+
format.html{render :text => @value}
|
12
|
+
format.json{render :json => {params[:id] => ENV[params[:id]]}}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
#PUT /bushido/envs/:id
|
18
|
+
def update
|
19
|
+
return if ENV["BUSHIDO_KEY"] != params[:key]
|
20
|
+
ENV[params[:id]] = params[:v]
|
21
|
+
@value = ENV[params[:id]]
|
22
|
+
|
23
|
+
respond_to do |format|
|
24
|
+
if @value != ENV[params[:id]]
|
25
|
+
format.html{render :layout => false, :text => true, :status => :unprocessable_entity}
|
26
|
+
format.json{render :status => :unprocessable_entity}
|
27
|
+
else
|
28
|
+
puts "omg calling fire method from controller"
|
29
|
+
Bushido::Hooks.fire(params[:id], {params[:id] => ENV[params[:id]]})
|
30
|
+
format.html{render :text => true}
|
31
|
+
format.json{render :json => {params[:id] => ENV[params[:id]]}}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/bushido.gemspec
CHANGED
@@ -6,11 +6,11 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "bushido"
|
7
7
|
s.version = Bushido::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["Sean Grove"]
|
10
|
-
s.email = ["s@bushi.do"]
|
9
|
+
s.authors = ["Sean Grove", "Kev Zettler"]
|
10
|
+
s.email = ["support@bushi.do","s@bushi.do"]
|
11
11
|
s.homepage = "https://github.com/sgrove/bushidogem"
|
12
|
-
s.summary = %q{
|
13
|
-
s.description = %q{A module for
|
12
|
+
s.summary = %q{Bushido integration}
|
13
|
+
s.description = %q{A module for integrating the Bushido platform into a rails app}
|
14
14
|
|
15
15
|
s.add_dependency "rest-client", ">=1.6.1"
|
16
16
|
s.add_dependency "json", ">=1.4.6"
|
data/config/routes.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Bushido
|
2
|
+
class Hooks #:nodoc:
|
3
|
+
|
4
|
+
@@hooks = {}
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def fire *hooks, data
|
8
|
+
unless @@hooks[:global].nil?
|
9
|
+
@@hooks[:global].call('global', data)
|
10
|
+
end
|
11
|
+
|
12
|
+
if hooks.length > 0
|
13
|
+
hooks.each do |h|
|
14
|
+
unless @@hooks[h].nil?
|
15
|
+
@@hooks[h].call(h, data)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def listen *hooks, &block
|
22
|
+
if hooks.empty? and block_given?
|
23
|
+
@@hooks[:global] = block
|
24
|
+
elsif !hooks.nil? and block_given?
|
25
|
+
hooks.each do |h|
|
26
|
+
@@hooks[h] = block
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rack/utils'
|
2
|
+
|
3
|
+
module Bushido
|
4
|
+
class Middleware
|
5
|
+
|
6
|
+
# BUSHIDO_JS_URL = 'http://localhost:4567/javascripts/bushido.js'
|
7
|
+
BUSHIDO_JS_URL = 'http://bushi.do/api/bushido.js'
|
8
|
+
|
9
|
+
include Rack::Utils
|
10
|
+
|
11
|
+
def initialize(app, opts = {})
|
12
|
+
@app = app
|
13
|
+
@bushido_app_name = ENV['BUSHIDO_APP']
|
14
|
+
@bushido_metrics_token = ENV['BUSHIDO_METRICS_TOKEN']
|
15
|
+
@bushido_claimed = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(env)
|
19
|
+
status, headers, response = @app.call(env)
|
20
|
+
|
21
|
+
content = ""
|
22
|
+
response.each { |part| content += part }
|
23
|
+
|
24
|
+
# "claiming" bar + stats ?
|
25
|
+
content.gsub!(/<\/body>/i, <<-STR
|
26
|
+
<script type="text/javascript">
|
27
|
+
var _bushido_app = '#{@bushido_app_name}';
|
28
|
+
var _bushido_claimed = #{@bushido_claimed.to_s};
|
29
|
+
var _bushido_metrics_token = '#{@bushido_metrics_token}';
|
30
|
+
(function() {
|
31
|
+
var bushido = document.createElement('script'); bushido.type = 'text/javascript'; bushido.async = true;
|
32
|
+
bushido.src = '#{BUSHIDO_JS_URL}?#{::Bushido::VERSION.gsub('.', '')}';
|
33
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(bushido, s);
|
34
|
+
})();
|
35
|
+
</script>
|
36
|
+
</body>
|
37
|
+
STR
|
38
|
+
)
|
39
|
+
|
40
|
+
headers['content-length'] = bytesize(content).to_s
|
41
|
+
|
42
|
+
[status, headers, [content]]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/lib/bushido/user.rb
CHANGED
data/lib/bushido/version.rb
CHANGED
data/lib/bushido.rb
CHANGED
@@ -3,7 +3,8 @@ module Bushido #:nodoc:
|
|
3
3
|
require 'rest-client'
|
4
4
|
require 'json'
|
5
5
|
require 'highline/import'
|
6
|
-
|
6
|
+
|
7
|
+
require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
7
8
|
require "bushido/platform"
|
8
9
|
require "bushido/utils"
|
9
10
|
require "bushido/command"
|
@@ -11,4 +12,6 @@ module Bushido #:nodoc:
|
|
11
12
|
require "bushido/user"
|
12
13
|
require "bushido/event"
|
13
14
|
require "bushido/version"
|
15
|
+
require "bushido/hooks"
|
16
|
+
require "bushido/middleware"
|
14
17
|
end
|
data/lib/engine.rb
ADDED
data/lib/rails/routes.rb
ADDED
data/test/routes_test.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DefaultRoutingTest < ActionController::TestCase
|
4
|
+
test 'set passed variable' do
|
5
|
+
assert_recognizes({:controller => 'bushido', :action => 'index'}, {:path => 'bushido', :method => :post})
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'get passed variable' do
|
9
|
+
assert_recognizes({:controller => 'bushido', :action => 'index'}, {:path => 'bushido', :method => :get})
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
metadata
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
name: bushido
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.20
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sean Grove
|
9
|
+
- Kev Zettler
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
|
-
date: 2011-06-
|
14
|
+
date: 2011-06-11 00:00:00 -07:00
|
14
15
|
default_executable:
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
@@ -46,8 +47,9 @@ dependencies:
|
|
46
47
|
version: 1.6.1
|
47
48
|
type: :runtime
|
48
49
|
version_requirements: *id003
|
49
|
-
description: A module for
|
50
|
+
description: A module for integrating the Bushido platform into a rails app
|
50
51
|
email:
|
52
|
+
- support@bushi.do
|
51
53
|
- s@bushi.do
|
52
54
|
executables:
|
53
55
|
- bushido
|
@@ -59,16 +61,23 @@ files:
|
|
59
61
|
- .gitignore
|
60
62
|
- Gemfile
|
61
63
|
- Rakefile
|
64
|
+
- app/controllers/bushido/envs_controller.rb
|
62
65
|
- bin/bushido
|
63
66
|
- bushido.gemspec
|
67
|
+
- config/routes.rb
|
64
68
|
- lib/bushido.rb
|
65
69
|
- lib/bushido/app.rb
|
66
70
|
- lib/bushido/command.rb
|
67
71
|
- lib/bushido/event.rb
|
72
|
+
- lib/bushido/hooks.rb
|
73
|
+
- lib/bushido/middleware.rb
|
68
74
|
- lib/bushido/platform.rb
|
69
75
|
- lib/bushido/user.rb
|
70
76
|
- lib/bushido/utils.rb
|
71
77
|
- lib/bushido/version.rb
|
78
|
+
- lib/engine.rb
|
79
|
+
- lib/rails/routes.rb
|
80
|
+
- test/routes_test.rb
|
72
81
|
- test/test_executable.rb
|
73
82
|
has_rdoc: true
|
74
83
|
homepage: https://github.com/sgrove/bushidogem
|
@@ -97,6 +106,7 @@ rubyforge_project: bushido
|
|
97
106
|
rubygems_version: 1.6.2
|
98
107
|
signing_key:
|
99
108
|
specification_version: 3
|
100
|
-
summary:
|
109
|
+
summary: Bushido integration
|
101
110
|
test_files:
|
111
|
+
- test/routes_test.rb
|
102
112
|
- test/test_executable.rb
|