Skip to content

Commit

Permalink
Merge pull request #40 from /issues/39-Add_python_path_images_into_ra…
Browse files Browse the repository at this point in the history
…ke_task

Add python path images into rake task
  • Loading branch information
loiswells97 authored Mar 29, 2022
2 parents 4d04401 + bb1b8fe commit 6fe6848
Show file tree
Hide file tree
Showing 37 changed files with 59 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,18 @@ COMPONENTS:
location: "main.py"
index: 0
default: true
IMAGES:
- "astronaut1.png"
- "astronaut2.png"
- "earth.png"
- "flowers.png"
- "iss.png"
- "moon.png"
- "planet1.png"
- "planet2.png"
- "rocket1.png"
- "rocket2.png"
- "shark.png"
- "tree.png"
- "treefeller.png"
- "turtle.png"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ COMPONENTS:
location: "main.py"
index: 0
default: true
IMAGES:
- "car.png"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ COMPONENTS:
location: "main.py"
index: 0
default: true
IMAGES:
- "moon.png"
- "rocket.png"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def draw_player():

def setup():
# Setup your animation here
size(400, 400)
text_size(40)
text_align(CENTER, TOP) # position around the centre, top
size(400, 400)


def draw():
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ COMPONENTS:
location: "main.py"
index: 0
default: true
IMAGES:
- "fallenover.png"
- "skiing.png"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ COMPONENTS:
location: "main.py"
index: 0
default: true
IMAGES:
- "moon.png"
- "orange_planet.png"
- "planet.png"
- "purple_planet.png"
- "rocket.png"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ COMPONENTS:
location: "main.py"
index: 0
default: true
IMAGES:
- "moon.png"
- "orange_planet.png"
- "planet.png"
- "purple_planet.png"
- "rocket.png"
27 changes: 23 additions & 4 deletions lib/tasks/projects.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace :projects do
task create_starter: :environment do
Dir.each_child("#{File.dirname(__FILE__)}/project_components") do |dir|
proj_config = YAML.safe_load(File.read("#{File.dirname(__FILE__)}/project_components/#{dir}/project_config.yml"))
Project.find_by(identifier: proj_config['IDENTIFIER'])&.destroy
new_project = Project.new(identifier: proj_config['IDENTIFIER'], name: proj_config['NAME'])
project = find_project(proj_config)
components = proj_config['COMPONENTS']
components.each do |component|
name = component['name']
Expand All @@ -18,9 +17,29 @@ namespace :projects do
default = component['default']
project_component = Component.new(name: name, extension: extension, content: code, index: index,
default: default)
new_project.components << project_component
project.components << project_component
end
new_project.save

project_images = proj_config['IMAGES'] || []
project_images.each do |image_name|
project.images.attach(io: File.open(File.dirname(__FILE__) + "/project_components/#{dir}/#{image_name}"),
filename: image_name)
end

project.save
end
end
end

def find_project(proj_config)
if Project.find_by(identifier: proj_config['IDENTIFIER']).nil?
project = Project.new(identifier: proj_config['IDENTIFIER'], name: proj_config['NAME'])
else
project = Project.find_by(identifier: proj_config['IDENTIFIER'])
project.name = proj_config['NAME']
project.components.each(&:destroy)
project.images.purge
end

project
end

0 comments on commit 6fe6848

Please sign in to comment.