Module: Gamefic::Sdk::Tasks

Defined in:
lib/gamefic-sdk/tasks.rb,
lib/gamefic-sdk/tasks/web.rb,
lib/gamefic-sdk/tasks/ruby.rb,
lib/gamefic-sdk/tasks/common.rb

Defined Under Namespace

Modules: Common Classes: Ruby, Web

Class Method Summary collapse

Class Method Details

.define_all_tasksObject



15
16
17
18
# File 'lib/gamefic-sdk/tasks.rb', line 15

def define_all_tasks
  define_build_tasks
  define_spec_tasks
end

.define_build_tasksObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gamefic-sdk/tasks.rb', line 20

def define_build_tasks
  define_task 'ruby:run', 'Run a Ruby CLI app' do
    Ruby.new.run
  end

  define_task 'ruby:build', 'Build a distributable CLI app' do
    Ruby.new.build
  end

  Rake::Task.define_task('web:generate', [:version]) { |_, args| Web.new.generate(args[:version]) }
            .tap { |task| task.add_description 'Generate a web app' }

  define_task 'web:run', 'Run a standalone web app' do
    Web.new.run
  end

  define_task 'web:build', 'Build a distributable web app' do
    Web.new.build
  end

  define_task 'web:autoload', 'Generate autoload.rb for Opal' do
    Web.new.autoload
  end
end

.define_spec_tasksObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/gamefic-sdk/tasks.rb', line 45

def define_spec_tasks
  RSpec::Core::RakeTask.new(:spec)

  Opal::RSpec::RakeTask.new(:opal) do |_, config|
    Bundler.definition
           .dependencies_for([:default])
           .each { |dep| Opal.use_gem dep.name }
    Opal.append_path '.'
    Opal.append_path File.join('.', 'lib')
    config.pattern = 'spec/**/*_spec.rb'
    config.requires = ['spec/opal_helper']
  end.rake_task.prerequisites.push 'web:autoload'
end

.define_task(name, desc, &block) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/gamefic-sdk/tasks.rb', line 59

def define_task(name, desc, &block)
  return if Rake::Task.task_defined?(name)

  # @type [Rake::Task]
  task = Rake::Task.define_task(name, &block)
  task.add_description desc
end