Class: ActsAsTumblrGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



10
11
12
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 10

def self.next_migration_number(path)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create_tag_migrationsObject



14
15
16
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 14

def create_tag_migrations
  generate("acts_as_taggable_on:migration")
end

#generate_migrationObject



18
19
20
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 18

def generate_migration
  migration_template "tumblr_migrations.rb.erb", "db/migrate/#{migration_file_name}"
end

#make_controllersObject



60
61
62
63
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 60

def make_controllers
  copy_file "sessions_controller.rb", "app/controllers/sessions_controller.rb"
  copy_file "application_controller.rb", "app/controllers/application_controller.rb"
end

#make_exportr_fileObject



56
57
58
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 56

def make_exportr_file
  copy_file "exportr.yml", "config/exportr.yml"
end

#make_initializerObject



69
70
71
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 69

def make_initializer
  copy_file "acts_as_tumblr.rb", "config/initializers/acts_as_tumblr.rb"
end

#make_modelsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 22

def make_models
  
  create_file "app/models/#{file_name}.rb",
  <<-FILE
class #{class_name} < ActiveRecord::Base
acts_as_tumblr
end      
  FILE
  
  create_file "app/models/image.rb",
  <<-FILE
class Image < ActiveRecord::Base
acts_as_tumblr_media :for => :#{plural_name.singularize}

has_attached_file :asset, :styles => {
  :thumb => ["50x50#", :jpg], 
  :small => ["150x150#", :jpg], 
  :medium => ["300x210#", :jpg],
  :full => ["700x", :jpg]
},
:processors => [:thumbnail],
:storage => :s3,
:s3_credentials => {
  :access_key_id => ENV['S3_ACCESS_KEY_ID'],
  :secret_access_key => ENV['S3_SECRET_ACCESS_KEY'],
  :bucket => ENV['S3_BUCKET']
},
:path => ":attachment/:id/:style.:content_type_extension",
:default_url => "/assets/missing.png"
end 
  FILE
  
end

#make_tumblr_user_fileObject



65
66
67
# File 'lib/generators/acts_as_tumblr/acts_as_tumblr_generator.rb', line 65

def make_tumblr_user_file
  copy_file "tumblr_user.rb", "app/models/tumblr_user.rb"
end