sinatra-admin 0.1.0 → 0.1.1

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: ec4cc4370873a4a162ba234e9751b4efbaa24399
4
- data.tar.gz: fdd0d626c74e68e08e2515358b4aad04eac33290
3
+ metadata.gz: 38b4ab16c9122b2bf6588d73a562b9b0099688d8
4
+ data.tar.gz: 62223b80352211b6c7e948b46b15d0301db04510
5
5
  SHA512:
6
- metadata.gz: a26d7a34c0de58a89125553c82e840d291bdf1887a0b4ccfd8048f9520be31966268e22c10df10adcae4a292cccd5432ea7f01d53a83d3dc7aff90c9dcb2b83c
7
- data.tar.gz: c2586581a6eceab9b8992913d0dcd87d108936b3c3190186ea1cade3c2d36b24d527c01964e2c7b938691653e8f0363429a6eb979e6089c319169475ea7a4106
6
+ metadata.gz: eefd5b42c6f83ec5c06aaa3f796e5122553ad5d33b1eb36865c47281104fcbc5f42da03339d6df6585247f8688ee27d9ec307e84872514189001eda49cff446e
7
+ data.tar.gz: 57ae0111229b64a4ddaee2fd27f6626c81073ade1d7032b007cd128da9891a42d2904748afa0b63e3e743edea665c80f3519a1e2f984efe2dfa4e7f5ebd1b794
data/README.md CHANGED
@@ -24,7 +24,16 @@ Or install it yourself as:
24
24
  By default SinatraAdmin assumes that it's mounted over an "admin"
25
25
  namespace. This is how SinatraAdmin should be configured:
26
26
 
27
- 1. Define your project namespace and your Sinatra applications.
27
+ 1. Set ENV['SINATRA_ADMIN_SECRET']. This secret key is used by
28
+ Rack::Session::Cookie to encrypt your cookies. Warden needs this
29
+ session secret key to keep the user sessions. If you do not set
30
+ this value you're going to see a security warning.
31
+
32
+ ```ruby
33
+ $ export SINATRA_ADMIN_SECRET="my_secret_key"
34
+ ```
35
+
36
+ 2. Define your project namespace and your Sinatra applications.
28
37
  ```ruby
29
38
  module MyApp
30
39
  class API < Sinatra::Base
@@ -37,14 +46,14 @@ namespace. This is how SinatraAdmin should be configured:
37
46
  end
38
47
  ```
39
48
 
40
- 2. Add SinatraAdmin::App middleware to your admin application.
49
+ 3. Add SinatraAdmin::App middleware to your admin application.
41
50
  ```ruby
42
51
  class MyApp::Admin
43
52
  use SinatraAdmin::App
44
53
  end
45
54
  ```
46
55
 
47
- 3. Register model resources(let's assume that we have User and Comment
56
+ 4. Register model resources(let's assume that we have User and Comment
48
57
  models). It creates the 7 REST actions to /create/update/remove
49
58
  records.
50
59
  ```ruby
@@ -54,7 +63,7 @@ namespace. This is how SinatraAdmin should be configured:
54
63
  end
55
64
  ```
56
65
 
57
- 4. Define your root resource(optional). This is going to be the first
66
+ 5. Define your root resource(optional). This is going to be the first
58
67
  page where the application is going to redirect you after the login.
59
68
  SinatraAdmin defines the first registered resource as the default root.
60
69
  In this case it will get 'User'(according to point number 3). If you
@@ -65,7 +74,7 @@ namespace. This is how SinatraAdmin should be configured:
65
74
  end
66
75
  ```
67
76
 
68
- 5. Define your custom resources. Having model resources sometimes is not
77
+ 6. Define your custom resources. Having model resources sometimes is not
69
78
  enough and we might want to see some stats about our application. An
70
79
  example could be: "As an admin I want to see how many user accounts has
71
80
  been registered". Let's take a look at how to define custom resources.
@@ -89,7 +98,7 @@ namespace. This is how SinatraAdmin should be configured:
89
98
  allows us to find the template that we are looking for. This takes us to
90
99
  the next point.
91
100
 
92
- 6. Extend your views path(Only for custom resources). SinatraAdmin has
101
+ 7. Extend your views path(Only for custom resources). SinatraAdmin has
93
102
  the method :extend_views_from. This method receives a value that
94
103
  should either be a String instance with the path to views folder or
95
104
  be a Sinatra application. SinatraAdmin expects to be mounted over an
@@ -102,7 +111,7 @@ namespace. This is how SinatraAdmin should be configured:
102
111
  end
103
112
  ```
104
113
 
105
- 7. Wrapping it up.
114
+ 8. Wrapping it up.
106
115
  ```ruby
107
116
  class MyApp::Admin < Sinatra::Base
108
117
  use SinatraAmin::App
@@ -121,7 +130,7 @@ namespace. This is how SinatraAdmin should be configured:
121
130
  end
122
131
  ```
123
132
 
124
- 8. Run it. We assume you're using a config.ru file to run your Sinatra
133
+ 9. Run it. We assume you're using a config.ru file to run your Sinatra
125
134
  application. This is how it should look like:
126
135
  ```ruby
127
136
  require 'path/to/my_app/api'
@@ -165,7 +174,7 @@ features but also writing documentation, adding issues, refactoring code
165
174
  or just sending us either a <3 if you liked the project or a </3 if you
166
175
  did not like it ;)
167
176
 
168
- * Current version: 0.1.0
177
+ * Current version: 0.1.1
169
178
 
170
179
  ## Contributing
171
180
 
@@ -3,7 +3,7 @@ module SinatraAdmin
3
3
  class Base
4
4
  class << self
5
5
  def add(resource_constant, &block)
6
- route = resource_constant.to_s.downcase.split.join('_').pluralize
6
+ route = resource_constant.to_s.split(/\s|\::/).join('_').underscore.pluralize
7
7
  if SinatraAdmin.config.routes.include?(route)
8
8
  raise RegistrationException, "The resource #{resource_constant.to_s} is already registered"
9
9
  else
@@ -1,3 +1,3 @@
1
1
  module SinatraAdmin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -17,6 +17,11 @@ describe SinatraAdmin::Register::Model do
17
17
  end
18
18
 
19
19
  context 'when resource has not been registered yet' do
20
+ it 'decode namespaced models correctly' do
21
+ described_class.add 'SinatraAdmin::Admin'
22
+ expect(SinatraAdmin.config.routes).to include('sinatra_admin_admins')
23
+ end
24
+
20
25
  it 'adds route to config' do
21
26
  described_class.add 'Tag'
22
27
  expect(SinatraAdmin.config.routes).to include('tags')
@@ -1,5 +1,5 @@
1
1
  describe SinatraAdmin do
2
2
  describe '::VERSION' do
3
- it { expect(described_class::VERSION).to eq('0.1.0') }
3
+ it { expect(described_class::VERSION).to eq('0.1.1') }
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fco. Delgado
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-13 00:00:00.000000000 Z
13
+ date: 2014-08-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler