paperclip_montage 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +4 -0
  3. data/.travis.yml +55 -0
  4. data/Gemfile +38 -0
  5. data/Guardfile +14 -0
  6. data/LICENSE +674 -0
  7. data/README.md +67 -0
  8. data/Rakefile +50 -0
  9. data/config/Guardfile +14 -0
  10. data/lib/generators/paperclip_montage/USAGE +8 -0
  11. data/lib/generators/paperclip_montage/paperclip_montage_generator.rb +3 -0
  12. data/lib/paperclip/montage.rb +94 -0
  13. data/lib/paperclip/myversion.rb +11 -0
  14. data/lib/paperclip_montage.rb +5 -0
  15. data/paperclip_montage.gemspec +154 -0
  16. data/spec/fixtures/valid.jpg +0 -0
  17. data/spec/fixtures/valid1.png +0 -0
  18. data/spec/fixtures/valid2.png +0 -0
  19. data/spec/fixtures/valid3.png +0 -0
  20. data/spec/fixtures/valid4.png +0 -0
  21. data/spec/paperclip/montage_spec.rb +56 -0
  22. data/spec/rails-app/.gitignore +17 -0
  23. data/spec/rails-app/.rspec +2 -0
  24. data/spec/rails-app/Gemfile +32 -0
  25. data/spec/rails-app/Guardfile +76 -0
  26. data/spec/rails-app/README.rdoc +28 -0
  27. data/spec/rails-app/Rakefile +6 -0
  28. data/spec/rails-app/app/assets/images/.keep +0 -0
  29. data/spec/rails-app/app/assets/javascripts/application.js +16 -0
  30. data/spec/rails-app/app/assets/stylesheets/application.css +15 -0
  31. data/spec/rails-app/app/controllers/application_controller.rb +5 -0
  32. data/spec/rails-app/app/controllers/concerns/.keep +0 -0
  33. data/spec/rails-app/app/helpers/application_helper.rb +2 -0
  34. data/spec/rails-app/app/models/.keep +0 -0
  35. data/spec/rails-app/app/models/avatar.rb +5 -0
  36. data/spec/rails-app/app/models/avatars_meta.rb +4 -0
  37. data/spec/rails-app/app/models/concerns/.keep +0 -0
  38. data/spec/rails-app/app/models/meta.rb +16 -0
  39. data/spec/rails-app/app/views/layouts/application.html.erb +14 -0
  40. data/spec/rails-app/bin/bundle +3 -0
  41. data/spec/rails-app/bin/rails +8 -0
  42. data/spec/rails-app/bin/rake +8 -0
  43. data/spec/rails-app/bin/spring +18 -0
  44. data/spec/rails-app/config.ru +4 -0
  45. data/spec/rails-app/config/Guardfile +76 -0
  46. data/spec/rails-app/config/application.rb +23 -0
  47. data/spec/rails-app/config/boot.rb +4 -0
  48. data/spec/rails-app/config/database.yml +25 -0
  49. data/spec/rails-app/config/environment.rb +5 -0
  50. data/spec/rails-app/config/environments/development.rb +37 -0
  51. data/spec/rails-app/config/environments/production.rb +78 -0
  52. data/spec/rails-app/config/environments/test.rb +39 -0
  53. data/spec/rails-app/config/initializers/assets.rb +8 -0
  54. data/spec/rails-app/config/initializers/backtrace_silencers.rb +7 -0
  55. data/spec/rails-app/config/initializers/cookies_serializer.rb +3 -0
  56. data/spec/rails-app/config/initializers/filter_parameter_logging.rb +4 -0
  57. data/spec/rails-app/config/initializers/inflections.rb +16 -0
  58. data/spec/rails-app/config/initializers/mime_types.rb +4 -0
  59. data/spec/rails-app/config/initializers/session_store.rb +3 -0
  60. data/spec/rails-app/config/initializers/wrap_parameters.rb +14 -0
  61. data/spec/rails-app/config/locales/en.yml +23 -0
  62. data/spec/rails-app/config/routes.rb +56 -0
  63. data/spec/rails-app/config/secrets.yml +22 -0
  64. data/spec/rails-app/db/migrate/20141212000615_create_avatars.rb +9 -0
  65. data/spec/rails-app/db/migrate/20141212000731_create_meta.rb +9 -0
  66. data/spec/rails-app/db/migrate/20141214193102_create_avatars_meta.rb +10 -0
  67. data/spec/rails-app/db/schema.rb +44 -0
  68. data/spec/rails-app/db/seeds.rb +7 -0
  69. data/spec/rails-app/public/404.html +67 -0
  70. data/spec/rails-app/public/422.html +67 -0
  71. data/spec/rails-app/public/500.html +66 -0
  72. data/spec/rails-app/public/favicon.ico +0 -0
  73. data/spec/rails-app/public/robots.txt +5 -0
  74. data/spec/rails-app/spec/models/avatar_spec.rb +9 -0
  75. data/spec/rails-app/spec/models/avatars_meta_spec.rb +5 -0
  76. data/spec/rails-app/spec/models/meta_spec.rb +48 -0
  77. data/spec/rails-app/spec/rails_helper.rb +50 -0
  78. data/spec/rails-app/spec/spec_helper.rb +12 -0
  79. data/spec/spec_helper.rb +112 -0
  80. metadata +306 -0
