calc-nik 0.0.3 → 0.0.4
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.
- data/.rspec +2 -0
- data/Rakefile +6 -0
- data/calc.gemspec +2 -0
- data/ext/calc/calc.c +19 -0
- data/ext/calc/extconf.rb +3 -0
- data/lib/calc/version.rb +1 -1
- data/lib/calc.rb +2 -1
- data/spec/calc_spec.rb +31 -0
- data/spec/spec_helper.rb +3 -0
- metadata +12 -4
data/.rspec
ADDED
data/Rakefile
CHANGED
data/calc.gemspec
CHANGED
@@ -12,6 +12,8 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = %q{Basic calculator}
|
13
13
|
gem.homepage = ""
|
14
14
|
|
15
|
+
gem.extensions << "ext/calc/extconf.rb"
|
16
|
+
|
15
17
|
gem.add_development_dependency "rspec"
|
16
18
|
gem.add_development_dependency "simplecov"
|
17
19
|
gem.add_development_dependency "rake"
|
data/ext/calc/calc.c
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
|
3
|
+
/* our new native method; it just returns
|
4
|
+
* the string "bonjour!" */
|
5
|
+
static VALUE calc_bonjour(VALUE self) {
|
6
|
+
return rb_str_new2("bonjour!");
|
7
|
+
}
|
8
|
+
|
9
|
+
/* ruby calls this to load the extension */
|
10
|
+
void Init_calc(void) {
|
11
|
+
/* assume we haven't yet defined Hola */
|
12
|
+
VALUE klass = rb_define_class("Calc_c",
|
13
|
+
rb_cObject);
|
14
|
+
|
15
|
+
/* the hola_bonjour function can be called
|
16
|
+
* from ruby as "Hola.bonjour" */
|
17
|
+
rb_define_singleton_method(klass,
|
18
|
+
"bonjour", calc_bonjour, 0);
|
19
|
+
}
|
data/ext/calc/extconf.rb
ADDED
data/lib/calc/version.rb
CHANGED
data/lib/calc.rb
CHANGED
data/spec/calc_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#calc_spec.rb
|
2
|
+
require 'spec_helper'
|
3
|
+
require './lib/calc'
|
4
|
+
|
5
|
+
describe Calc do
|
6
|
+
before(:each) do
|
7
|
+
@c = Calc::Calc.new
|
8
|
+
@c.get [1, 2], 3
|
9
|
+
@c.get [4, [5, 6], 7]
|
10
|
+
|
11
|
+
@c_short = Calc::Calc.new
|
12
|
+
@c_short.get 1
|
13
|
+
end
|
14
|
+
|
15
|
+
it "gets parameters" do
|
16
|
+
@c.instance_variable_get("@numbers").should eql([1, 2, 3, 4, 5, 6, 7])
|
17
|
+
@c_short.instance_variable_get("@numbers").should eql([1])
|
18
|
+
end
|
19
|
+
|
20
|
+
it "sums stack parameters and wipe them" do
|
21
|
+
@c.plus.should == 28
|
22
|
+
@c_short.plus.should == 1
|
23
|
+
@c.instance_variable_get("@numbers").should == []
|
24
|
+
end
|
25
|
+
|
26
|
+
it "subsctract sum of stack from 0" do
|
27
|
+
@c.minus.should == -28
|
28
|
+
@c_short.minus.should == -1
|
29
|
+
@c.instance_variable_get("@numbers").should == []
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calc-nik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -63,17 +63,23 @@ description: Basic calculator
|
|
63
63
|
email:
|
64
64
|
- laqwoter@gmail.com
|
65
65
|
executables: []
|
66
|
-
extensions:
|
66
|
+
extensions:
|
67
|
+
- ext/calc/extconf.rb
|
67
68
|
extra_rdoc_files: []
|
68
69
|
files:
|
69
70
|
- .gitignore
|
71
|
+
- .rspec
|
70
72
|
- Gemfile
|
71
73
|
- LICENSE.txt
|
72
74
|
- README.md
|
73
75
|
- Rakefile
|
74
76
|
- calc.gemspec
|
77
|
+
- ext/calc/calc.c
|
78
|
+
- ext/calc/extconf.rb
|
75
79
|
- lib/calc.rb
|
76
80
|
- lib/calc/version.rb
|
81
|
+
- spec/calc_spec.rb
|
82
|
+
- spec/spec_helper.rb
|
77
83
|
homepage: ''
|
78
84
|
licenses: []
|
79
85
|
post_install_message:
|
@@ -98,4 +104,6 @@ rubygems_version: 1.8.24
|
|
98
104
|
signing_key:
|
99
105
|
specification_version: 3
|
100
106
|
summary: Basic calculator
|
101
|
-
test_files:
|
107
|
+
test_files:
|
108
|
+
- spec/calc_spec.rb
|
109
|
+
- spec/spec_helper.rb
|