diff --git a/Gemfile b/Gemfile index c004f4ca..91bb17b3 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,5 @@ gem "sinatra-activerecord" gem "sqlite3" gem "pry" gem "require_all" +gem "rake" +gem "activerecord" diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..d074a107 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,56 +1,58 @@ GEM remote: https://rubygems.org/ specs: - activemodel (6.0.3.1) - activesupport (= 6.0.3.1) - activerecord (6.0.3.1) - activemodel (= 6.0.3.1) - activesupport (= 6.0.3.1) - activesupport (6.0.3.1) + activemodel (6.1.1) + activesupport (= 6.1.1) + activerecord (6.1.1) + activemodel (= 6.1.1) + activesupport (= 6.1.1) + activesupport (6.1.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - coderay (1.1.1) - concurrent-ruby (1.1.6) - i18n (1.8.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + coderay (1.1.3) + concurrent-ruby (1.1.8) + i18n (1.8.7) concurrent-ruby (~> 1.0) - method_source (0.8.2) - minitest (5.14.1) - mustermann (1.0.3) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) + method_source (1.0.0) + minitest (5.14.3) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) rack (2.2.3) - rack-protection (2.0.7) + rack-protection (2.1.0) rack - require_all (1.3.3) - sinatra (2.0.7) + rake (13.0.3) + require_all (3.0.0) + ruby2_keywords (0.0.4) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.12) - activerecord (>= 3.2) + sinatra-activerecord (2.0.22) + activerecord (>= 4.1) sinatra (>= 1.0) - slop (3.6.0) - sqlite3 (1.3.13) - thread_safe (0.3.6) + sqlite3 (1.4.2) tilt (2.0.10) - tzinfo (1.2.7) - thread_safe (~> 0.1) - zeitwerk (2.3.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) PLATFORMS - ruby + x86_64-darwin-20 DEPENDENCIES + activerecord pry + rake require_all sinatra-activerecord sqlite3 BUNDLED WITH - 1.14.6 + 2.2.6 diff --git a/bin/run.rb b/bin/run.rb index cf08c338..c725e713 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -2,4 +2,7 @@ +binding.pry puts "HELLO WORLD" + + diff --git a/config/environment.rb b/config/environment.rb index 4dbe13e5..e66361aa 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,3 +3,4 @@ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') require_all 'lib' + diff --git a/lib/Employee.rb b/lib/Employee.rb new file mode 100644 index 00000000..0d0586c5 --- /dev/null +++ b/lib/Employee.rb @@ -0,0 +1,54 @@ +class Employee + #name, id, project_id + attr_accessor :id, :name, :employeer, :project_id + @@all = [] + + def initalize(id = nil, name, employeer) #, project_id = nil) + @id=id + @name = name + # @project_id = project_id + @employeer = employeer + @@all << self + end + + + def self.all + @@all + end + + #basic save method to add new record into database using sql. Note requires .update method + # def save + # if self.id + # self.update + # else + # sql = <<-SQL + # INSERT INTO employee (name, project_id, employeer_id) + # VALUES (?, ?, ?) + # SQL + + # DB[:conn].execute(sql, self.name, self.project_id,employeer_id) + # @id = DB[:conn].execute("SELECT last_insert_rowid() FROM songs")[0][0] + # end + # end + + # #create new instance method + # def self.create(name, employeer, project_id=Nil) + # employee = Employee.new(name, employeer.id) + # employee.save + # employee + # end + + # def self.find_by_id(id) + # sql = "SELECT * FROM employee WHERE id = ?" + # result = DB[:conn].execute(sql, id)[0] + # Employee.new(result[0], result[1], result[2]) + # end + + # def update + # sql = "UPDATE employee SET name = ?, employeer_id = ?, project_id, WHERE id = ?" + # DB[:conn].execute(sql, self.name, self.employeer_id, self.project_id self.id) + # end + + +end + diff --git a/lib/EmployeeSkills.rb b/lib/EmployeeSkills.rb new file mode 100644 index 00000000..24ed8684 --- /dev/null +++ b/lib/EmployeeSkills.rb @@ -0,0 +1,32 @@ +class EmployeeSkills + attr_accessor :id, :employee_id, :skill_id + @@all =[] + +def initalize(id=nil, employee_id, skill_id) + @id = id + @employee_id = employee_id + @skill_id = skill_id + @@all << self +end + +def self.all + @@all +end + + + + + + + + + + + + + + + + + +end \ No newline at end of file diff --git a/lib/Employeer.rb b/lib/Employeer.rb new file mode 100644 index 00000000..9694cdb7 --- /dev/null +++ b/lib/Employeer.rb @@ -0,0 +1,17 @@ +class Employeer + attr_accessor :id, :name + + @@all = [] + + def initalize (id=nil,name) + @id=id + @name = name + @@all << self + end + + + def self.all + @@all + end + +end \ No newline at end of file diff --git a/lib/Project.rb b/lib/Project.rb new file mode 100644 index 00000000..f75f5918 --- /dev/null +++ b/lib/Project.rb @@ -0,0 +1,18 @@ +class Project + #name, id + attr_accessor :id, :project + @@all = [] + + def initalize(id=nil,project) + @id=id + @project = project + @@all << self + end + + + + def self.all + @@all + end + +end diff --git a/lib/ProjectSkills.rb b/lib/ProjectSkills.rb new file mode 100644 index 00000000..c6a6bdab --- /dev/null +++ b/lib/ProjectSkills.rb @@ -0,0 +1,17 @@ +class ProjectSkills + attr_accessor :id, :project_id, :skill_id + + @@all=[] + + def initalize(id=nil,project_id,skill_id) + @id=id + @project_id=project_id + @skill_id=skill_id + @@all<