calc-nik 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Rakefile CHANGED
@@ -1,4 +1,10 @@
1
1
  require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+ # require 'rake/extensiontask'
4
+
5
+ # spec = Gem::Specification.load('calc.gemspec')
6
+
7
+ # Rake::ExtensionTask.new('calc', spec)
2
8
 
3
9
  desc 'Default: run specs.'
4
10
  task :default => :spec
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
+ }
@@ -0,0 +1,3 @@
1
+ require 'mkmf'
2
+
3
+ create_makefile('calc/calc')
data/lib/calc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Calc
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/calc.rb CHANGED
@@ -1,4 +1,5 @@
1
- require "calc/version"
1
+ require 'calc/version'
2
+ require 'calc/calc'
2
3
 
3
4
  module Calc
4
5
  class Calc
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
@@ -0,0 +1,3 @@
1
+ # RSpec.configure {|c| c.formatter = 'documentation'}
2
+ require 'simplecov'
3
+ SimpleCov.start
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.3
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-05 00:00:00.000000000 Z
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