assets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Jack Dempsey
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,24 @@
1
+ Name: Assets
2
+
3
+ Description: Assets is a simple gem that contains an ActiveRecord model, Asset, which relies on paperclip for attachment management
4
+
5
+ Getting Started
6
+
7
+ Usage:
8
+
9
+ Installation:
10
+
11
+
12
+ Getting Involved
13
+
14
+ Contributing:
15
+
16
+ Creators
17
+
18
+ Authors: Jack Dempsey
19
+ Contributors:
20
+
21
+ Legal
22
+
23
+ Copyright: 2010 Jack Dempsey
24
+ License: See LICENSE for details
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "assets"
8
+ gem.summary = %Q{small layer that sits on top of paperclip and provides some conveniences}
9
+ gem.description = %Q{Assets is a simple gem that provides an ActiveRecord model that handles attachments via paperclip,
10
+ and provides additional helpful and often common functionality}
11
+ gem.email = "jack.dempsey@gmail.com"
12
+ gem.homepage = "http://github.com/jackdempsey/assets"
13
+ gem.authors = ["Jack Dempsey"]
14
+ gem.add_dependency "paperclip", "~> 2.3.3"
15
+ gem.add_dependency "activerecord", "~> 3.0.0"
16
+ gem.add_development_dependency "rspec", "~> 2.0.0.beta.22"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'spec/rake/spectask'
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ end
29
+
30
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
31
+ spec.libs << 'lib' << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.rcov = true
34
+ end
35
+
36
+ task :spec => :check_dependencies
37
+
38
+ task :default => :spec
39
+
40
+ require 'rake/rdoctask'
41
+ Rake::RDocTask.new do |rdoc|
42
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "assets #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,66 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{assets}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jack Dempsey"]
12
+ s.date = %q{2010-09-30}
13
+ s.description = %q{Assets is a simple gem that provides an ActiveRecord model that handles attachments via paperclip,
14
+ and provides additional helpful and often common functionality}
15
+ s.email = %q{jack.dempsey@gmail.com}
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "assets.gemspec",
28
+ "lib/assets.rb",
29
+ "lib/generators/assets/USAGE",
30
+ "lib/generators/assets/model_generator.rb",
31
+ "lib/generators/assets/templates/migration.rb",
32
+ "spec/assets_spec.rb",
33
+ "spec/spec.opts",
34
+ "spec/spec_helper.rb",
35
+ "writeme.yml"
36
+ ]
37
+ s.homepage = %q{http://github.com/jackdempsey/assets}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.7}
41
+ s.summary = %q{small layer that sits on top of paperclip and provides some conveniences}
42
+ s.test_files = [
43
+ "spec/assets_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<paperclip>, ["~> 2.3.3"])
53
+ s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.0"])
54
+ s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
55
+ else
56
+ s.add_dependency(%q<paperclip>, ["~> 2.3.3"])
57
+ s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
58
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<paperclip>, ["~> 2.3.3"])
62
+ s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
63
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
64
+ end
65
+ end
66
+
File without changes
@@ -0,0 +1,7 @@
1
+ Assets Generator
2
+
3
+ The assets generator invokes the active_record:model generator, whose Usage banner you will see above.
4
+
5
+ Use this generator in a similar fashion, passing in values we will send on to active_record:model
6
+
7
+ rails generate assets:model NAME [field:type field:type]
@@ -0,0 +1,52 @@
1
+ require 'rails/generators/active_record'
2
+ # generator borrows some nice methods and logic from devise
3
+ # http://github.com/plataformatec/devise
4
+
5
+ module Assets
6
+ module Generators
7
+ class ModelGenerator < ActiveRecord::Generators::Base
8
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
9
+
10
+ source_root File.expand_path("../templates", __FILE__)
11
+
12
+ def generate_model
13
+ invoke "active_record:model", [name], :migration => false unless model_exists?
14
+ end
15
+
16
+ def copy_migration
17
+ migration_template "migration.rb", "db/migrate/create_#{table_name}"
18
+ end
19
+
20
+ def inject_content
21
+ inject_into_class model_path, class_name, %q{
22
+ # Setup accessible (or protected) attributes for your model
23
+ attr_accessible :name, :description, :owner_type, :owner_id
24
+
25
+ belongs_to :owner, :polymorphic => true
26
+
27
+ validates_presence_of :owner
28
+
29
+ has_attached_file :attachment
30
+
31
+ %w(image doc pdf xls).each do |file_type|
32
+ define_method "is_#{file_type}?" do
33
+ attachment_content_type.present? && attachment_content_type.include?("#{file_type}")
34
+ end
35
+ end
36
+
37
+ }
38
+ end
39
+
40
+ private
41
+
42
+ def model_exists?
43
+ File.exists?(File.join(destination_root, model_path))
44
+ end
45
+
46
+ def model_path
47
+ @model_path ||= File.join("app", "models", "#{file_path}.rb")
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,25 @@
1
+ class Create<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table(:<%= table_name %>) do |t|
4
+
5
+ <% for attribute in attributes -%>
6
+ t.<%= attribute.type %> :<%= attribute.name %>
7
+ <% end -%>
8
+
9
+ # setup polymorphic owner fields
10
+ t.string :owner_type
11
+ t.integer :owner_id
12
+
13
+ # setup fields for paperclip
14
+ t.string :attachment_file_name, :attachment_content_type
15
+ t.integer :attachment_file_size
16
+ t.datetime :attachment_updated_at
17
+
18
+ t.timestamps
19
+ end
20
+ end
21
+
22
+ def self.down
23
+ drop_table :<%= table_name %>
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Assets" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'assets'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,25 @@
1
+ ---
2
+ :name: "Assets"
3
+ :description: "Assets is a simple gem that contains an ActiveRecord model, Asset, which relies on paperclip for attachment management"
4
+
5
+ :getting_started:
6
+ :usage:
7
+ :installation:
8
+ :requirements:
9
+ :steps:
10
+
11
+ :getting_involved:
12
+ :contributing:
13
+ - "Fork the project."
14
+ - "Make your feature addition or bug fix on a topic branch."
15
+ - "Add tests for it if applicable (docs may not need it, code might)"
16
+ - "Commit, do not mess with rakefile, version, or history."
17
+ - "Send me a pull request. Bonus points for topic branches."
18
+
19
+ :creators:
20
+ :authors: "Jack Dempsey"
21
+ :contributors:
22
+
23
+ :legal:
24
+ :copyright: "2010 Jack Dempsey"
25
+ :license: "See LICENSE for details"
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assets
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Jack Dempsey
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-30 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: paperclip
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 3
31
+ - 3
32
+ version: 2.3.3
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: activerecord
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 3
45
+ - 0
46
+ - 0
47
+ version: 3.0.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 2
60
+ - 0
61
+ - 0
62
+ - beta
63
+ - 22
64
+ version: 2.0.0.beta.22
65
+ type: :development
66
+ version_requirements: *id003
67
+ description: |-
68
+ Assets is a simple gem that provides an ActiveRecord model that handles attachments via paperclip,
69
+ and provides additional helpful and often common functionality
70
+ email: jack.dempsey@gmail.com
71
+ executables: []
72
+
73
+ extensions: []
74
+
75
+ extra_rdoc_files:
76
+ - LICENSE
77
+ - README
78
+ files:
79
+ - .document
80
+ - .gitignore
81
+ - LICENSE
82
+ - README
83
+ - Rakefile
84
+ - VERSION
85
+ - assets.gemspec
86
+ - lib/assets.rb
87
+ - lib/generators/assets/USAGE
88
+ - lib/generators/assets/model_generator.rb
89
+ - lib/generators/assets/templates/migration.rb
90
+ - spec/assets_spec.rb
91
+ - spec/spec.opts
92
+ - spec/spec_helper.rb
93
+ - writeme.yml
94
+ has_rdoc: true
95
+ homepage: http://github.com/jackdempsey/assets
96
+ licenses: []
97
+
98
+ post_install_message:
99
+ rdoc_options:
100
+ - --charset=UTF-8
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ requirements: []
120
+
121
+ rubyforge_project:
122
+ rubygems_version: 1.3.7
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: small layer that sits on top of paperclip and provides some conveniences
126
+ test_files:
127
+ - spec/assets_spec.rb
128
+ - spec/spec_helper.rb