poodle-rb 0.0.9 → 0.1.0
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 +4 -4
- data/Rakefile +8 -12
- data/app/controllers/poodle/admin_controller.rb +6 -0
- data/app/views/layouts/poodle/application.html.erb +1 -1
- data/app/views/layouts/poodle/public.html.erb +1 -1
- data/config/initializers/poodle_validators.rb +59 -0
- data/config/initializers/state_machines_scopes.rb +23 -0
- data/lib/poodle/action_view/theme_helper.rb +32 -28
- data/lib/poodle/engine.rb +9 -0
- data/lib/poodle/version.rb +1 -1
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/models/profile_picture.rb +8 -0
- data/spec/dummy/app/models/user.rb +5 -0
- data/spec/dummy/app/uploaders/image_uploader.rb +81 -0
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{test → spec}/dummy/bin/bundle +0 -0
- data/{test → spec}/dummy/bin/rails +0 -0
- data/{test → spec}/dummy/bin/rake +0 -0
- data/{test → spec}/dummy/config.ru +0 -0
- data/{test → spec}/dummy/config/application.rb +1 -1
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +0 -0
- data/{test → spec}/dummy/config/environments/test.rb +2 -1
- data/{test → spec}/dummy/config/initializers/assets.rb +0 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +0 -0
- data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/routes.rb +0 -0
- data/{test → spec}/dummy/config/secrets.yml +0 -0
- data/spec/dummy/db/migrate/20131108102728_create_profile_pictures.rb +9 -0
- data/spec/dummy/db/migrate/20140402113213_create_users.rb +10 -0
- data/spec/dummy/db/schema.rb +29 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +8276 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test → spec}/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/uploads/profile_picture/image/1/large_test.jpg +0 -0
- data/spec/dummy/public/uploads/profile_picture/image/1/medium_test.jpg +0 -0
- data/spec/dummy/public/uploads/profile_picture/image/1/test.jpg +0 -0
- data/spec/dummy/public/uploads/profile_picture/image/1/thumb_test.jpg +0 -0
- data/spec/dummy/spec/helpers/theme_helper_spec.rb +160 -0
- data/spec/dummy/spec/support/factories/profile_pictures.rb +6 -0
- data/spec/dummy/spec/support/factories/test.jpg +0 -0
- data/spec/dummy/spec/support/factories/users.rb +13 -0
- data/spec/spec_helper.rb +34 -0
- metadata +262 -74
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/integration/navigation_test.rb +0 -10
- data/test/poodle_test.rb +0 -7
- data/test/test_helper.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 979fff07efaad933578909ad85a7623c2cc7bbc7
|
4
|
+
data.tar.gz: df9b48a604f41d12044669ae7b566eae9b8f8087
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7b1e22bfe5e726174c181ef0a45e9beb992d9965798c46ff8be5d44d667dfd5b01367e7f7f12bb5422614910df66059082e443523d5c6fdd378641acd3419e5
|
7
|
+
data.tar.gz: 0491858e489f85f6e023775b29ba352c868eeb499cf9c3c0a3bd0e19444e5618616c069341295165c140757dbe6321fb68e31beb8650614781d695611e6ec20c
|
data/Rakefile
CHANGED
@@ -5,7 +5,6 @@ rescue LoadError
|
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'rdoc/task'
|
8
|
-
|
9
8
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
9
|
rdoc.rdoc_dir = 'rdoc'
|
11
10
|
rdoc.title = 'Poodle'
|
@@ -14,21 +13,18 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
13
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
14
|
end
|
16
15
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
16
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
17
|
load 'rails/tasks/engine.rake'
|
19
18
|
|
20
|
-
|
21
|
-
|
22
19
|
Bundler::GemHelper.install_tasks
|
23
20
|
|
24
|
-
|
21
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
23
|
+
require 'rspec/core'
|
24
|
+
require 'rspec/core/rake_task'
|
25
|
+
|
26
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
27
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
32
28
|
|
33
29
|
|
34
|
-
task default: :
|
30
|
+
task default: :spec
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<title><%= title -%></title>
|
5
5
|
<%= meta_tags %>
|
6
6
|
<link rel="icon" href="/assets/favicon.ico" type="image/png">
|
7
|
-
<%= stylesheet_link_tag "
|
7
|
+
<%= stylesheet_link_tag "application", :media => "all" -%>
|
8
8
|
<%= csrf_meta_tags -%>
|
9
9
|
<%= yield :javascript_header -%>
|
10
10
|
</head>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<title><%= title -%></title>
|
5
5
|
<%= meta_tags %>
|
6
6
|
<link rel="icon" href="/assets/favicon.ico" type="image/png">
|
7
|
-
<%= stylesheet_link_tag "
|
7
|
+
<%= stylesheet_link_tag "application", :media => "all" -%>
|
8
8
|
<%= csrf_meta_tags -%>
|
9
9
|
<%= yield :javascript_header -%>
|
10
10
|
</head>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module PoodleValidators
|
2
|
+
|
3
|
+
def generate_validation_options(attribute, options)
|
4
|
+
reg_exp = /\A[a-zA-Z1-9\-\ \(\)\.+]*\z/i
|
5
|
+
options.reverse_merge!(
|
6
|
+
presence: true,
|
7
|
+
min_length: 3,
|
8
|
+
max_length: 256,
|
9
|
+
format: reg_exp,
|
10
|
+
uniqueness: false,
|
11
|
+
mandatory: false
|
12
|
+
)
|
13
|
+
|
14
|
+
if options.has_key?(:condition_method) && !options[:condition_method].blank?
|
15
|
+
condition_proc = proc {|obj| obj.send(options[:condition_method])}
|
16
|
+
elsif options.has_key?(:mandatory) && options[:mandatory] == false
|
17
|
+
condition_proc = proc {|obj| !obj.send(attribute).blank?}
|
18
|
+
else
|
19
|
+
condition_proc = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
voptions = {
|
23
|
+
presence: options[:presence],
|
24
|
+
length: { minimum: options[:min_length], maximum: options[:max_length]},
|
25
|
+
format: {:with => options[:format]}
|
26
|
+
}
|
27
|
+
voptions.merge!(uniqueness: options[:uniqueness]) if options[:uniqueness]
|
28
|
+
voptions.merge!(if: condition_proc) if condition_proc
|
29
|
+
|
30
|
+
voptions
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate_string(attribute, **options)
|
34
|
+
voptions = generate_validation_options(attribute, options)
|
35
|
+
validates attribute, **voptions
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate_username(attribute, **options)
|
39
|
+
reg_exp = /\A[a-zA-Z0-9\_]*\z/
|
40
|
+
options.merge!(mandatory: true, max_length: 3, max_length: 128, format: reg_exp, :uniqueness => {:case_sensitive => false})
|
41
|
+
voptions = generate_validation_options(attribute, options)
|
42
|
+
validates attribute, **voptions
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_email(attribute, **options)
|
46
|
+
reg_exp = /\A(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})\z/i
|
47
|
+
options.merge!(mandatory: true, format: reg_exp, :uniqueness => {:case_sensitive => false})
|
48
|
+
voptions = generate_validation_options(attribute, options)
|
49
|
+
validates attribute, **voptions
|
50
|
+
end
|
51
|
+
|
52
|
+
def validate_password(attribute, **options)
|
53
|
+
reg_exp = /\A(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9!@$#&*_\.,;:])/
|
54
|
+
options.merge!(mandatory: true, format: reg_exp, min_length: 7, max_length: 256)
|
55
|
+
voptions = generate_validation_options(attribute, options)
|
56
|
+
validates attribute, **voptions
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module StateMachinesScopes
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
|
6
|
+
# Will generate a bunch of instance methods (scopes) which can be used for filtering by status
|
7
|
+
# == Examples
|
8
|
+
# >>> User.approveds
|
9
|
+
# >>> User.pendings
|
10
|
+
# => ActiveRecord::Relation Object
|
11
|
+
self.state_machines.each do |name, machine|
|
12
|
+
machine.states.map(&:name).each do |my_status|
|
13
|
+
metaclass = class << self; self ; end
|
14
|
+
metaclass.instance_eval do
|
15
|
+
define_method(my_status.to_s.pluralize) do
|
16
|
+
where( status: my_status )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -3,11 +3,12 @@ module Poodle
|
|
3
3
|
# This module creates Bootstrap wrappers around basic View Tags
|
4
4
|
module ThemeHelper
|
5
5
|
# theme_fa_icon('plus')
|
6
|
-
# <i class='fa fa-plus
|
6
|
+
# <i class='fa fa-plus'></i>
|
7
7
|
# theme_fa_icon('plus', 'lg')
|
8
|
-
# <i class='fa fa-plus fa-lg
|
8
|
+
# <i class='fa fa-plus fa-lg'></i>
|
9
9
|
def theme_fa_icon(icon_text, size="")
|
10
|
-
|
10
|
+
size_class = %w{lg 2x 3x 4x 5x}.include?(size.strip) ? " fa-#{size.strip}" : ""
|
11
|
+
"<i class='fa fa-#{icon_text}#{size_class}'></i>"
|
11
12
|
end
|
12
13
|
|
13
14
|
# theme_button_text('New Project')
|
@@ -124,8 +125,9 @@ module Poodle
|
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
|
-
def clear_tag(height)
|
128
|
-
|
128
|
+
def clear_tag(height=nil)
|
129
|
+
height_class = height ? " cl-#{height}" : ""
|
130
|
+
content_tag(:div, "", class: "clearfix#{height_class}")
|
129
131
|
end
|
130
132
|
|
131
133
|
# Example
|
@@ -226,13 +228,6 @@ module Poodle
|
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
229
|
-
#<% if request.xhr? %>
|
230
|
-
# <%= render :partial=>"layouts/poodle/common/flash_message" %>
|
231
|
-
#<% end %>
|
232
|
-
def theme_flash_message
|
233
|
-
render :partial=>"layouts/poodle/common/flash_message" if request.xhr?
|
234
|
-
end
|
235
|
-
|
236
231
|
# Example
|
237
232
|
# theme_more_widget(object, data_columns=[:id, :created_at, :updated_at], super_admin = true)
|
238
233
|
# is equivalent to:
|
@@ -315,37 +310,46 @@ module Poodle
|
|
315
310
|
end
|
316
311
|
|
317
312
|
# Example
|
318
|
-
#
|
313
|
+
# place_holder(width: 60, height: 40, text: "Not Found")
|
319
314
|
# is equivalent to:
|
320
|
-
|
315
|
+
# "http://placehold.it/60x40&text=Not Found"
|
316
|
+
def palceholdit(**options)
|
317
|
+
options.reverse_merge!( width: 60, height: 60, text: "<No Image>" )
|
318
|
+
"http://placehold.it/#{options[:width]}x#{options[:height]}&text=#{options[:text]}"
|
319
|
+
end
|
321
320
|
|
322
|
-
|
321
|
+
# Example
|
322
|
+
# theme_user_image(@user)
|
323
|
+
# is equivalent to:
|
324
|
+
def theme_user_image(user, method_name, **options)
|
325
|
+
|
326
|
+
url_domain = defined?(QAuthRubyClient) ? QAuthRubyClient.configuration.q_auth_url : "http://localhost:9001"
|
323
327
|
|
324
328
|
options.reverse_merge!(
|
325
|
-
role: nil,
|
326
329
|
width: 60,
|
327
330
|
height: options[:width],
|
328
|
-
popover: true,
|
329
|
-
size: "thumb",
|
330
331
|
url_domain: url_domain,
|
331
332
|
place_holder: { width: options[:width], height: options[:height], text: "<No Image>" },
|
332
|
-
html_options: {
|
333
|
-
|
334
|
-
|
335
|
-
|
333
|
+
html_options: { class: "", style: "width:100%;height:auto;cursor:pointer;" }
|
334
|
+
)
|
335
|
+
|
336
|
+
options[:place_holder].reverse_merge!(
|
337
|
+
width: options[:width],
|
338
|
+
height: options[:height],
|
339
|
+
text: "<No Image>"
|
336
340
|
)
|
337
341
|
|
338
342
|
options[:html_options].reverse_merge!(
|
339
343
|
"data-toggle" => "popover",
|
340
344
|
"data-placement" => "bottom",
|
341
|
-
title
|
342
|
-
"data-content" =>
|
345
|
+
"title" => user.name,
|
346
|
+
"data-content" => options[:popover] === true ? "" : options[:popover].to_s
|
343
347
|
) if options[:popover]
|
344
348
|
|
345
|
-
|
346
|
-
url =
|
347
|
-
|
348
|
-
url =
|
349
|
+
begin
|
350
|
+
url = options[:url_domain] + user.send(:eval, method_name)
|
351
|
+
rescue
|
352
|
+
url = palceholdit()
|
349
353
|
end
|
350
354
|
|
351
355
|
content_tag(:div) do
|
data/lib/poodle/engine.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
module Poodle
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
+
|
3
4
|
isolate_namespace Poodle
|
4
5
|
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec, :fixture => false
|
8
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
9
|
+
g.assets false
|
10
|
+
g.helper false
|
11
|
+
end
|
12
|
+
|
5
13
|
initializer "poodle.configure_rails_initialization" do |app|
|
6
14
|
|
7
15
|
ActiveSupport.on_load :action_view do
|
@@ -28,6 +36,7 @@ module Poodle
|
|
28
36
|
helper Poodle::TitleHelper
|
29
37
|
helper Poodle::UrlHelper
|
30
38
|
end
|
39
|
+
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
data/lib/poodle/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
4
|
+
|
5
|
+
# Include RMagick or MiniMagick support:
|
6
|
+
include CarrierWave::RMagick
|
7
|
+
# include CarrierWave::MiniMagick
|
8
|
+
|
9
|
+
# Choose what kind of storage to use for this uploader:
|
10
|
+
#storage Rails.env.production? ? :fog : :file
|
11
|
+
storage :file
|
12
|
+
|
13
|
+
def root
|
14
|
+
Rails.root.join 'public/'
|
15
|
+
end
|
16
|
+
|
17
|
+
# Override the directory where uploaded files will be stored.
|
18
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
19
|
+
def store_dir
|
20
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
21
|
+
end
|
22
|
+
|
23
|
+
version :large do
|
24
|
+
resize_to_limit(540, 540)
|
25
|
+
end
|
26
|
+
|
27
|
+
version :medium do
|
28
|
+
resize_to_fill(232, 232)
|
29
|
+
end
|
30
|
+
|
31
|
+
version :thumb do
|
32
|
+
#process :crop
|
33
|
+
resize_to_fill(116, 116)
|
34
|
+
end
|
35
|
+
|
36
|
+
# def crop
|
37
|
+
# if model.crop_x.present?
|
38
|
+
# resize_to_limit(540, 540)
|
39
|
+
# manipulate! do |img|
|
40
|
+
# x = model.crop_x.to_i
|
41
|
+
# y = model.crop_y.to_i
|
42
|
+
# w = model.crop_w.to_i
|
43
|
+
# h = model.crop_h.to_i
|
44
|
+
# img.crop!(x, y, w, h)
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
|
49
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
50
|
+
# def default_url
|
51
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
52
|
+
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
53
|
+
#
|
54
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
55
|
+
# end
|
56
|
+
|
57
|
+
# Process files as they are uploaded:
|
58
|
+
# process :scale => [200, 300]
|
59
|
+
#
|
60
|
+
# def scale(width, height)
|
61
|
+
# # do something
|
62
|
+
# end
|
63
|
+
|
64
|
+
# Create different versions of your uploaded files:
|
65
|
+
# version :thumb do
|
66
|
+
# process :scale => [50, 50]
|
67
|
+
# end
|
68
|
+
|
69
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
70
|
+
# For images you might use something like this:
|
71
|
+
# def extension_white_list
|
72
|
+
# %w(jpg jpeg gif png)
|
73
|
+
# end
|
74
|
+
|
75
|
+
# Override the filename of the uploaded files:
|
76
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
77
|
+
# def filename
|
78
|
+
# "something.jpg" if original_filename
|
79
|
+
# end
|
80
|
+
|
81
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
16
|
+
config.serve_static_files = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
@@ -36,4 +36,5 @@ Rails.application.configure do
|
|
36
36
|
|
37
37
|
# Raises error for missing translations
|
38
38
|
# config.action_view.raise_on_missing_translations = true
|
39
|
+
config.active_record.raise_in_transactional_callbacks = true
|
39
40
|
end
|