mosso 0.0.2 → 0.0.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e446b43885b8b9059822890998c06eaea75dff7
4
- data.tar.gz: 23222c85b8ee6e335d85c177eb1266a5e69f051f
3
+ metadata.gz: bd53a6fcdc03df331ab16c53e4d9ff5571980a4e
4
+ data.tar.gz: 0962f00f7675b4119c69977a015979083b299996
5
5
  SHA512:
6
- metadata.gz: ea90ca4c63583a195307c6e6fa42103f97d22ddd3262d7ecfdcb28659b4bd8d7f19306a246d7b9c98d7dfed34dbfd74e439201889f40c9ba78378db3287832d6
7
- data.tar.gz: 17696d70ad3566d9b0beff9841c10ea3aaa7769db9ae225f28023f947622c49142c2b06391137c102dba4d046e43362e6802c0c41f79f5960c3f9221fa34ba9f
6
+ metadata.gz: e973c990abe128df760b757f3b4f0b03978d65dfba1c7f192b6ad41b22456117793bc02a33da437e708ebcb1b37e2df276cb7fb857141ef9dabefa0895aa6661
7
+ data.tar.gz: 9314577c36ebf0da78c5306bd32a7360b45f6aaed6f8de2084d8ac5b671931c943f5548bd5f87183aaa6e4b549af6faa43f122f023a820320d88be07da8cdbcf
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ pkg
data/README.md CHANGED
@@ -7,26 +7,31 @@ Module to measure the execution time.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  gem 'mosso'
10
-
10
+
11
11
  And then execute:
12
12
 
13
- $ bundle
13
+ $ bundle install
14
14
 
15
15
  Or install it yourself as:
16
16
 
17
17
  $ gem install mosso
18
18
 
19
19
  ## Usage
20
-
21
- m = Mosso.new
22
- ......
23
-
24
- m.exection_time() # => ""
25
-
20
+ require 'mosso'
21
+
22
+ m = Measure.new
23
+ ...
24
+ ...
25
+ ...
26
+ puts m
27
+
28
+ STDOUT:
29
+ Exection Time: 2.000249151 [sec]
30
+ FileName: /home/user/products/gems/mosso/spec/mosso_spec.rb, Method: puts, Line: 32"
26
31
 
27
32
  ## Contributing
28
33
 
29
- 1. Fork it ( http://github.com/<my-github-username>/mosso/fork )
34
+ 1. Fork it ( http://github.com/ryosy383/mosso/fork )
30
35
  2. Create your feature branch (`git checkout -b my-new-feature`)
31
36
  3. Commit your changes (`git commit -am 'Add some feature'`)
32
37
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/measure.rb ADDED
@@ -0,0 +1,37 @@
1
+ class Measure
2
+
3
+ def initialize()
4
+ start()
5
+ end
6
+
7
+ def to_s
8
+ ret = []
9
+ file, line, method = parse_caller(caller.first)
10
+ ret << "Exection Time: #{exection_time()} [sec]"
11
+ ret << "FileName: #{file}, Method: #{method}, Line: #{line}"
12
+ ret << "\n"
13
+ ret.join("\n")
14
+ end
15
+
16
+ def start()
17
+ @start_time = Time.now
18
+ end
19
+
20
+ def reset()
21
+ start()
22
+ end
23
+
24
+ def exection_time()
25
+ Time.now - @start_time
26
+ end
27
+
28
+ def parse_caller(at)
29
+ if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
30
+ file = $1
31
+ line = $2.to_i
32
+ method = $3
33
+ [file, line, method]
34
+ end
35
+ end
36
+
37
+ end
data/lib/mosso/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mosso
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.21"
3
3
  end
data/lib/mosso.rb CHANGED
@@ -1,6 +1,2 @@
1
1
  require "mosso/version"
2
- require "mosso/extension/mosso"
3
-
4
- module Mosso
5
- # Your code goes here...
6
- end
2
+ require "measure"
data/spec/mosso_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Mosso do
4
4
  it 'should have a version number' do
5
5
  Mosso::VERSION.should_not be_nil
6
- Mosso::VERSION.should == "0.0.2"
6
+ Mosso::VERSION.should == "0.0.21"
7
7
  end
8
8
 
9
9
  it 'should measure rightly the execution time' do
@@ -11,24 +11,24 @@ describe Mosso do
11
11
  # initialize
12
12
  measure = Measure.new
13
13
  sleep 1
14
- measure.exection_time().round.should == 1.0
14
+ measure.exection_time().round.should be_eql(1)
15
15
  puts measure
16
16
 
17
17
  # exection_time
18
18
  sleep 2
19
- measure.exection_time().round.should == 3.0
19
+ measure.exection_time().round.should be_eql(3)
20
20
  puts measure
21
21
 
22
22
  # reset
23
23
  measure.reset
24
24
  sleep 1
25
- measure.exection_time().round.should == 1.0
25
+ measure.exection_time().round.should be_eql(1)
26
26
  puts measure
27
27
 
28
28
  # start
29
29
  measure.start
30
- sleep 1
31
- measure.exection_time().round.should == 1.0
30
+ sleep 2
31
+ measure.exection_time().round.should be_eql(2)
32
32
  puts measure
33
33
 
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mosso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryosy383
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,8 +66,8 @@ files:
66
66
  - LICENSE.txt
67
67
  - README.md
68
68
  - Rakefile
69
+ - lib/measure.rb
69
70
  - lib/mosso.rb
70
- - lib/mosso/extension/mosso.rb
71
71
  - lib/mosso/version.rb
72
72
  - mosso.gemspec
73
73
  - spec/mosso_spec.rb
@@ -1,23 +0,0 @@
1
- class Measure
2
-
3
- def initialize()
4
- start()
5
- end
6
-
7
- def to_s
8
- "Execution time: #{exection_time()} [sec]"
9
- end
10
-
11
- def start()
12
- @start_time = Time.now
13
- end
14
-
15
- def reset()
16
- start()
17
- end
18
-
19
- def exection_time()
20
- Time.now - @start_time
21
- end
22
-
23
- end