testml-command 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ GemSpec = Gem::Specification.new do |gem|
4
+ gem.name = 'testml-command'
5
+ gem.version = '0.0.1'
6
+ gem.license = 'MIT'
7
+ gem.required_ruby_version = '>= 1.9.1'
8
+
9
+ gem.authors << 'Ingy döt Net'
10
+ gem.email = 'ingy@ingy.net'
11
+ gem.summary = 'TestML Language Interpreter Command'
12
+ gem.description = <<-'.'
13
+ Run TestML as a general purpose programming language.
14
+ .
15
+ gem.homepage = 'http://testml.org'
16
+
17
+ gem.files = `git ls-files`.lines.map{|l|l.chomp}
18
+
19
+ gem.executables << 'testml'
20
+
21
+ gem.add_dependency 'testml', '>= 0.0.2'
22
+ end
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright © 2013 Ingy döt Net
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the ‘Software’), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,30 @@
1
+ = testml/command - TestML interpreter command
2
+
3
+ This gem installs a +testml+ command in your PATH that you can use to run
4
+ standalone TestML scripts, just like any other dynamic programming language.
5
+
6
+ = Synopsis
7
+
8
+ > cat example/hello-world.tml
9
+ #!/usr/bin/env testml
10
+
11
+ %TestML 0.1.0
12
+
13
+ Print("Hello, world!\n")
14
+ > ./example/hello-world.tml
15
+ Hello, world!
16
+ >
17
+
18
+ = Description
19
+
20
+ TestML is an Acmeist software testing language. Normally it is used to run data
21
+ driven tests against software. Using this gem, you can also use TestML as a
22
+ general purpose scripting language.
23
+
24
+ = Status
25
+
26
+ This is the first release. Set your expectations accordingly.
27
+
28
+ = Copyright
29
+
30
+ Copyright (c) 2013 Ingy döt Net. See LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,73 @@
1
+ # Load Gem constants from the gemspec
2
+ GemSpecFile = '.gemspec'
3
+ load GemSpecFile
4
+ GemName = GemSpec.name
5
+ GemVersion = GemSpec.version
6
+ GemDir = "#{GemName}-#{GemVersion}"
7
+ GemFile = "#{GemDir}.gem"
8
+ DevNull = '2>/dev/null'
9
+
10
+ # Require the Rake libraries
11
+ require 'rake'
12
+ require 'rake/testtask'
13
+ require 'rake/clean'
14
+ if File.exists? 'test/testml.yaml'
15
+ if File.exists? 'lib/rake/testml.rb'
16
+ $:.unshift "#{Dir.getwd}/lib"
17
+ end
18
+ require 'rake/testml'
19
+ end
20
+
21
+ task :default => 'help'
22
+
23
+ CLEAN.include GemDir, GemFile, 'data.tar.gz', 'metadata.gz'
24
+
25
+ desc 'Run the tests'
26
+ task :test do
27
+ load '.env' if File.exists? '.env'
28
+ Rake::TestTask.new do |t|
29
+ t.verbose = true
30
+ t.test_files = ENV['DEV_TEST_FILES'] &&
31
+ FileList[ENV['DEV_TEST_FILES'].split] ||
32
+ FileList['test/**/*.rb'].sort
33
+ end
34
+ end
35
+
36
+ desc 'Build the gem'
37
+ task :build => [:clean, :test] do
38
+ sh "gem build #{GemSpecFile}"
39
+ end
40
+
41
+ desc 'Install the gem'
42
+ task :install => [:build] do
43
+ sh "gem install #{GemFile}"
44
+ end
45
+
46
+ desc 'Build, unpack and inspect the gem'
47
+ task :distdir => [:build] do
48
+ sh "tar xf #{GemFile} #{DevNull}"
49
+ Dir.mkdir GemDir
50
+ Dir.chdir GemDir
51
+ sh "tar xzf ../data.tar.gz #{DevNull}"
52
+ puts "\n>>> Entering sub-shell for #{GemDir}..."
53
+ system ENV['SHELL']
54
+ end
55
+
56
+ desc 'Build and push the gem'
57
+ task :release => [:build] do
58
+ sh "gem push #{GemFile}"
59
+ end
60
+
61
+ desc 'Print a description of the gem'
62
+ task :desc do
63
+ puts "Gem: '#{GemName}' (version #{GemVersion})"
64
+ puts
65
+ puts GemSpec.description.gsub /^/, ' '
66
+ end
67
+
68
+ desc 'List the Rakefile tasks'
69
+ task :help do
70
+ puts 'The following rake tasks are available:'
71
+ puts
72
+ puts `rake -T`.gsub /^/, ' '
73
+ end
data/bin/testml ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'testml/command'
4
+
5
+ TestML::Command.new(ARGV.clone).run
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env testml
2
+
3
+ %TestML 0.1.0
4
+
5
+ Print(List('The ', *fruit, ' is ', *color, ".\n").Join(''))
6
+
7
+ === Red appple
8
+ --- fruit: apple
9
+ --- color: red
10
+
11
+ === Orange orange
12
+ --- fruit: orange
13
+ --- color: orange
14
+
15
+ === Yellow banana
16
+ --- fruit: banana
17
+ --- color: yellow
18
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env testml
2
+
3
+ %TestML 0.1.0
4
+
5
+ Print("Hello, world!\n")
@@ -0,0 +1,69 @@
1
+ require 'testml/runtime/lang'
2
+ require 'testml/compiler/pegex'
3
+ require 'testml/library/standard'
4
+ require 'testml/library/debug'
5
+
6
+ class TestML::Command
7
+ VERSION = '0.0.1'
8
+
9
+ def usage
10
+ <<'...'
11
+ Usage:
12
+ testml [testml-options] (<testml-file> | -) [runtime arguments]
13
+
14
+ TestML Options:
15
+ -b, --bridge= <bridge-class[,bridge-class-list]>
16
+ ...
17
+ end
18
+
19
+ def initialize(args)
20
+ @args = args
21
+ @file = nil
22
+ @testml = nil
23
+ @bridge = []
24
+ @argv = []
25
+ get_options(args)
26
+ end
27
+
28
+ def get_options(args)
29
+ while arg = args.shift
30
+ if arg =~ /^(?:-b|--bridge(?:=(.*))?)$/
31
+ b = $1 || args.shift or error '-b|--bridge requires a value'
32
+ @bridge.concat(b.split(','))
33
+ elsif File.exists?(arg)
34
+ @file = arg
35
+ break
36
+ elsif arg =~ /^--?$/
37
+ break
38
+ elsif arg !~ /^-/
39
+ error "Input file '#{arg}' does not exist"
40
+ else
41
+ error "Unrecognized argument '#{arg}'"
42
+ end
43
+ end
44
+
45
+ @testml = @file ? File.read(@file) : STDIN.read
46
+ @argv = TestML::List.new(args.map {|a| TestML::String.new(a)})
47
+ end
48
+
49
+ def run
50
+ @runtime = TestML::Runtime::Lang.new(
51
+ testml: @testml,
52
+ bridge: @bridge,
53
+ compiler: TestML::Compiler::Pegex,
54
+ library: [
55
+ TestML::Library::Standard,
56
+ TestML::Library::Debug,
57
+ ],
58
+ )
59
+ @runtime.compile_testml
60
+ @runtime.initialize_runtime
61
+ #XXX @runtime
62
+ @runtime.global.setvar('ARGV', @argv)
63
+ @runtime.run_function(@runtime.function, [])
64
+ end
65
+
66
+ def error(msg)
67
+ fail "Error: #{msg}\n\n#{usage}\n"
68
+ end
69
+ end
@@ -0,0 +1,18 @@
1
+ require 'testml/runtime'
2
+ require 'testml/util'
3
+
4
+ class TestML::Runtime::Lang < TestML::Runtime
5
+ include TestML::Util
6
+
7
+ def assert_EQ(got, want)
8
+ return bool got.value == want.value
9
+ end
10
+
11
+ def assert_HAS(got, has)
12
+ return bool got.value.index(has.value) != -1
13
+ end
14
+
15
+ def assert_OK(got)
16
+ return bool !! got.value
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testml-command
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ingy döt Net
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: testml
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.2
30
+ description: ! 'Run TestML as a general purpose programming language.
31
+
32
+ '
33
+ email: ingy@ingy.net
34
+ executables:
35
+ - testml
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gemspec
40
+ - Gemfile
41
+ - LICENSE
42
+ - README.rdoc
43
+ - Rakefile
44
+ - bin/testml
45
+ - example/fruity.tml
46
+ - example/hello-world.tml
47
+ - lib/testml/command.rb
48
+ - lib/testml/runtime/lang.rb
49
+ homepage: http://testml.org
50
+ licenses:
51
+ - MIT
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.9.1
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.23
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: TestML Language Interpreter Command
74
+ test_files: []
75
+ has_rdoc: