test_values 0.1.0.pre → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89fdd287011ca7c6359884da4b4cd0dcf3c0ce19
4
- data.tar.gz: ff2b9c4fd2e6b795f796ec05cd6b9397d7dd4b97
3
+ metadata.gz: d70c7bfe9b941510702219a97cb6dbd10135c1ab
4
+ data.tar.gz: 337503957c0b9b80233ab2d2b24f161269457480
5
5
  SHA512:
6
- metadata.gz: b2903c4b9768a65722ae1f695532a5171ea78ea46b1f6fe69d2227164002fcd34a2ac8147b681e08f7669e631960cdd1ec67f51ad68f27f3cb8827d89435ba3a
7
- data.tar.gz: 9208aeaa88a0d828b8e38b144d015790e92586fdfdd3a84b228f9bd052aeae2674508834f989f8d4205f70863d3a6251831dd0bcf5b5027f809f035913db1e89
6
+ metadata.gz: 848d62c01a29a9f912cedf4e3300625025d4792c3fbe4a14847caac37b276e4d7b8c2bf118dc58e4535c8b18e6c603f67053c90e2d767e3485ba1357d7b3529e
7
+ data.tar.gz: 6ae2b10eddcf9e39421bc263f3b88ab01fb30d347ad4fc1aa6460b2064d8b21cb98c309958fd0cc8c523a0bd5fec416f85902ba7398506b1fd7109455032a434
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test_values (0.1.0.pre)
4
+ test_values (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,43 +1,7 @@
1
- # TestValues
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/test_values`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'test_values'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install test_values
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/test_values. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
- ## License
38
-
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the TestValues project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/test_values/blob/master/CODE_OF_CONDUCT.md).
1
+ # Test Values
2
+
3
+ Project to support generation of values for testing software.
4
+
5
+ At this point, just a few methods.
6
+
7
+ Experimenting with YARD documentation.
data/lib/test_values.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'test_values/version'
2
+ require 'test_values/values_base'
3
+ require 'test_values/string_values'
2
4
 
3
- module TestValues
5
+ class TestValues
4
6
  # Your code goes here...
5
7
  end
@@ -0,0 +1,57 @@
1
+ class StringValues < ValuesBase
2
+
3
+ BASE_STRING = 'x'
4
+ # Return a string of the given +size+,
5
+ # built by trimming or extending the given +base_string+.
6
+ # @param size [Integer] the size of the string to be returned.
7
+ # @param base_string [String] the base string to be trimmed or extended.
8
+ # @return [String] a string of the given size.
9
+ # @raise [TypeError] if +size+ is not an +Integer+.
10
+ # @raise [TypeError] if +base_string+ is not a +String+.
11
+ # @raise [RangeError] if +size+ is negative.
12
+ def self.string_of_size(size, base_string=BASE_STRING)
13
+ self.verify_class('size', Integer, size)
14
+ self.verify_class('base_string', String, base_string)
15
+ if size < 0
16
+ message = "Parameter size must be nonnegative, not #{size}"
17
+ raise RangeError.new(message)
18
+ end
19
+ return '' if size == 0
20
+ s = base_string
21
+ while s.size < size
22
+ s = s * 2
23
+ end
24
+ return s[0..size-1]
25
+ end
26
+
27
+ # Return a hash of strings of minimum and maximum length
28
+ # for the given +range+.
29
+ # @param range [Range] specifies the minimum and maximum string lengths.
30
+ # @param base_string [String] specifies the +base_string+
31
+ # @see string_of_size string_of_size for exceptions raised.
32
+ # @return [Hash] +Symbol+/+String+ pairs
33
+ # with keys +:min_length+ and +:max_length+.
34
+ def self.strings_in_length_range(range, base_string=BASE_STRING)
35
+ self.verify_class('range', Range, range)
36
+ {
37
+ :min_length => self.string_of_size(range.first, base_string),
38
+ :max_length => self.string_of_size(range.last, base_string),
39
+ }
40
+ end
41
+
42
+ # Return a hash of strings not within minimum and maximum length
43
+ # for the given +range+.
44
+ # @param range [Range] specifies the minimum and maximum string lengths.
45
+ # @param base_string [String] specifies the +base_string+
46
+ # @see string_of_size string_of_size for exceptions raised.
47
+ # @return [Hash] +Symbol+/+String+ pairs
48
+ # with keys +:too_short+ and +:too_long+.
49
+ def self.strings_not_in_length_range(range, base_string=BASE_STRING)
50
+ self.verify_class('range', Range, range)
51
+ {
52
+ :too_short => self.string_of_size(range.first - 1, base_string),
53
+ :too_long => self.string_of_size(range.last + 1, base_string),
54
+ }
55
+ end
56
+
57
+ end
@@ -0,0 +1,9 @@
1
+ class ValuesBase
2
+
3
+ def self.verify_class(parameter_name, klass, obj)
4
+ return if obj.kind_of?(klass)
5
+ message = "Parameter #{parameter_name} must be instance of #{klass.name}, not #{obj.inspect}"
6
+ raise TypeError.new(message)
7
+ end
8
+
9
+ end
@@ -1,3 +1,3 @@
1
- module TestValues
2
- VERSION = '0.1.0.pre'
1
+ class TestValues
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_values
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - burdettelamar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-13 00:00:00.000000000 Z
11
+ date: 2018-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,8 @@ files:
70
70
  - bin/console
71
71
  - bin/setup
72
72
  - lib/test_values.rb
73
+ - lib/test_values/string_values.rb
74
+ - lib/test_values/values_base.rb
73
75
  - lib/test_values/version.rb
74
76
  - test_values.gemspec
75
77
  homepage: https://github.com/BurdetteLamar/test_values
@@ -87,9 +89,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
89
  version: '0'
88
90
  required_rubygems_version: !ruby/object:Gem::Requirement
89
91
  requirements:
90
- - - ">"
92
+ - - ">="
91
93
  - !ruby/object:Gem::Version
92
- version: 1.3.1
94
+ version: '0'
93
95
  requirements: []
94
96
  rubyforge_project:
95
97
  rubygems_version: 2.4.5.2