dropset 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.
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Copyright (c) 2011 Christopher Maujean
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation
5
+ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
6
+ and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions
9
+ of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
12
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
13
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
14
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
15
+ DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ Dropset
2
+ =======
3
+
4
+ require 'dropset'
5
+ Dropset.calc(10) # => 55
6
+
7
+ Very simple tool to calculate the number of reps in a "drop set".
@@ -0,0 +1,7 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc 'Default: run specs.'
4
+ task :default => :spec
5
+
6
+ desc "Run specs"
7
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '/lib'))
4
+ require 'dropset'
5
+
6
+ num = ARGV[0].to_i || 1
7
+
8
+ puts "#{Dropset.calc(num)}"
9
+
@@ -0,0 +1,8 @@
1
+ class Dropset
2
+
3
+ def self.calc(n)
4
+ ( n.kind_of? Fixnum and n > 0 ) or raise ArgumentError
5
+ (n * n / 2) + ( n / 2 ) + (n.odd? ? 1 : 0)
6
+ end
7
+
8
+ end
@@ -0,0 +1,3 @@
1
+ module Dropset
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'dropset'
3
+
4
+ describe Dropset do
5
+ it "has a calc method" do
6
+ Dropset.should respond_to(:calc)
7
+ end
8
+
9
+ it "calculates the correct answer for even numbers" do
10
+ [[10,55],[100,5050],[2,3],[4,10]].each do |requested_set,reps|
11
+ Dropset.calc(requested_set).should == reps
12
+ end
13
+ end
14
+
15
+ it "calculates the correct answer for odd numbers" do
16
+ [[3,6],[11,66],[33,561], [61,1891], [100003,5000350006]].each do |requested_set, reps|
17
+ Dropset.calc(requested_set).should == reps
18
+ end
19
+ end
20
+
21
+ it "raises ArgumentError when not passed a number" do
22
+ lambda {
23
+ Dropset.calc()
24
+ }.should raise_error(ArgumentError)
25
+ end
26
+
27
+ it "raises ArgumentError when passed 0" do
28
+ lambda {
29
+ Dropset.calc(0)
30
+ }.should raise_error(ArgumentError)
31
+ end
32
+
33
+ it "raises ArgumentError when passed non-integer values" do
34
+ lambda {
35
+ Dropset.calc(:foo)
36
+ }.should raise_error(ArgumentError)
37
+ lambda {
38
+ Dropset.calc("Foo")
39
+ }.should raise_error(ArgumentError)
40
+ lambda {
41
+ Dropset.calc(5.1)
42
+ }.should raise_error(ArgumentError)
43
+ end
44
+
45
+ it "returns 1 for an input of 1" do
46
+ Dropset.calc(1).should == 1
47
+ end
48
+ end
@@ -0,0 +1,2 @@
1
+ path = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
2
+ $LOAD_PATH << path
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dropset
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Christopher Maujean
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-24 00:00:00.000000000 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+ description: ! " Calculates the number of reps in a dropset (Descending set)\n \n
16
+ \ require 'dropset'\n Dropset.calc(10) #=> 55\n \n"
17
+ email: cmaujean@gmail.com
18
+ executables:
19
+ - dropset
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - README.markdown
24
+ - Rakefile
25
+ - LICENSE
26
+ - lib/dropset/version.rb
27
+ - lib/dropset.rb
28
+ - bin/dropset
29
+ - spec/dropset_spec.rb
30
+ - spec/spec_helper.rb
31
+ has_rdoc: true
32
+ homepage: https://github.com/cmaujean/dropset
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.6.2
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Calculates the number of reps in a dropset (Descending set)
56
+ test_files: []