tanraya-playmo 0.0.3 → 0.0.4

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.
@@ -4,5 +4,74 @@ recipe :dragonfly do
4
4
 
5
5
  ask "Would you like to use Dragonfly in this project?" do
6
6
  gem "dragonfly"
7
+
8
+ # Create initializer
9
+ create_file 'config/initializers/dragonfly.rb', <<-CONTENT.gsub(/^ {6}/, '')
10
+ require 'dragonfly/rails/images'
11
+ CONTENT
12
+
13
+ # Create Image model?
14
+ ask "Create polymorphic Image model?" do
15
+ # Create migration
16
+ filename = "db/migrate/#{(Time.now - 3600).strftime("%Y%m%d%H%M%S")}_create_images.rb"
17
+
18
+ create_file filename, <<-CONTENT.gsub(/^ {8}/, '')
19
+ class CreateImages < ActiveRecord::Migration
20
+ def change
21
+ create_table :images do |t|
22
+ t.string :imageable_type, :null => false, :limit => 20
23
+ t.integer :imageable_id, :null => false
24
+ t.string :description, :null => true
25
+ t.string :image_uid, :null => false
26
+
27
+ t.timestamps
28
+ end
29
+
30
+ add_index :images, [:imageable_id, :imageable_type]
31
+ add_index :images, :image_uid
32
+ end
33
+ end
34
+ CONTENT
35
+
36
+ # Create polymorphic Image model
37
+ create_file 'app/models/image.rb', <<-CONTENT.gsub(/^ {8}/, '')
38
+ # Polymorphic Image model that works with Dragonfly gem.
39
+ #
40
+ # = How to associate this model with another?
41
+ #
42
+ # # Example model
43
+ # class UserProfile < ActiveRecord::Base
44
+ # belongs_to :user
45
+ # has_one :image, :as => :imageable, :dependent => :destroy
46
+ #
47
+ # attr_accessible :image_attributes
48
+ #
49
+ # accepts_nested_attributes_for :image,
50
+ # :reject_if => lambda { |x| x[:image].blank? },
51
+ # :allow_destroy => true,
52
+ # :limit => 1 # for has_one association
53
+ # end
54
+ #
55
+ class Image < ActiveRecord::Base
56
+ ALLOWED_MIME_TYPES = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif']
57
+ ALLOWED_EXTENSIONS = [:jpeg, :jpg, :png, :JPEG, :JPG, :PNG]
58
+
59
+ belongs_to :imageable, :polymorphic => true
60
+ image_accessor :image # accessor to image_uid
61
+
62
+ validates :image, :presence => true, :on => :create
63
+ validates :image, :length => { :maximum => 6.megabytes }
64
+
65
+ # Dragonfly custom validators for image
66
+ # see: github.com/markevans/dragonfly
67
+ validates_property :format, :of => :image, :in => ALLOWED_EXTENSIONS
68
+ validates_property :mime_type, :of => :image, :in => ALLOWED_MIME_TYPES
69
+ validates_property :width, :of => :image, :in => (150..3000)
70
+ validates_property :height, :of => :image, :in => (150..3000)
71
+
72
+ default_scope order(:updated_at)
73
+ end
74
+ CONTENT
75
+ end
7
76
  end
8
77
  end
@@ -1,3 +1,3 @@
1
1
  module TanrayaPlaymo
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanraya-playmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-16 00:00:00.000000000Z
12
+ date: 2012-01-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &84036040 !ruby/object:Gem::Requirement
16
+ requirement: &12060760 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *84036040
24
+ version_requirements: *12060760
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: playmo
27
- requirement: &84035690 !ruby/object:Gem::Requirement
27
+ requirement: &12109460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,12 +32,11 @@ dependencies:
32
32
  version: 0.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *84035690
35
+ version_requirements: *12109460
36
36
  description: This just only for my purposes
37
37
  email:
38
38
  - andrew@tanraya.com
39
- executables:
40
- - tanraya-playmo
39
+ executables: []
41
40
  extensions: []
42
41
  extra_rdoc_files: []
43
42
  files:
@@ -46,9 +45,7 @@ files:
46
45
  - Gemfile
47
46
  - README.md
48
47
  - Rakefile
49
- - bin/tanraya-playmo
50
48
  - lib/tanraya-playmo.rb
51
- - lib/tanraya_playmo/cli.rb
52
49
  - lib/tanraya_playmo/recipes/dragonfly_recipe.rb
53
50
  - lib/tanraya_playmo/version.rb
54
51
  - tanraya-playmo.gemspec
data/bin/tanraya-playmo DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $:.unshift File.expand_path("../../lib", __FILE__)
3
-
4
- require 'tanraya-playmo'
5
-
6
- TanrayaPlaymo::Cli.start(ARGV)
@@ -1,14 +0,0 @@
1
- require 'thor/group'
2
-
3
- module TanrayaPlaymo
4
- class Cli < Thor::Group
5
- include Thor::Actions
6
-
7
- argument :application_name, :type => :string, :desc => "The name of the rails application"
8
- desc "Generates a new Rails application with Playmo'"
9
-
10
- def run_tanraya_playmo
11
- ::Playmo::Cli.start(ARGV)
12
- end
13
- end
14
- end