nobrainer 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/no_brainer/autoload.rb +20 -7
- data/lib/no_brainer/config.rb +2 -0
- data/lib/no_brainer/railtie.rb +5 -5
- data/lib/nobrainer.rb +10 -4
- data/lib/rails/generators/nobrainer.rb +18 -0
- data/lib/rails/generators/nobrainer/model/model_generator.rb +17 -0
- data/lib/rails/generators/nobrainer/model/templates/model.rb.tt +13 -0
- metadata +6 -4
- data/lib/no_brainer/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a973d430bb1e593bac8d5d072cea1a815335b9c0
|
4
|
+
data.tar.gz: 002f64fd3e97cb4b987c906a53bb0048b60fe120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5098627bcc261dd22e3c12f2984b98f59a38948ce671881b7656e1ed0dd268b321bc18d89304f1395e38e00976fbd9407b4cb639a79a56ad470011130ce4079
|
7
|
+
data.tar.gz: 78ba3dcc4ae4efd55c0291dee1b88ae8216bcb7e9b0694fb875296392c5b82abebb1da411a6dea0677865930c7a5abd6f1a4b3351c59d0851fc3f1fad370292a
|
data/lib/no_brainer/autoload.rb
CHANGED
@@ -1,14 +1,27 @@
|
|
1
|
+
require 'active_support/dependencies/autoload'
|
2
|
+
|
1
3
|
module NoBrainer::Autoload
|
2
4
|
include ActiveSupport::Autoload
|
3
5
|
|
4
|
-
def
|
5
|
-
|
6
|
+
def self.extended(base)
|
7
|
+
ActiveSupport::Autoload.extended(base)
|
8
|
+
end
|
9
|
+
|
10
|
+
def autoload(*constants)
|
11
|
+
constants.each { |constant| super(constant) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def eager_autoload(*constants)
|
15
|
+
super() { autoload(*constants) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def autoload_and_include(*constants)
|
19
|
+
constants.each { |constant| autoload constant }
|
20
|
+
constants.each { |constant| include const_get constant }
|
6
21
|
end
|
7
22
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
include const_get mod
|
12
|
-
end
|
23
|
+
def eager_autoload_and_include(*constants)
|
24
|
+
eager_autoload(*constants)
|
25
|
+
constants.each { |constant| include const_get constant }
|
13
26
|
end
|
14
27
|
end
|
data/lib/no_brainer/config.rb
CHANGED
data/lib/no_brainer/railtie.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require "rails"
|
1
|
+
require 'nobrainer'
|
3
2
|
|
4
3
|
class NoBrainer::Railtie < Rails::Railtie
|
4
|
+
config.app_generators.orm :nobrainer
|
5
|
+
config.eager_load_namespaces << NoBrainer
|
6
|
+
|
5
7
|
config.action_dispatch.rescue_responses.merge!(
|
6
8
|
"NoBrainer::Errors::DocumentNotFound" => :not_found,
|
7
9
|
"NoBrainer::Errors::DocumentInvalid" => :unprocessable_entity,
|
@@ -16,7 +18,7 @@ class NoBrainer::Railtie < Rails::Railtie
|
|
16
18
|
|
17
19
|
if defined?(ActiveRecord) && NoBrainer::Config.warn_on_active_record
|
18
20
|
STDERR.puts "[NoBrainer] WARNING: ActiveRecord is loaded which is probably not what you want."
|
19
|
-
STDERR.puts "[NoBrainer] Follow the instructions on http://
|
21
|
+
STDERR.puts "[NoBrainer] Follow the instructions on http://nobrainer.io/docs/configuration/#removing_activerecord"
|
20
22
|
STDERR.puts "[NoBrainer] Configure NoBrainer with 'config.warn_on_active_record = false' to disable with warning."
|
21
23
|
end
|
22
24
|
|
@@ -30,6 +32,4 @@ class NoBrainer::Railtie < Rails::Railtie
|
|
30
32
|
NoBrainer::Loader.cleanup
|
31
33
|
end
|
32
34
|
end
|
33
|
-
|
34
|
-
#config.eager_load_namespaces << NoBrainer
|
35
35
|
end
|
data/lib/nobrainer.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
require 'active_support/core_ext'
|
2
|
-
|
3
1
|
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9')
|
4
2
|
raise 'Please use Ruby 1.9 or later'
|
5
3
|
end
|
6
4
|
|
5
|
+
# Load only what we need from ActiveSupport
|
6
|
+
require 'active_support/concern'
|
7
|
+
require 'active_support/lazy_load_hooks'
|
8
|
+
%w(module/delegation module/attribute_accessors class/attribute object/blank
|
9
|
+
object/inclusion object/duplicable hash/keys hash/reverse_merge array/extract_options)
|
10
|
+
.each { |dep| require "active_support/core_ext/#{dep}" }
|
11
|
+
|
7
12
|
module NoBrainer
|
8
13
|
require 'no_brainer/autoload'
|
9
14
|
extend NoBrainer::Autoload
|
10
15
|
|
11
|
-
|
12
|
-
|
16
|
+
# We eager load things that could be loaded for the first time during the web request
|
17
|
+
autoload :Document, :IndexManager, :Loader, :Fork, :DecoratedSymbol
|
18
|
+
eager_autoload :Config, :Connection, :Error, :QueryRunner, :Criteria, :Util
|
13
19
|
|
14
20
|
class << self
|
15
21
|
# Note: we always access the connection explicitly, so that in the future,
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
2
|
+
require 'nobrainer'
|
3
|
+
|
4
|
+
module NoBrainer::Generators
|
5
|
+
class Base < Rails::Generators::NamedBase
|
6
|
+
def self.base_name
|
7
|
+
'nobrainer'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.base_root
|
11
|
+
File.dirname(__FILE__)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.namespace
|
15
|
+
super.gsub(/no_brainer/,'nobrainer')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rails/generators/nobrainer"
|
2
|
+
|
3
|
+
module NoBrainer::Generators
|
4
|
+
class ModelGenerator < Base
|
5
|
+
argument :attributes, :type => :array, default: [], banner: "field ... field"
|
6
|
+
|
7
|
+
check_class_collision
|
8
|
+
|
9
|
+
class_option :parent, :type => :string, :desc => "The parent class for the generated model"
|
10
|
+
|
11
|
+
def create_model_file
|
12
|
+
template "model.rb.tt", File.join("app/models", class_path, "#{file_name}.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
hook_for :test_framework
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %><%= " < #{options[:parent].classify}" if options[:parent] %>
|
3
|
+
<% unless options[:parent] -%>
|
4
|
+
include NoBrainer::Document
|
5
|
+
<% end -%>
|
6
|
+
<% attributes.reject(&:reference?).each do |attribute| -%>
|
7
|
+
field :<%= attribute.name %>
|
8
|
+
<% end -%>
|
9
|
+
<% attributes.select(&:reference?).each do |attribute| -%>
|
10
|
+
belongs_to :<%= attribute.name %>
|
11
|
+
<% end -%>
|
12
|
+
end
|
13
|
+
<% end -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nobrainer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Viennot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rethinkdb
|
@@ -121,10 +121,12 @@ files:
|
|
121
121
|
- lib/no_brainer/query_runner.rb
|
122
122
|
- lib/no_brainer/error.rb
|
123
123
|
- lib/no_brainer/document.rb
|
124
|
-
- lib/no_brainer/config.rb
|
125
124
|
- lib/no_brainer/railtie.rb
|
126
125
|
- lib/no_brainer/autoload.rb
|
127
|
-
- lib/no_brainer/
|
126
|
+
- lib/no_brainer/config.rb
|
127
|
+
- lib/rails/generators/nobrainer.rb
|
128
|
+
- lib/rails/generators/nobrainer/model/model_generator.rb
|
129
|
+
- lib/rails/generators/nobrainer/model/templates/model.rb.tt
|
128
130
|
- lib/nobrainer.rb
|
129
131
|
- README.md
|
130
132
|
- LICENSE.md
|
data/lib/no_brainer/version.rb
DELETED