mongoid_scribe 0.1.0 → 0.1.1

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: 1589a51bcfcc3ef3e9fb957353e132e0f925450b
4
- data.tar.gz: 01b1cbee0553e66b3828e69afcb0682d0ec5e8b6
3
+ metadata.gz: dec2ffa9d5083184e3cec4fd6ea4d06073cd612c
4
+ data.tar.gz: 33c2e8a614493bb90344479cdde918683c6bfc18
5
5
  SHA512:
6
- metadata.gz: 37b5260974b8330a98a8db17206e8ff2f4d049b2d298037b8967fdfa8014b4b0f948c6ae01b50de7c751c32dce6b25f9a9ea91aaa57286f08ac2ef1c883ce95f
7
- data.tar.gz: 25da9b12f09eb54592c08303577ae19be422a0d39c9cbfa6d5338be12c26f0904928470ff361595de8d9d3108bbd0a07080ba063ce5e34d191a6084fb3c8679c
6
+ metadata.gz: 86a221f1891f8fe319311d210e0e02badb97a5bb3fc12b849ba2381bffe509c4d83ce4a219ae6c9846bda7faa3fc388115d9a382e1fd7aeafeea9aaf7724aab6
7
+ data.tar.gz: c783cc2326a59dc70f23190d4af6e0cb8a58bed9e6c8a72deff856fd68a615e1d2f3ba0f793ceac84610bb3669cb3284967146f1fcff8b245966d7a968bd2ea8
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Mongoid Scribe
2
2
 