@@ -0,0 +1,17 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
17
+ Gemfile.lock
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,32 @@
1
+ source 'https://rubygems.org'
2
+ #ruby '2.0.0'
3
+
4
+ if RUBY_VERSION =~ /1.9/
5
+ Encoding.default_external = Encoding::UTF_8
6
+ Encoding.default_internal = Encoding::UTF_8
7
+ end
8
+
9
+ rails_version = ENV["RAILS_VERSION"] || "default"
10
+
11
+ rails = case rails_version
12
+ when "master"
13
+ {github: "rails/rails"}
14
+ when "default"
15
+ ">= 3.1.0"
16
+ else
17
+ "~> #{rails_version}"
18
+ end
19
+
20
+ gem 'paperclip_montage', path: '../../'
21
+ gem 'paperclip', '~> 4.1.0'
22
+
23
+ group :development, :test do
24
+ gem 'guard-rspec', '>= 0'
25
+ gem 'guard-yard', '>= 0'
26
+ gem 'rails', rails
27
+ gem 'sqlite3'
28
+ gem 'rspec'
29
+ gem 'rspec-rails'
30
+ gem 'coveralls', require: false
31
+ gem 'pry-byebug'
32
+ end
@@ -0,0 +1,76 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %(app lib config test spec feature)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ # Note: The cmd option is now required due to the increasing number of ways
11
+ # rspec may be run, below are examples of the most common uses.
12
+ # * bundler: 'bundle exec rspec'
13
+ # * bundler binstubs: 'bin/rspec'
14
+ # * spring: 'bin/rspec' (This will use spring if running and you have
15
+ # installed the spring binstubs per the docs)
16
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
17
+ # * 'just' rspec: 'rspec'
18
+
19
+ guard :rspec, cmd: "bundle exec rspec" do
20
+ require "ostruct"
21
+
22
+ # Generic Ruby apps
23
+ rspec = OpenStruct.new
24
+ rspec.spec = ->(m) { "spec/#{m}_spec.rb" }
25
+ rspec.spec_dir = "spec"
26
+ rspec.spec_helper = "spec/spec_helper.rb"
27
+
28
+ watch(%r{^spec/.+_spec\.rb$})
29
+ watch(%r{^lib/(.+)\.rb$}) { |m| rspec.spec.("lib/#{m[1]}") }
30
+ watch(%r{^../../lib/(.+)\.rb$}) { UI.info 'reached' }
31
+ watch(rspec.spec_helper) { rspec.spec_dir }
32
+ watch(%r{../../lib/paperclip/(.*).rb})
33
+
34
+ # Rails example
35
+ rails = OpenStruct.new
36
+ rails.app = %r{^app/(.+)\.rb$}
37
+ rails.views_n_layouts = %r{^app/(.*)(\.erb|\.haml|\.slim)$}
38
+ rails.controllers = %r{^app/controllers/(.+)_controller\.rb$}
39
+ rails.routes = "config/routes.rb"
40
+ rails.app_controller = "app/controllers/application_controller.rb"
41
+ rails.spec_helper = "spec/rails_helper.rb"
42
+ rails.spec_support = %r{^spec/support/(.+)\.rb$}
43
+ rails.views = %r{^app/views/(.+)/.*\.(erb|haml|slim)$}
44
+ watch ("config/Guardfile") { UI.info "Exiting guard because config changed"; exit 0 }
45
+
46
+ watch(rails.app) { |m| rspec.spec.(m[1]) }
47
+ watch(rails.views_n_layouts) { |m| rspec.spec.("#{m[1]}#{m[2]}") }
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ watch(rails.spec_support) { rspec.spec_dir }
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "spec/routing" }
59
+ watch(rails.app_controller) { "spec/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.views) { |m| rspec.spec.("features/#{m[1]}") }
63
+
64
+ # Turnip features and steps
65
+ watch(%r{^spec/acceptance/(.+)\.feature$})
66
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
67
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
68
+ end
69
+
70
+ end
71
+
72
+ guard 'yard' do
73
+ watch(%r{app/.+\.rb})
74
+ watch(%r{lib/.+\.rb})
75
+ watch(%r{ext/.+\.c})
76
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ class Avatar < ActiveRecord::Base
2
+ has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
3
+
4
+ validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
5
+ end
@@ -0,0 +1,4 @@
1
+ class AvatarsMeta < ActiveRecord::Base
2
+ belongs_to :meta
3
+ belongs_to :avatar
4
+ end
File without changes
@@ -0,0 +1,16 @@
1
+ class Meta < ActiveRecord::Base
2
+ #after_update :reprocess_montage
3
+
4
+ has_and_belongs_to_many :avatars
5
+
6
+ has_attached_file :montage,
7
+ processors: [:montage],
8
+ :styles => { medium: { geometry: "300x300>", source: :avatars} , thumb: { geometry: "100x100>" } }
9
+
10
+ validates_attachment :montage, :attachment_presence => true,
11
+ :content_type => { :content_type => "image/jpeg" }
12
+
13
+ def reprocess_montage
14
+ montage.reprocess!
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
7
+ require_relative '../config/boot'
8
+ require 'rails/commands'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ require_relative '../config/boot'
7
+ require 'rake'
8
+ Rake.application.run
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast
4
+ # It gets overwritten when you run the `spring binstub` command
5
+
6
+ unless defined?(Spring)
7
+ require "rubygems"
8
+ require "bundler"
9
+
10
+ if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
11
+ ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12
+ ENV["GEM_HOME"] = ""
13
+ Gem.paths = ENV
14
+
15
+ gem "spring", match[1]
16
+ require "spring/binstub"
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,76 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %(app lib config test spec feature)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ # Note: The cmd option is now required due to the increasing number of ways
11
+ # rspec may be run, below are examples of the most common uses.
12
+ # * bundler: 'bundle exec rspec'
13
+ # * bundler binstubs: 'bin/rspec'
14
+ # * spring: 'bin/rspec' (This will use spring if running and you have
15
+ # installed the spring binstubs per the docs)
16
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
17
+ # * 'just' rspec: 'rspec'
18
+
19
+ guard :rspec, cmd: "bundle exec rspec" do
20
+ require "ostruct"
21
+
22
+ # Generic Ruby apps
23
+ rspec = OpenStruct.new
24
+ rspec.spec = ->(m) { "spec/#{m}_spec.rb" }
25
+ rspec.spec_dir = "spec"
26
+ rspec.spec_helper = "spec/spec_helper.rb"
27
+
28
+ watch(%r{^spec/.+_spec\.rb$})
29
+ watch(%r{^lib/(.+)\.rb$}) { |m| rspec.spec.("lib/#{m[1]}") }
30
+ watch(%r{^../../lib/(.+)\.rb$}) { UI.info 'reached' }
31
+ watch(rspec.spec_helper) { rspec.spec_dir }
32
+ watch(%r{../../lib/paperclip/(.*).rb})
33
+
34
+ # Rails example
35
+ rails = OpenStruct.new
36
+ rails.app = %r{^app/(.+)\.rb$}
37
+ rails.views_n_layouts = %r{^app/(.*)(\.erb|\.haml|\.slim)$}
38
+ rails.controllers = %r{^app/controllers/(.+)_controller\.rb$}
39
+ rails.routes = "config/routes.rb"
40
+ rails.app_controller = "app/controllers/application_controller.rb"
41
+ rails.spec_helper = "spec/rails_helper.rb"
42
+ rails.spec_support = %r{^spec/support/(.+)\.rb$}
43
+ rails.views = %r{^app/views/(.+)/.*\.(erb|haml|slim)$}
44
+ watch ("config/Guardfile") { UI.info "Exiting guard because config changed"; exit 0 }
45
+
46
+ watch(rails.app) { |m| rspec.spec.(m[1]) }
47
+ watch(rails.views_n_layouts) { |m| rspec.spec.("#{m[1]}#{m[2]}") }
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ watch(rails.spec_support) { rspec.spec_dir }
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "spec/routing" }
59
+ watch(rails.app_controller) { "spec/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.views) { |m| rspec.spec.("features/#{m[1]}") }
63
+
64
+ # Turnip features and steps
65
+ watch(%r{^spec/acceptance/(.+)\.feature$})
66
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
67
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
68
+ end
69
+
70
+ end
71
+
72
+ guard 'yard' do
73
+ watch(%r{app/.+\.rb})
74
+ watch(%r{lib/.+\.rb})
75
+ watch(%r{ext/.+\.c})
76
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module RailsApp
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
+ # config.time_zone = 'Central Time (US & Canada)'
18
+
19
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
+ # config.i18n.default_locale = :de
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3