-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lowjoel/language-definitions
Import the language definitions from the Web application.
- Loading branch information
Showing
9 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
require 'active_support/all' | ||
require 'coursemology/polyglot/version' | ||
|
||
module Coursemology | ||
module Polyglot | ||
# Your code goes here... | ||
module Coursemology::Polyglot | ||
extend ActiveSupport::Autoload | ||
|
||
eager_autoload do | ||
autoload :Language | ||
end | ||
|
||
def self.eager_load! | ||
super | ||
Coursemology::Polyglot::Language.eager_load! | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
if defined?(ActiveRecord) | ||
# :nocov: | ||
# TODO: This is for compatibility with the Web application. A future refactoring might be able | ||
# to remove this dependency. | ||
class Coursemology::Polyglot::Language < ActiveRecord::Base; end | ||
# :nocov: | ||
else | ||
class Coursemology::Polyglot::Language; end | ||
end | ||
|
||
class Coursemology::Polyglot::Language | ||
extend ActiveSupport::Autoload | ||
|
||
eager_autoload do | ||
autoload :Python | ||
end | ||
|
||
# Gets the display name of the language. | ||
# | ||
# @abstract | ||
# @return [String] | ||
def self.display_name | ||
fail NotImplementedError | ||
end | ||
|
||
# The stylesheets that need to be packaged with the rest of the application. | ||
# | ||
# This should include the Rouge/Pygments stylesheet for formatting code. | ||
# | ||
# @abstract | ||
# @return [Array<String>] | ||
def self.stylesheets | ||
fail NotImplementedError | ||
end | ||
|
||
# The script files that need to be packaged with the rest of the application. | ||
# | ||
# This should include the Ace mode for the language. | ||
# | ||
# @abstract | ||
# @return [Array<String>] | ||
def self.javascript | ||
fail NotImplementedError | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Coursemology::Polyglot::Language::Python < Coursemology::Polyglot::Language | ||
class Python2Point7 < Coursemology::Polyglot::Language::Python | ||
class << self | ||
def display_name | ||
'Python 2.7' | ||
end | ||
end | ||
end | ||
|
||
class Python3Point4 < Coursemology::Polyglot::Language::Python | ||
class << self | ||
def display_name | ||
'Python 3.4' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Coursemology::Polyglot::Language::Python do | ||
describe Coursemology::Polyglot::Language::Python::Python2Point7 do | ||
it 'returns the correct display name' do | ||
expect(subject.class.display_name).to eq('Python 2.7') | ||
end | ||
end | ||
|
||
describe Coursemology::Polyglot::Language::Python::Python3Point4 do | ||
it 'returns the correct display name' do | ||
expect(subject.class.display_name).to eq('Python 3.4') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Coursemology::Polyglot::Language do | ||
describe '.display_name' do | ||
it 'fails with NotImplementedError' do | ||
expect { subject.class.display_name }.to raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe '.stylesheets' do | ||
it 'fails with NotImplementedError' do | ||
expect { subject.class.stylesheets }.to raise_error(NotImplementedError) | ||
end | ||
end | ||
|
||
describe '.javascript' do | ||
it 'fails with NotImplementedError' do | ||
expect { subject.class.javascript }.to raise_error(NotImplementedError) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters