sabisu_rails 0.0.1.pre.beta → 0.0.2.pre.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 284b0d527cd0903c0553fdbb85a121935c342e83
4
- data.tar.gz: db4e336d9dfeee82b8f322b67d2730f19290db15
3
+ metadata.gz: 6491eb8ca8d239f42738e91af6c92ee0dc42c56e
4
+ data.tar.gz: d701d1baaca8fffdba75291bdf83f71e7f6308ec
5
5
  SHA512:
6
- metadata.gz: 54ba3eaf47892f081eed2a42fb0ea1d6d7d7cdd8a6a9ec16a89c45ce5ecc737f0206c3c86ce292565c404a4257a077aa26bc691cdf62cdfd386ba0f1c8d63f7f
7
- data.tar.gz: bfa4740da7113d819377b2313bc03714d41b2e90ca22e43e5cb357972b37ec41caf7df7c29b93ba89c032065b3136653355fea0765aa5a59d88c550e710e8e1d
6
+ metadata.gz: 19e9c26894ed33d2f675e8da6ed5f7085dff9c3171e1f3e73e49081108b748619f0a63c121a3910e07921623a497b8d9c2d2d6e449cb07c224acf8ff2d358c40
7
+ data.tar.gz: 31e4150830c255866c8ea0d611bb2afefc94587c9e1e17ec28cce523b7fa768adba910d7d1219b1503d11c851febded3f6e71eb176d7ae56137b1f0818bba35e
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [Sabisu](https://github.com/IcaliaLabs/sabisu)
1
+ # [Sabisu](https://github.com/IcaliaLabs/sabisu-rails)
2
2
 
3
3
  Sabisu is a powerful postman-like engine client to explore your Rails application api. It's still under heavy development, but it is quite impressive and beautiful. Give it a try!
4
4
 
@@ -103,6 +103,29 @@ Keep track of new feautres, development issues and community news.
103
103
  + [http://github.com/kurenn](http://github.com/kurenn)
104
104
  + [http://klout.com/#/kurenn](http://klout.com/#/kurenn)
105
105
 
106
+ ## A live example
107
+
108
+ We have deployed an example application on Heroku for you to give it a spin, visit `http://sabisu.herokuapp.com/sabisu_rails/explorer` and because is a demo the api only has GET endpoints.
109
+
110
+ The authentication credentials are:
111
+
112
+ ```
113
+ username: admin
114
+ password: sekret
115
+ ```
116
+
117
+ The file configuration for Heroku turns out to be more complex, check it out:
118
+
119
+ ```ruby
120
+ SabisuRails.setup do |config|
121
+
122
+ config.base_api_uri = ENV['API_URL']
123
+ config.resources = ["products", "users"]
124
+ config.default_resource = "users"
125
+
126
+ end
127
+ ```
128
+
106
129
 
107
130
  ## Copyright and license
108
131
 
@@ -37,4 +37,13 @@ $ ->
37
37
  $('#explorer_form').submit ->
38
38
  Pace.start()
39
39
 
40
-
40
+ $('.appeareable').hide()
41
+
42
+ $('#explorer_http_method').change ->
43
+ $('#explorer_uri_pattern').val('')
44
+ if $(@).val() is "GET" or $(@).val() is "DELETE"
45
+ $('.appeareable').hide()
46
+ $('.hideaway').show()
47
+ else
48
+ $('.appeareable').show()
49
+ $('.hideaway').hide()
@@ -1,8 +1,7 @@
1
1
  .main-content {
2
2
  border-left: 1px solid darken(#F5F5F5, 5%);
3
- padding-left: 30px;
4
3
  background: #FFF;
5
- padding-bottom: 20px;
4
+ padding: 30px;
6
5
  }
7
6
 
8
7
  .navigation {
@@ -78,14 +77,24 @@ fieldset {
78
77
 
79
78
  .navigation {
80
79
  &.inline {
80
+ border-top: 1px solid #CCC;
81
+ padding: 0;
81
82
  li {
83
+ border-right: 1px solid #CCC;
84
+ padding: 6px 10px;
85
+ border-bottom: 1px solid #CCC;
86
+
87
+ &:first-child {
88
+ border-left: 1px solid #CCC;
89
+ }
82
90
  a {
83
- padding: 2px 5px;
84
- font-weight: lighter;
91
+ padding: 6px 10px;
92
+ font-weight: bold;
93
+ font-size: px-to-rems(14);
85
94
  }
86
95
 
87
96
  &.active {
88
- border-top: 2px solid darken($navigation-inline-active-background, 10%);
97
+ border-bottom: 1px solid #FFF;
89
98
  }
90
99
  }
91
100
  }
@@ -94,10 +103,24 @@ fieldset {
94
103
  .response-details {
95
104
  float: right;
96
105
  padding-right: 25px;
106
+ .navigation {
107
+ &.inline {
108
+ li {
109
+ border-right: none;
110
+ border-bottom: none;
111
+ color: #777;
112
+
113
+ &:first-child {
114
+ border-left: none;
115
+ }
116
+ }
117
+ }
118
+ }
97
119
  }
98
120
 
99
121
  .response-wrapper {
100
122
  padding-right: 10px;
123
+ margin-top: 20px;
101
124
  }
102
125
 
103
126
  .text-strong {
@@ -7,8 +7,14 @@ $navigation-list-link-padding: 12px 0;
7
7
  $navigation-link-color: #333;
8
8
  $navigation-list-item-font-size: 1rem;
9
9
 
10
- $navigation-inline-active-background: #B2789C;
11
- $navigation-inline-active-padding: 2px 10px;
10
+ $navigation-inline-active-background: #FFF;
11
+ $navigation-inline-active-padding: 6px 10px;
12
+ $navigation-inline-margin-bottom: 15px;
13
+
14
+ $navigation-inline-active-color: #222;
15
+ $navigation-inline-link-color: rgba(#777, 0.3);
16
+ $navigation-inline-link-hover: #08C;
17
+ $navigation-inline-list-item-margin-left: 0;
12
18
 
13
19
  // Base overrides
14
20
  $body-background-color: #F5F5F5;
@@ -22,3 +28,6 @@ $button-success-background: #8ABD68;
22
28
  // Labels
23
29
  $label-default-background: $button-default-background-color;
24
30
  $label-primary-background: #34495e;
31
+
32
+ // Experimental
33
+ $include-flexible-addons: true;
@@ -2,7 +2,7 @@ module SabisuRails
2
2
  class ExplorerController < SabisuRails::BaseController
3
3
 
4
4
  def index
5
- @resources = SabisuRails.resources
5
+ @resources = SabisuRails.resources_names
6
6
  @explorer = SabisuRails::Explorer.new(params[:explorer] || {})
7
7
  @response = SabisuRails::Request.new(@explorer, params[@explorer.resource_name], params[:explorer]).response
8
8
  respond_to do |format|
@@ -5,7 +5,7 @@ module SabisuRails::ExplorerHelper
5
5
  end
6
6
 
7
7
  def active_resource_state(resource)
8
- loaded_resource = SabisuRails.default_resource
8
+ loaded_resource = SabisuRails.default_resource.to_s
9
9
  if params[:explorer].nil?
10
10
  "active" if loaded_resource == resource
11
11
  else
@@ -10,16 +10,14 @@
10
10
  <div class="col-10 nopadding">
11
11
  <div class="main-content">
12
12
  <div class="row">
13
- <div class="col-2">
14
- <h4 class="text-muted"><%= "/#{@explorer.resource}/" %></h4>
15
- </div>
16
- <div class="col-10">
17
-
18
- <%= form_for :explorer, url: explorer_path, html: {id: 'explorer_form'}, method: :get, remote: true do |f| %>
13
+ <%= simple_form_for :explorer, url: explorer_path, html: {id: 'explorer_form'}, method: :get, remote: true do |f| %>
19
14
  <%= f.hidden_field :resource, value: @explorer.resource %>
20
15
  <div class="row">
21
16
  <div class="col-6">
22
- <%= f.text_field :uri_pattern, value: @explorer.uri_pattern, placeholder: "URI pattern. 1 or bids or orders/1" %>
17
+ <div class="input-addon">
18
+ <a class="addon"><%= "/#{@explorer.resource}/" %></a>
19
+ <%= f.text_field :uri_pattern, value: @explorer.uri_pattern, placeholder: "URI pattern. 1 or bids or orders/1", class: "addon-field" %>
20
+ </div>
23
21
  </div>
24
22
  <div class="col-2">
25
23
  <%= f.select :http_method, options_for_select(SabisuRails.http_methods, @explorer.http_method.upcase) %>
@@ -32,26 +30,39 @@
32
30
  </div>
33
31
  </div>
34
32
  <br />
35
- <fieldset>
36
- <legend>Url params (<span class="label round" id="url_params_counter_js">0</span>)</legend>
37
- <div class="row" id="url_params_inputs">
38
33
 
39
- </div>
40
- </fieldset>
41
- <fieldset>
42
- <legend>Headers (<span class="label round" id="headers_counter_js">0</span>)</legend>
43
- <div class="row" id="header_inputs">
34
+ <div class="appeareable">
35
+ <% @explorer.resource_columns.each do |column| %>
36
+ <%= f.input column, input_html: {name: "#{@explorer.resource_name}[#{column}]" }, as: @explorer.column_type(column), required: @explorer.required_attribute?(column) %>
37
+ <% end %>
38
+ </div>
44
39
 
45
- </div>
46
- </fieldset>
40
+ <div class="row">
41
+ <div class="col-5">
42
+ <fieldset>
43
+ <legend>Url params (<span class="label round" id="url_params_counter_js">0</span>)</legend>
44
+ <div class="row" id="url_params_inputs">
45
+
46
+ </div>
47
+ </fieldset>
48
+ </div>
49
+ <div class="col-1">
50
+
51
+ </div>
52
+ <div class="col-5">
53
+ <fieldset>
54
+ <legend>Headers (<span class="label round" id="headers_counter_js">0</span>)</legend>
55
+ <div class="row" id="header_inputs">
47
56
 
48
- <%= f.submit "Send", class: 'button large radius three-d success', data: { :disable_with => "Processing..." } %>
57
+ </div>
58
+ </fieldset>
59
+ </div>
60
+ </div>
61
+ <%= f.submit "Send", class: 'button radius three-d success', data: { :disable_with => "Processing..." } %>
49
62
  <% end %>
50
- </div>
51
63
  </div>
52
64
 
53
65
  <div class="response-wrapper">
54
- <hr />
55
66
 
56
67
  <div class="row">
57
68
  <div class="response-details">
@@ -38,6 +38,8 @@ module SabisuRails
38
38
  mattr_accessor :resources
39
39
  @@resources = []
40
40
 
41
+ mattr_reader :resources_names
42
+
41
43
  # Authentication
42
44
  mattr_accessor :authentication_username
43
45
  @@authentication_username = "admin"
@@ -56,6 +58,10 @@ module SabisuRails
56
58
  @@configured
57
59
  end
58
60
 
61
+ def self.resources_names
62
+ @@resources_names ||= @@resources.map { |resource| resource.is_a?(Hash) ? resource.keys[0].to_s : resource.to_s }
63
+ end
64
+
59
65
  #Method to configure sabisu
60
66
  def self.setup
61
67
  @@configured = true
@@ -2,6 +2,7 @@ module SabisuRails
2
2
  class Explorer
3
3
 
4
4
  include SabisuRails::Helpers::Required
5
+ include SabisuRails::Helpers::Type
5
6
 
6
7
  attr_reader :resource, :uri_pattern, :http_method
7
8
 
@@ -21,15 +22,24 @@ module SabisuRails
21
22
  end
22
23
 
23
24
  def resource_columns
24
- resource_class.columns
25
+ resource_custom_columns.reject { |column| SabisuRails.ignored_attributes.include? column }
25
26
  end
26
27
 
27
- def resource_attributes
28
- resource_columns.map(&:name) - SabisuRails.ignored_attributes
29
- end
30
-
31
28
  def method_missing(meth, *args, &block)
32
29
  resource_class.new.send(meth, *args, &block)
33
30
  end
31
+
32
+ private
33
+
34
+ def resource_custom_columns
35
+ columns = nil
36
+ SabisuRails.resources.each do |resource|
37
+ if resource.is_a?(Hash) && resource[@resource.to_sym].present?
38
+ columns = resource[@resource.to_sym].map(&:to_s)
39
+ end
40
+ end
41
+ columns || resource_class.columns.map(&:name)
42
+ end
43
+
34
44
  end
35
45
  end
@@ -1,5 +1,6 @@
1
1
  module SabisuRails
2
2
  module Helpers
3
3
  autoload :Required, 'sabisu_rails/helpers/required'
4
+ autoload :Type, 'sabisu_rails/helpers/type'
4
5
  end
5
6
  end
@@ -0,0 +1,14 @@
1
+ module SabisuRails
2
+ module Helpers
3
+ module Type
4
+
5
+ def column_type(col)
6
+ columns.select { |column| column[0] == col }.flatten[1]
7
+ end
8
+
9
+ def columns
10
+ @columns ||= resource_class.columns.map{|c| [c.name, c.type] }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -5,10 +5,7 @@ module SabisuRails
5
5
  config.eager_load_namespaces << SabisuRails
6
6
 
7
7
  ActiveSupport.on_load :active_record do
8
- if SabisuRails.resources.empty?
9
- SabisuRails.resources = SabisuRails::RouteRecognizer.new.resources
10
- SabisuRails.default_resource = SabisuRails.resources.first.to_s
11
- end
8
+ SabisuRails.default_resource = SabisuRails.resources_names.first
12
9
  SabisuRails.app_name = Rails.application.class.parent_name
13
10
  end
14
11
 
@@ -1,3 +1,3 @@
1
1
  module SabisuRails
2
- VERSION = "0.0.1-beta"
2
+ VERSION = "0.0.2-beta"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sabisu_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.beta
4
+ version: 0.0.2.pre.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abraham Kuri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,6 +130,7 @@ files:
130
130
  - lib/sabisu_rails/explorer.rb
131
131
  - lib/sabisu_rails/helpers.rb
132
132
  - lib/sabisu_rails/helpers/required.rb
133
+ - lib/sabisu_rails/helpers/type.rb
133
134
  - lib/sabisu_rails/railtie.rb
134
135
  - lib/sabisu_rails/request.rb
135
136
  - lib/sabisu_rails/route_recognizer.rb