fibonaccia 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @internal_comment
3
+ #
4
+ # Copyright © 2015 Ken Coar
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require('fibonaccia/module-doc')
20
+
21
+ # @private
22
+ module Fibonaccia::ClassMethods
23
+
24
+ class << self
25
+
26
+ #
27
+ # @!parse extend ClassMethods
28
+ #
29
+ def included(klass)
30
+ klass.extend(::Fibonaccia::ClassMethods)
31
+ end # def included
32
+
33
+ end # module Fibonaccia::ClassMethods eigenclass
34
+
35
+ end # module Fibonaccia::ClassMethods
@@ -0,0 +1,82 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @internal_comment
3
+ #
4
+ # Copyright © 2015 Ken Coar
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require('fibonaccia/module-doc')
20
+
21
+ module Fibonaccia
22
+
23
+ #
24
+ # Define a 'parent' exception class for the module. All
25
+ # module-specific exceptions should inherit from this.
26
+ #
27
+ class ::Fibonaccia::Exception < ::StandardError
28
+
29
+ #
30
+ # We cannot access the <tt>mesg</tt> 'instance variable' of the
31
+ # inherited class hierarchy, do we needs must fake it as part of
32
+ # our constructor.
33
+ #
34
+ # If the first element of the argument list is a string, we set
35
+ # our message to it. Otherwise, we follow the practice of using
36
+ # the name of the class as the message.
37
+ #
38
+ # @param [Array] args
39
+ # <tt>::StandardError.method(:new).arity => -1</tt>, so we allow
40
+ # an undefined number of arguments here, as well. We only look
41
+ # at the first one, though. If it's a string, we use it --
42
+ # otherwise we set the message to <tt>nil</tt> and let
43
+ # #to_s/#to_str apply the default at need.
44
+ #
45
+ def initialize(*args)
46
+ @mesg = (args[0].respond_to?(:to_str)) ? args[0] : nil
47
+ return super
48
+ end # def initialize
49
+
50
+ #
51
+ # We cannot access the standard <tt>Exception</tt> hierarchical
52
+ # message mechanism because it store the message in a
53
+ # non-<tt>@</tt> prefixed 'instance variable.' So we need to work
54
+ # around it with our own instance variable, set by the
55
+ # constructor.
56
+ #
57
+ # @return [String]
58
+ # whatever the constructor stored in the <tt>@mesg</tt> instance
59
+ # variable, or the class name if <tt>@mesg</tt> is <tt>nil</tt>.
60
+ #
61
+ def to_s
62
+ return (@mesg || self.class.name)
63
+ end # def to_s
64
+
65
+ #
66
+ # Having a <tt>#to_str</tt> method tells Ruby 'you can treat me as a String.'
67
+ # This just returns the same value as #to_s.
68
+ #
69
+ # @return [String]
70
+ # value returned by #to_s method.
71
+ #
72
+ def to_str
73
+ return self.to_s
74
+ end # def to_str
75
+
76
+ end # class Exception
77
+
78
+ class NotPositiveInteger < ::Fibonaccia::Exception
79
+
80
+ end # class NotPositiveInteger
81
+
82
+ end # module Fibonaccia
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @internal_comment
3
+ #
4
+ # Copyright © 2015 Ken Coar
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ # @internal_comment
20
+ #
21
+ # This file exists solely to ensure that Yard picks up the module documentation properly.
22
+ #
23
+
24
+ #
25
+ # The *Fibonaccia* module simply provides three things to Ruby code:
26
+ #
27
+ # 1. Access to a constant, <tt>Fibonaccia.PHI</tt> (φ), which is the
28
+ # value of the Golden Ratio (see the
29
+ # {https://en.wikipedia.org/wiki/Golden_ratio Wikipedia article})
30
+ # either to whatever precision Ruby is using, or to an arbitrarily
31
+ # great precision using <tt>BigDecimal</tt> semantics;
32
+ # 2. The Fibonacci sequence, to however many terms you desire (and your resources
33
+ # can support);
34
+ # 3. Coördinates to construct a {https://en.wikipedia.org/wiki/Golden_spiral golden spiral}
35
+ # (<b>not</b> the Fibonacci spiral, which is an <i>approximation</i> of
36
+ # the golden spiral). <b><i>Not yet implemented.</i></b>
37
+ #
38
+ module Fibonaccia
39
+ end # module Fibonaccia
@@ -0,0 +1,86 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @internal_comment
3
+ #
4
+ # Copyright © 2015 Ken Coar
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require('fibonaccia/module-doc')
20
+ require('versionomy')
21
+
22
+ module Fibonaccia
23
+
24
+ #
25
+ # Minimum version of Ruby we support.
26
+ #
27
+ MINIMUM_RUBY_VERSION = Versionomy.parse('1.9.3')
28
+ #
29
+ # Enforce our minimum requirement.
30
+ #
31
+ if (Versionomy.ruby_version < MINIMUM_RUBY_VERSION)
32
+ raise(RuntimeError,
33
+ "minimum Ruby version required is #{MINIMUM_RUBY_VERSION.to_s}, " +
34
+ "running #{Versionomy.ruby_version.to_s}")
35
+ end
36
+
37
+ #
38
+ # Initial starting point.
39
+ #
40
+ @version = Versionomy.parse('0.0.1')
41
+
42
+ #
43
+ # First actual release: 1.0.0!
44
+ #
45
+ @version = @version.change(:major => 1,
46
+ :tiny => 0)
47
+
48
+ #
49
+ # How to advance the version number.
50
+ #
51
+ #@version = @version.bump(:minor)
52
+
53
+ #
54
+ # Stupid build problems..
55
+ #
56
+ @version = @version.bump(:tiny)
57
+ @version = @version.bump(:tiny)
58
+
59
+ @version.freeze
60
+
61
+ #
62
+ # Frozen string representation of the module version number.
63
+ #
64
+ VERSION = @version.to_s.freeze
65
+
66
+ #
67
+ # Returns the {http://rubygems.org/gems/versionomy Versionomy}
68
+ # representation of the package version number.
69
+ #
70
+ # @return [Versionomy]
71
+ #
72
+ def self.version
73
+ return @version
74
+ end # def self.version
75
+
76
+ #
77
+ # Returns the package version number as a string.
78
+ #
79
+ # @return [String]
80
+ # Package version number.
81
+ #
82
+ def self.VERSION
83
+ return self.const_get('VERSION')
84
+ end # def self.VERSION
85
+
86
+ end # module Fibonaccia
@@ -0,0 +1,118 @@
1
+ %global gem_name fibonaccia
2
+ %global gem_version %(ruby -rubygems -Ilib -r%{gem_name} -e 'puts(Fibonaccia::VERSION)')
3
+ #%global gems_dir %(ruby -rubygems -e 'begin ; puts(Gem::RUBYGEMS_DIR) ; rescue ; puts(Gem::dir) ; end' 2> /dev/null)
4
+ #%global gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}
5
+ %global rubyabi 1.8
6
+
7
+ Name: rubygem-%{gem_name}
8
+ Version: %{gem_version}
9
+ Release: 2%{?dist}
10
+ BuildArch: noarch
11
+
12
+ Summary: Fibonacci series and golden relationships.
13
+
14
+ Group: Development/Languages
15
+
16
+ License: Apache 2.0
17
+ URL: https://github.com/RoUS/rubygem-fibonaccia
18
+ Source0: https://rubygems.org/downloads/%{gem_name}-%{version}.gem
19
+
20
+ BuildRequires: rubygems-devel
21
+ BuildRequires: ruby(rubygems) >= 1.3.6
22
+ BuildRequires: rubygem-bundler >= 1.0.7
23
+
24
+ Requires: rubygem-bigdecimal
25
+ Requires: rubygem-bundler >= 1.0.7
26
+ Requires: rubygem-versionomy >= 0.4.3
27
+
28
+ %description
29
+ This provides a simple module for dealing with the Fibonacci
30
+ series and things that relate to it.
31
+
32
+
33
+ %package doc
34
+ Summary: Documentation for %{name}
35
+ Group: Documentation
36
+ Requires: %{name} = %{version}-%{release}
37
+ BuildArch: noarch
38
+
39
+
40
+ %description doc
41
+ Documentation for %{name}
42
+
43
+
44
+ %prep
45
+ gem unpack %{SOURCE0}
46
+ %setup -q -D -T -n %{gem_name}-%{version}
47
+ gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
48
+
49
+
50
+ %build
51
+ gem build %{gem_name}.gemspec
52
+ #
53
+ # %%gem_install compiles any C extensions and installs the gem into
54
+ # ./%%gem_dir by default, so that we can move it into the buildroot in
55
+ # %%install
56
+ #
57
+ %gem_install
58
+
59
+
60
+ %install
61
+ mkdir -p %{buildroot}%{gem_dir}
62
+ cp -a ./%{gem_dir}/* %{buildroot}%{gem_dir}
63
+
64
+ #
65
+ # Comment these out until we know how to handle them.
66
+ #
67
+ #chmod 0644 $RPM_BUILD_ROOT%{gem_instdir}/tests/*.rb
68
+ #chmod -R 0655 $RPM_BUILD_ROOT%{gem_instdir}/features
69
+
70
+ #
71
+ # We don't need these files anymore, and they shouldn't be in the RPM.
72
+ #
73
+ rm -rf $RPM_BUILD_ROOT%{gem_instdir}/{.require_paths,.travis.yml}
74
+ rm -rf $RPM_BUILD_ROOT%{gem_instdir}/{test*,features*,rel-eng,Gemfile*}
75
+ rm -rf $RPM_BUILD_ROOT%{gem_instdir}/{Rakefile*,tasks*}
76
+ rm -rf $RPM_BUILD_ROOT%{gem_instdir}/%{name}.spec
77
+ rm -rf $RPM_BUILD_ROOT%{gem_instdir}/%{gem_name}.gemspec
78
+ rm -rf $RPM_BUILD_ROOT%{gem_cache}
79
+
80
+
81
+ #%check
82
+ #pushd .%{gem_instdir}
83
+ #ruby -S testrb -Ilib:ext/%{gem_name}/ext $(ls -1 tests/test_*.rb | sort)
84
+ #popd
85
+
86
+
87
+ %post
88
+ #
89
+ # If Yard is installed on the system, build the yri docco for the gem.
90
+ #
91
+ if which yard 2>&1 > /dev/null ; then
92
+ yard gems %{gem_name} 2>&1 > /dev/null
93
+ fi
94
+
95
+
96
+ %files
97
+ %defattr(-,root,root,-)
98
+ %doc %{gem_instdir}/Change[Ll]og
99
+ %doc %{gem_instdir}/CONTRIBUTORS.md
100
+ %doc %{gem_instdir}/LICEN[SC]E.md
101
+ %doc %{gem_instdir}/README.md
102
+ %dir %{gem_instdir}
103
+ %dir %{gem_libdir}
104
+ %dir %{gem_libdir}/%{gem_name}
105
+ %{gem_libdir}/*.rb
106
+ %{gem_libdir}/%{gem_name}/*.rb
107
+ %{gem_spec}
108
+
109
+
110
+ %files doc
111
+ %doc %{gem_docdir}
112
+ %doc %{gem_instdir}/[A-Z]*.html
113
+
114
+
115
+ %changelog
116
+ * Thu Jul 23 2015 Ken Coar <kcoar@redhat.com> 1.0.0-2
117
+ - new package built with tito
118
+
@@ -0,0 +1,9 @@
1
+ desc('Convert markdown files to HTML')
2
+ task(:markdown) do
3
+ Dir['*.md'].each do |mdname|
4
+ muname = mdname.sub(%r!\.md$!, '.html')
5
+ $stdout.print("Converting #{File.basename(mdname)}:")
6
+ system("rdiscount < \"#{mdname}\" > \"#{muname}\"")
7
+ $stdout.puts(' done.')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fibonaccia
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Ken Coar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bigdecimal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: versionomy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: cucumber
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rdiscount
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.8.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.2
111
+ description: |
112
+ Non-mixin module providing access to terms in the Fibonacci series.
113
+ Fetch specific terms, slice the series, check to see if an arbitrary
114
+ value is a Fibonacci number, etc.
115
+ email:
116
+ - kcoar@redhat.com
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files:
120
+ - README.md
121
+ - Details.md
122
+ files:
123
+ - ".tito/custom/gemtagger.py"
124
+ - ".tito/custom/gemtagger.pyc"
125
+ - ".tito/packages/.readme"
126
+ - ".tito/packages/rubygem-fibonaccia"
127
+ - ".tito/tito.props"
128
+ - ".travis.yml"
129
+ - CONTRIBUTORS.md
130
+ - Changelog
131
+ - Details.md
132
+ - Gemfile
133
+ - LICENCE.md
134
+ - LICENCE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - features/constants.feature
138
+ - features/enumeration.feature
139
+ - features/exceptions.feature
140
+ - features/is_fibonacci.feature
141
+ - features/sizing.feature
142
+ - features/slicing-growth.feature
143
+ - features/slicing-sequence.feature
144
+ - features/slicing.feature
145
+ - features/step_definitions/exceptions.rb
146
+ - features/step_definitions/fibonaccia-specific.rb
147
+ - features/step_definitions/streams.rb
148
+ - features/step_definitions/utility.rb
149
+ - features/support/env.rb
150
+ - features/support/hooks.rb
151
+ - fibonaccia.gemspec
152
+ - lib/fibonaccia.rb
153
+ - lib/fibonaccia/classmethods.rb
154
+ - lib/fibonaccia/exceptions.rb
155
+ - lib/fibonaccia/module-doc.rb
156
+ - lib/fibonaccia/version.rb
157
+ - rubygem-fibonaccia.spec
158
+ - tasks/markdown-to-html.rake
159
+ homepage: https://github.com/RoUS/rubygem-fibonaccia
160
+ licenses:
161
+ - Apache 2.0
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options:
165
+ - "--main=README.md"
166
+ - "--charset=UTF-8"
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 1.9.3
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.2.3
182
+ signing_key:
183
+ specification_version: 3
184
+ summary: fibonaccia-1.0.2 - Easy access to Fibonacci series and related things.
185
+ test_files:
186
+ - features/constants.feature
187
+ - features/enumeration.feature
188
+ - features/exceptions.feature
189
+ - features/is_fibonacci.feature
190
+ - features/sizing.feature
191
+ - features/slicing-growth.feature
192
+ - features/slicing-sequence.feature
193
+ - features/slicing.feature
194
+ - features/step_definitions/exceptions.rb
195
+ - features/step_definitions/fibonaccia-specific.rb
196
+ - features/step_definitions/streams.rb
197
+ - features/step_definitions/utility.rb
198
+ - features/support/env.rb
199
+ - features/support/hooks.rb
200
+ has_rdoc: true