libqalculate-ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ require 'mkmf'
2
+
3
+ CONFIG["CPP"] = "g++ `pkg-config --cflags --libs libqalculate`"
4
+ CONFIG["CC"] = "g++ `pkg-config --cflags --libs libqalculate`"
5
+ #CONFIG["CFLAGS"] = "-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2"
6
+ dir_config("ext")
7
+ pkg_config 'libqalculate'
8
+ create_makefile("qalculate",'ext')
@@ -0,0 +1,40 @@
1
+ require 'test/unit'
2
+ require 'qalculate'
3
+ class TestQalc < Test::Unit::TestCase
4
+ def test_load
5
+ qalc = Qalculate::Calculator.new
6
+ qalc.loadGlobalDefinitions;
7
+ qalc.loadLocalDefinitions;
8
+ end
9
+ def test_calculate
10
+ Qalculate::Calculator.new
11
+ q = Qalculate.calculator;
12
+ q.loadGlobalDefinitions();
13
+ q.loadLocalDefinitions();
14
+ eo = Qalculate::EvaluationOptions.new
15
+ result = q.calculate( '2+2', eo );
16
+ po = Qalculate::PrintOptions.new
17
+ assert_equal 4, result.print(po).to_i;
18
+ assert_equal q.calculate( '2+2' ).print(po).to_i, 4
19
+ assert_equal q.calculate( '1/5' ).print(po).to_f, 0.2
20
+ assert_equal '0.84147098', q.calculate( 'sin(1*radian)' ).print(po)
21
+ po.base = 9;
22
+ assert_equal q.calculate( '3/9' ).print(po).to_f, 0.3
23
+ assert_equal q.calculate( 'x=1' ).print(po), ""
24
+ end
25
+ def test_functions
26
+ Qalculate::Calculator.new
27
+ q = Qalculate.calculator
28
+ q.loadGlobalDefinitions();
29
+ q.loadLocalDefinitions();
30
+ q.functions.each do |function|
31
+ p function.category()
32
+ p function.description()
33
+ end
34
+ puts "Units:"
35
+ q.variables.each do |var|
36
+ p var.title
37
+ end
38
+ #assert q.functions['Geometry']
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libqalculate-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrey Kostenko
8
+ autorequire: qalc
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-04 00:00:00 +03:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Simple and fast calculator'
17
+ email: andrey@kostenko.name
18
+ executables: []
19
+
20
+ extensions:
21
+ - extconf.rb
22
+ extra_rdoc_files:
23
+ - Makefile
24
+ - Rakefile
25
+ files:
26
+ - ext/qalc_wrap.cxx
27
+ - ext/libqalculate/qalculate.h
28
+ - ext/libqalculate/Function.h
29
+ - ext/libqalculate/Unit.h
30
+ - ext/libqalculate/Prefix.h
31
+ - ext/libqalculate/BuiltinFunctions.h
32
+ - ext/libqalculate/Number.h
33
+ - ext/libqalculate/util.h
34
+ - ext/libqalculate/ExpressionItem.h
35
+ - ext/libqalculate/MathStructure.h
36
+ - ext/libqalculate/includes.h
37
+ - ext/libqalculate/DataSet.h
38
+ - ext/libqalculate/Variable.h
39
+ - ext/libqalculate/Calculator.h
40
+ - test/test_qalc.rb
41
+ - Makefile
42
+ - Rakefile
43
+ has_rdoc: true
44
+ homepage: http://qalculate-ruby.rubyforge.org/
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --title
48
+ - Builder -- Easy XML Building
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project: libqalculate-ruby
66
+ rubygems_version: 1.2.0
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: libqalculate port to ruby.
70
+ test_files: []
71
+