Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add python path images into rake task #40

Merged
merged 4 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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