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

fixed error for rubygems in Gemfile and bug in qed --help #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ web/
work/sandbox/
*.lock
*.gem

.rvmrc
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
source :rubygems
source "https://rubygems.org"
gemspec
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Ruby Q.E.D.


[Homepage](http://rubyworks.github.com/qed) /
[Documentation](http://rubydoc.info/gems/qed/frames) /
[Report Issue](http://github.com/rubyworks/qed/issues) /
Expand Down
28 changes: 28 additions & 0 deletions demo/12_ignore_non_ruby_code_blox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Ignore Non Ruby Code

Which can be indicated by a markdown \`\`\`elixir string e.g

count = 0

Now we increment it

```elixir
count = count + 1
```

or not?

```
count.assert.zero?
count += 1
```

but

```ruby
count += 1
```

worx

count.assert == 2
12 changes: 6 additions & 6 deletions lib/qed/cli/qed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class Session
#
# Session settings are passed to `Session.new`.
#
#def self.settings
# @settings ||= Settings.new
#end
def self.settings
@settings ||= Settings.new
end

#
# Command line interface for running demos.
Expand Down Expand Up @@ -56,8 +56,8 @@ def self.cli(*argv)

options = cli_parse(argv)

settings = Settings.new(options)
session = Session.new(settings)
@settings = Settings.new(options)
session = Session.new(@settings)
success = session.run

exit -1 unless success
Expand Down Expand Up @@ -143,7 +143,7 @@ def self.cli_parse(argv)
unless settings.profiles.empty?
puts "Available Profiles:"
#require 'confection'
QED.profiles.each do |name|
settings.profiles.each do |name|
next if name.strip == ''
puts " -p #{name}"
end
Expand Down
11 changes: 11 additions & 0 deletions lib/qed/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,31 @@ def parse
indented = false
explain = []
example = [] #Step.new(file)
foreign = false # we are inside a foreign language block, e.g. ^```livescript or ^```elixir, but **not** ^```ruby or ^```$

# TODO: I would not accept the PR like this, but I am willing to refactor this
lines.each do |lineno, line|
case line
when /^\s*$/ # blank line
next if foreign
blank = true
if indented
example << [lineno, line]
else
explain << [lineno, line]
end
when /\A\s+/ #/\A(\t|\ \ +)/ # indented
next if foreign
indented = true
blank = false
example << [lineno, line]
# Can we just escape other language blox?
when /\A```ruby/
foreign = false
when /\A```\s*\z/
foreign = false
when /\A```\S/
foreign = true
else
if indented or blank
steps << Step.new(demo, explain, example, steps.last)
Expand Down