Module: Canvas::Workflow

Defined in:
lib/canvas-workflow.rb,
lib/canvas/workflow.rb,
lib/canvas/workflow/cli.rb,
lib/canvas/workflow/tags.rb,
lib/canvas/workflow/client.rb,
lib/canvas/workflow/travis.rb,
lib/canvas/workflow/version.rb,
lib/canvas/workflow/cli/push.rb,
lib/canvas/workflow/cli/build.rb,
lib/canvas/workflow/cli/error.rb,
lib/canvas/workflow/tags/file.rb,
lib/canvas/workflow/tags/gist.rb,
lib/canvas/workflow/tags/icon.rb,
lib/canvas/workflow/cli/deploy.rb,
lib/canvas/workflow/tags/assignment.rb

Defined Under Namespace

Modules: CLI, Tags, Travis Classes: Client

Constant Summary collapse

VERSION =
"0.8.0".freeze

Class Method Summary collapse

Class Method Details

.clientCanvas::Client

Access the Canvas client for this Canvas Workflow site.

Returns:

  • (Canvas::Client)

    the Canvas client for this Canvas Workflow site



26
27
28
# File 'lib/canvas/workflow.rb', line 26

def self.client
  @client ||= Client.new(config)
end

.configObject

Access the configuration object for this Canvas Workflow site.

Returns:

  • the configuration object for this Canvas Workflow site



18
19
20
21
# File 'lib/canvas/workflow.rb', line 18

def self.config
  # load user configuration
  @config ||= YAML.load_file('_config.yml')['canvas']
end

.excluded?(file) ⇒ Boolean

Is file excluded from upload?

Parameters:

  • file (String)

    a file name

Returns:

  • (Boolean)

    true if the file has been excluded from upload.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/canvas/workflow.rb', line 34

def self.excluded?(file)
  return false if config['exclude'].nil?

  # get the list of files that has been explicitly excluded
  @excluded ||= Dir.glob(config['exclude'].map do |f|
    if File.directory?(f)
      if f.end_with?("/")
        f + "**/*"
      else
        f + "/**/*"
      end
    else
      f
    end
  end)

  # check if the param file has been excluded
  @excluded.include?(file)
end

.included?(file) ⇒ Boolean

Is file included for upload?

Parameters:

  • file (String)

    a file name

Returns:

  • (Boolean)

    true if the file has been included for upload.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/canvas/workflow.rb', line 58

def self.included?(file)
  return false if config['include'].nil?

  # get the list of files that has been explicitly included
  @included ||= Dir.glob(config['include'].map do |f|
    if File.directory?(f)
      if f.end_with?("/")
        f + "**/*"
      else
        f + "/**/*"
      end
    else
      f
    end
  end)

  # check if the param file has been included
  @included.include?(file)
end