Class: Appstats::Tasks
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Appstats::Tasks
- Defined in:
- lib/appstats/tasks.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
-
#config ⇒ Object
Returns the value of attribute config.
-
#default_env ⇒ Object
Returns the value of attribute default_env.
-
#env ⇒ Object
Returns the value of attribute env.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#name ⇒ Object
Returns the value of attribute name.
-
#schema ⇒ Object
Returns the value of attribute schema.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :appstats) {|_self| ... } ⇒ Tasks
constructor
A new instance of Tasks.
Constructor Details
#initialize(name = :appstats) {|_self| ... } ⇒ Tasks
Returns a new instance of Tasks.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/appstats/tasks.rb', line 11 def initialize(name = :appstats) @name = name base = File.('.') here = File.(File.dirname(File.dirname(File.dirname((__FILE__))))) @base = base @vendor = "#{here}/vendor" @gem_migrations = "#{here}/db/migrations" @app_migrate = "#{base}/db/migrate" @config = "#{base}/db/config.yml" @schema = "#{base}/db/schema.rb" @appstats_initializer = "#{base}/config/initializers/appstats_config.rb" @appstats_initializer_template = "#{here}/lib/templates/appstats_config.rb" @env = 'DB' @default_env = 'development' @verbose = true yield self if block_given? # Add to load_path every "lib/" directory in vendor Dir["#{vendor}/**/lib"].each{|p| $LOAD_PATH << p } define end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def base @base end |
#config ⇒ Object
Returns the value of attribute config.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def config @config end |
#default_env ⇒ Object
Returns the value of attribute default_env.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def default_env @default_env end |
#env ⇒ Object
Returns the value of attribute env.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def env @env end |
#log_level ⇒ Object
Returns the value of attribute log_level.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def log_level @log_level end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def name @name end |
#schema ⇒ Object
Returns the value of attribute schema.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def schema @schema end |
#vendor ⇒ Object
Returns the value of attribute vendor.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def vendor @vendor end |
#verbose ⇒ Object
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/appstats/tasks.rb', line 9 def verbose @verbose end |
Instance Method Details
#define ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/appstats/tasks.rb', line 32 def define namespace :appstats do namespace :install do desc "Install the migrations for this gem (for the database aspect of the gem)" task :migrations do unless File.exists?(@app_migrate) puts "Creating migrate directory" mkdir @app_migrate end puts "Moving migrations files from:\n> #{@gem_migrations}\nTo\n> #{@app_migrate}" system "cp -R #{@gem_migrations}/* #{@app_migrate}" end desc "Install the logger for this gem (for application instances that log statistics)" task :logger do if File.exists?(@appstats_initializer) puts "Initialize [#{@appstats_initializer}] already exists, creating example file [#{@appstats_initializer}.example] to see any new changes since you last installed this gem" system "cp -R #{@appstats_initializer_template} #{@appstats_initializer}.example" else puts "Creating default initializer [#{@appstats_initializer}]" system "cp -R #{@appstats_initializer_template} #{@appstats_initializer}" end end end end end |