3
+ [![Build Status](https://travis-ci.org/nick-desteffen/mongoid-scribe.svg?branch=master)](https://travis-ci.org/nick-desteffen/mongoid-scribe)
4
+ [![Code Climate](https://codeclimate.com/github/nick-desteffen/mongoid-scribe.png)](https://codeclimate.com/github/nick-desteffen/mongoid-scribe)
5
+
3
6
  Mongoid Scribe is a Rails Engine that provides a DSL for setting up simple admin interfaces to edit MongoDB documents. No configuration is required in order to get a basic form, however you can override any form you want to provide a more custom and usable interface.
4
7
 
5
8
  ### Generator
@@ -50,4 +53,4 @@ In your application visit: **/documents**
50
53
  ### Notes
51
54
  In development mode set `preload_models: true`
52
55
 
53
- Styled using [Base](http://matthewhartman.github.io/base/docs/index.html)
56
+ Styled using [Base](http://matthewhartman.github.io/base/docs/index.html)
@@ -3,7 +3,9 @@ module Mongoid
3
3
  class ApplicationController < ::ApplicationController
4
4
  include DocumentsHelper
5
5
 
6
- before_filter Mongoid::Scribe.authentication_filter
6
+ if Mongoid::Scribe.authentication_filter
7
+ before_filter Mongoid::Scribe.authentication_filter
8
+ end
7
9
 
8
10
  end
9
11
  end
@@ -10,7 +10,7 @@ module Mongoid
10
10
  end
11
11
 
12
12
  def index
13
- @documents = @klass.all
13
+ @documents = @klass.all.asc(:created_at)
14
14
  end
15
15
 
16
16
  def edit
@@ -19,9 +19,11 @@ module Mongoid
19
19
 
20
20
  def update
21
21
  @document = @klass.find(params[:id])
22
- @document.update_attributes(document_params)
23
-
24
- redirect_to document_path(params[:type], @document.id)
22
+ if @document.update_attributes(document_params)
23
+ redirect_to document_path(params[:type], @document.id)
24
+ else
25
+ render :edit
26
+ end
25
27
  end
26
28
 
27
29
  def show
@@ -35,6 +37,19 @@ module Mongoid
35
37
  redirect_to documents_path(params[:type])
36
38
  end
37
39
 
40
+ def new
41
+ @document = @klass.new
42
+ end
43
+
44
+ def create
45
+ @document = @klass.new(document_params)
46
+ if @document.save
47
+ redirect_to documents_path(params[:type])
48
+ else
49
+ render :new
50
+ end
51
+ end
52
+
38
53
  private
39
54
 
40
55
  def document_params
@@ -1,12 +1,12 @@
1
1
  <% content_for :navigation do %>
2
- <%= link_to "All Documents", document_listing_path, class: "button orange-button mobile-full" %>
3
- <%= link_to @klass.to_s.pluralize, documents_path(model_param(@klass)), class: "button orange-button mobile-full" %>
4
- <%= link_to @document.id, document_path(model_param(@klass), @document.id), class: "button orange-button mobile-full" %>
2
+ <%= link_to "All Documents", root_path, class: "button orange-button mobile-full" %>
3
+ <%= link_to "All #{@klass.to_s.pluralize}", documents_path(model_param(@klass)), class: "button orange-button mobile-full" %>
4
+ <%= link_to "View #{relation_label(@document)}", document_path(model_param(@klass), @document.id), class: "button orange-button mobile-full" %>
5
5
  <% end %>
6
6
 
7
7
  <div class="section header">
8
8
  <div class="container clear">
9
- <h1 class='logo'>Editing: <%= @document.id %></h1>
9
+ <h1 class='logo'>Editing: <%= relation_label(@document) %></h1>
10
10
  </div>
11
11
  </div>
12
12
 
@@ -19,4 +19,3 @@
19
19
  <%= form.submit("Update #{@klass}", class: "button orange-button mobile-full") %>
20
20
  </fieldset>
21
21
  <% end %>
22
-
@@ -1,5 +1,6 @@
1
1
  <% content_for :navigation do %>
2
- <%= link_to "All Documents", document_listing_path, class: "button orange-button mobile-full" %>
2
+ <%= link_to "All Documents", root_path, class: "button orange-button mobile-full" %>
3
+ <%= link_to "New #{@klass.name}", new_document_path(model_param(@klass)), class: "button orange-button mobile-full" %>
3
4
  <% end %>
4
5
 
5
6
  <div class="section header">
@@ -0,0 +1,20 @@
1
+ <% content_for :navigation do %>
2
+ <%= link_to "All Documents", root_path, class: "button orange-button mobile-full" %>
3
+ <%= link_to "All #{@klass.to_s.pluralize}", documents_path(model_param(@klass)), class: "button orange-button mobile-full" %>
4
+ <% end %>
5
+
6
+ <div class="section header">
7
+ <div class="container clear">
8
+ <h1 class='logo'>New <%= @klass %></h1>
9
+ </div>
10
+ </div>
11
+
12
+ <%= form_for @document, url: create_document_path(model_param(@klass)) do |form| %>
13
+ <fieldset class='row'>
14
+ <% Mongoid::Scribe.fields_for(@klass).each_pair do |name, config| %>
15
+ <%= Mongoid::Scribe::Builders::Field.new(form, @klass, @document, name, config).field %>
16
+ <% end %>
17
+ <%= link_to("Cancel", documents_path(model_param(@klass)), class: "button orange-button mobile-full") %>
18
+ <%= form.submit("Create #{@klass}", class: "button orange-button mobile-full") %>
19
+ </fieldset>
20
+ <% end %>
@@ -1,14 +1,15 @@
1
1
  <% content_for :navigation do %>
2
- <%= link_to "All Documents", document_listing_path, class: "button orange-button mobile-full" %>
3
- <%= link_to @klass.to_s.pluralize, documents_path(model_param(@klass)), class: "button orange-button mobile-full" %>
2
+ <%= link_to "All Documents", root_path, class: "button orange-button mobile-full" %>
3
+ <%= link_to "All #{@klass.to_s.pluralize}", documents_path(model_param(@klass)), class: "button orange-button mobile-full" %>
4
+ <%= link_to "New #{@klass.name}", new_document_path(model_param(@klass)), class: "button orange-button mobile-full" %>
5
+ <%= link_to "Edit #{relation_label(@document)}", edit_document_path(model_param(@klass), @document.id), class: "button orange-button mobile-full" %>
4
6
  <% end %>
5
7
 
6
8
  <div class="section header">
7
9
  <div class="container clear">
8
- <h1 class='logo'>Viewing: <%= @document.id %></h1>
10
+ <h1 class='logo'>Viewing: <%= relation_label(@document) %></h1>
9
11
  </div>
10
12
  </div>
11
- <%= link_to "Edit", edit_document_path(model_param(@klass), @document.id), class: "button orange-button mobile-full" %>
12
13
 
13
14
  <table>
14
15
  <% @klass.fields.each do |attribute, meta| %>
data/config/routes.rb CHANGED
@@ -1,10 +1,15 @@
1
1
  Mongoid::Scribe::Engine.routes.draw do
2
2
 
3
- get "/", to: "documents#all", as: :document_listing
4
- get "/:type/:id/edit", to: "documents#edit", as: :edit_document
5
- get "/:type/:id", to: "documents#show", as: :document
6
- put "/:type/:id/edit", to: "documents#update", as: :update_document
7
- get "/:type", to: "documents#index", as: :documents
8
- delete "/:type/:id", to: "documents#destroy", as: :destroy_document
3
+ scope("/:type/") do
4
+ get "new", to: "documents#new", as: :new_document
5
+ post "new", to: "documents#create", as: :create_document
6
+ get ":id/edit", to: "documents#edit", as: :edit_document
7
+ get ":id", to: "documents#show", as: :document
8
+ put ":id/edit", to: "documents#update", as: :update_document
9
+ get "", to: "documents#index", as: :documents
10
+ delete ":id", to: "documents#destroy", as: :destroy_document
11
+ end
12
+
13
+ root to: "documents#all"
9
14
 
10
15
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Scribe
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -1,3 +1,6 @@
1
+ require "rails"
2
+ require "strong_parameters"
3
+ require "mongoid"
1
4
  require "mongoid/scribe/version"
2
5
  require "mongoid/scribe/engine"
3
6
  require "mongoid/scribe/configuration"
@@ -11,6 +14,9 @@ module Mongoid
11
14
  module Scribe
12
15
  extend ActiveSupport::Autoload
13
16
 
17
+ DEFAULT_ENDPOINT = "/documents"
18
+ DEFAULT_AUTHENTICATION_FILTER = nil
19
+
14
20
  mattr_accessor :form_configuration
15
21
  @@form_configuration = {}
16
22
 
@@ -18,10 +24,10 @@ module Mongoid
18
24
  @@index_configuration = {}
19
25
 
20
26
  mattr_accessor :authentication_filter
21
- @@authentication_filter = nil
27
+ @@authentication_filter = DEFAULT_AUTHENTICATION_FILTER
22
28
 
23
29
  mattr_accessor :endpoint
24
- @@endpoint = "/documents"
30
+ @@endpoint = DEFAULT_ENDPOINT
25
31
 
26
32
  mattr_accessor :models
27
33
  @@models = Mongoid.models
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Mongoid::Scribe::VERSION
9
9
  spec.authors = ["Nick DeSteffen"]
10
10
  spec.email = ["nick.desteffen@gmail.com"]
11
- spec.description = %q{Write a gem description}
12
- spec.summary = %q{Write a gem summary}
11
+ spec.description = %q{Mongoid Scribe}
12
+ spec.summary = %q{Mongoid Scribe is a Rails Engine that provides a DSL for setting up simple admin interfaces to edit MongoDB documents. No configuration is required in order to get a basic form, however you can override any form you want to provide a more custom and usable interface.}
13
13
  spec.homepage = "https://github.com/nick-desteffen/mongoid-scribe"
14
14
  spec.license = "MIT"
15
15
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.files += Dir.glob("vendor/**/*")
20
20
  spec.files += %w(README.md LICENSE.txt mongoid_scribe.gemspec)
21
21
 
22
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.test_files = spec.files.grep(%r{^(spec)/})
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "rails", "~> 3.2.0"
@@ -29,5 +29,9 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.3"
31
31
  spec.add_development_dependency "rake"
32
- spec.add_development_dependency "minitest"
32
+ spec.add_development_dependency "rspec-rails", "~> 2.14.2"
33
+ spec.add_development_dependency "combustion", "~> 0.5.1"
34
+ spec.add_development_dependency "pry", "~> 0.9.12.6"
35
+ spec.add_development_dependency "factory_girl_rails", "~> 4.4.0"
36
+ spec.add_development_dependency "database_cleaner", "~> 1.2.0"
33
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_scribe
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
  - Nick DeSteffen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -95,53 +95,110 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: minitest
98
+ name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 2.14.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
111
- description: Write a gem description
110
+ version: 2.14.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: combustion
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.5.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 0.5.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 0.9.12.6
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 0.9.12.6
139
+ - !ruby/object:Gem::Dependency
140
+ name: factory_girl_rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 4.4.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: 4.4.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: database_cleaner
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 1.2.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 1.2.0
167
+ description: Mongoid Scribe
112
168
  email:
113
169
  - nick.desteffen@gmail.com
114
170
  executables: []
115
171
  extensions: []
116
172
  extra_rdoc_files: []
117
173
  files:
174
+ - LICENSE.txt
175
+ - README.md
176
+ - app/controllers/mongoid/scribe/application_controller.rb
177
+ - app/controllers/mongoid/scribe/documents_controller.rb
178
+ - app/helpers/mongoid/scribe/documents_helper.rb
179
+ - app/views/mongoid/scribe/documents/all.html.erb
180
+ - app/views/mongoid/scribe/documents/edit.html.erb
181
+ - app/views/mongoid/scribe/documents/index.html.erb
182
+ - app/views/mongoid/scribe/documents/new.html.erb
183
+ - app/views/mongoid/scribe/documents/show.html.erb
184
+ - app/views/mongoid/scribe/layouts/application.html.erb
185
+ - config/routes.rb
118
186
  - lib/generators/mongoid_scribe/install_generator.rb
119
187
  - lib/generators/mongoid_scribe/templates/config/initializers/mongoid_scribe.rb
188
+ - lib/mongoid/scribe.rb
120
189
  - lib/mongoid/scribe/builders/field.rb
121
190
  - lib/mongoid/scribe/builders/relation.rb
122
191
  - lib/mongoid/scribe/builders/table.rb
192
+ - lib/mongoid/scribe/configuration.rb
123
193
  - lib/mongoid/scribe/configuration/form_configuration.rb
124
194
  - lib/mongoid/scribe/configuration/index_configuration.rb
125
- - lib/mongoid/scribe/configuration.rb
126
195
  - lib/mongoid/scribe/engine.rb
127
196
  - lib/mongoid/scribe/version.rb
128
- - lib/mongoid/scribe.rb
129
197
  - lib/mongoid_scribe.rb
130
- - app/controllers/mongoid/scribe/application_controller.rb
131
- - app/controllers/mongoid/scribe/documents_controller.rb
132
- - app/helpers/mongoid/scribe/documents_helper.rb
133
- - app/views/mongoid/scribe/documents/all.html.erb
134
- - app/views/mongoid/scribe/documents/edit.html.erb
135
- - app/views/mongoid/scribe/documents/index.html.erb
136
- - app/views/mongoid/scribe/documents/show.html.erb
137
- - app/views/mongoid/scribe/layouts/application.html.erb
138
- - config/routes.rb
198
+ - mongoid_scribe.gemspec
139
199
  - vendor/assets/stylesheets/base/custom.css
140
200
  - vendor/assets/stylesheets/base/doc.css
141
201
  - vendor/assets/stylesheets/base/style.css
142
- - README.md
143
- - LICENSE.txt
144
- - mongoid_scribe.gemspec
145
202
  homepage: https://github.com/nick-desteffen/mongoid-scribe
146
203
  licenses:
147
204
  - MIT
@@ -162,8 +219,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
219
  version: '0'
163
220
  requirements: []
164
221
  rubyforge_project:
165
- rubygems_version: 2.0.14
222
+ rubygems_version: 2.2.2
166
223
  signing_key:
167
224
  specification_version: 4
168
- summary: Write a gem summary
225
+ summary: Mongoid Scribe is a Rails Engine that provides a DSL for setting up simple
226
+ admin interfaces to edit MongoDB documents. No configuration is required in order
227
+ to get a basic form, however you can override any form you want to provide a more
228
+ custom and usable interface.
169
229
  test_files: []