Class: Project
- Inherits:
-
Object
- Object
- Project
- Defined in:
- lib/outrider/project.rb
Constant Summary collapse
- @@log =
Logger.new(STDOUT)
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_project(options) ⇒ Object
A command line tool that lets us build a project /lib/ignite.rb create_project -p project -d domain.com.
- #create_project_db_row(options) ⇒ Object
- #delete_project(options) ⇒ Object
-
#initialize ⇒ Project
constructor
A new instance of Project.
- #project_name(name) ⇒ Object
- #set_config(name) ⇒ Object
-
#test_super(options) ⇒ Object
These methods are here simply to help run our unit tests.
Constructor Details
#initialize ⇒ Project
Returns a new instance of Project.
7 8 9 |
# File 'lib/outrider/project.rb', line 7 def initialize @config = {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/outrider/project.rb', line 3 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/outrider/project.rb', line 3 def logger @logger end |
Class Method Details
.create_db_row(options) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/outrider/project.rb', line 52 def self.create_db_row #create project in database project = Projects.create({ :title => [:project], :domain => [:domain] }) # TODO it might get stuck here if this domain already is in the raw data table entry = ProjectData.create({ :url => [:domain], :status => 'unscraped', :project_id => project.id }) @@log.info "Project created in database: #{project.id}" end |
.create_folder(options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/outrider/project.rb', line 25 def self.create_folder class_name = [:project].classify project_name = [:project].parameterize.underscore file_path = OutriderTools::Store::get_filepath( __FILE__, "../../projects/#{[:project]}/auxiliary.rb" ) #create project files by making a copy of test_project require 'fileutils' #create directories if they dont exist dirname = File.dirname(file_path) unless File.directory?(dirname) FileUtils.mkdir_p(dirname) @@log.info "Making directory: #{dirname}" end #generate our default project class File.open( file_path, 'w') { |file| file.write(%Q{class #{class_name} < Project\n\tdef initialize\n\t\tproject_name :#{project_name}\n\tend\nend}) @@log.info "Auxiliary File Created in: #{file.path}" } end |
.delete(options) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/outrider/project.rb', line 66 def self.delete #delete folder folder_path = OutriderTools::Store::get_filepath( __FILE__, "../../projects/#{[:project]}" ) FileUtils.rm_rf( folder_path ) @@log.info "Deleting: #{folder_path}" #delete from database project = Projects.find_by( title: [:project] ) project.destroy unless project.nil? @@log.info "Deleting: project from database: #{[:project]}" end |
Instance Method Details
#create_project(options) ⇒ Object
A command line tool that lets us build a project /lib/ignite.rb create_project -p project -d domain.com
102 103 104 105 |
# File 'lib/outrider/project.rb', line 102 def create_project Project::create_folder Project::create_db_row end |
#create_project_db_row(options) ⇒ Object
110 111 112 |
# File 'lib/outrider/project.rb', line 110 def create_project_db_row Project::create_db_row end |
#delete_project(options) ⇒ Object
116 117 118 |
# File 'lib/outrider/project.rb', line 116 def delete_project return Project::delete end |
#project_name(name) ⇒ Object
90 91 92 |
# File 'lib/outrider/project.rb', line 90 def project_name name set_config name.to_s end |
#set_config(name) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/outrider/project.rb', line 13 def set_config name = Projects.find_by( title: name ) @config = { :id => .id, :title => .title, :domain => .domain } unless .nil? end |
#test_super(options) ⇒ Object
These methods are here simply to help run our unit tests
85 86 87 88 |
# File 'lib/outrider/project.rb', line 85 def test_super p "Super Test Called" return "Super Test Called" end |