fdist 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b1742aa7764c4f14f9e9e42a6e11c5f1d13ce39
4
+ data.tar.gz: b4e48e02e5646ee25ea48fff7fb16bdf4a2cc81c
5
+ SHA512:
6
+ metadata.gz: 58cfe7cf332f2277ba1f52ca070ac895ca9976e2d2ff7c608afccc4a0e149e242be788394be6c5fc99b0e0ad17ac206ee68277ee8b868efa5893a916db355a88
7
+ data.tar.gz: da9ff0d41b06dbd59c94022fdd3a171516b70f8a633bae55fb0f03d217f9da0f0c874642b323bae3d7cf8be99fbdab10d8e817e949d67e34c119a3ff45d53239
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ # Add dependencies to develop your gem here.
6
+ # Include everything needed to run rake, tests, features, etc.
7
+ group :development do
8
+ gem "bundler", "~> 1.0"
9
+ gem "jeweler", "~> 1.8.7"
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.1.4)
6
+ faraday (0.8.8)
7
+ multipart-post (~> 1.2.0)
8
+ git (1.2.6)
9
+ github_api (0.10.1)
10
+ addressable
11
+ faraday (~> 0.8.1)
12
+ hashie (>= 1.2)
13
+ multi_json (~> 1.4)
14
+ nokogiri (~> 1.5.2)
15
+ oauth2
16
+ hashie (2.0.5)
17
+ highline (1.6.20)
18
+ httpauth (0.2.0)
19
+ jeweler (1.8.8)
20
+ builder
21
+ bundler (~> 1.0)
22
+ git (>= 1.2.5)
23
+ github_api (= 0.10.1)
24
+ highline (>= 1.6.15)
25
+ nokogiri (= 1.5.10)
26
+ rake
27
+ rdoc
28
+ jwt (0.1.8)
29
+ multi_json (>= 1.5)
30
+ multi_json (1.8.2)
31
+ multi_xml (0.5.5)
32
+ multipart-post (1.2.0)
33
+ nokogiri (1.5.10)
34
+ oauth2 (0.9.2)
35
+ faraday (~> 0.8)
36
+ httpauth (~> 0.2)
37
+ jwt (~> 0.1.4)
38
+ multi_json (~> 1.0)
39
+ multi_xml (~> 0.5)
40
+ rack (~> 1.2)
41
+ rack (1.5.2)
42
+ rake (10.1.0)
43
+ rdoc (4.0.0)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ bundler (~> 1.0)
50
+ jeweler (~> 1.8.7)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 michael d. towle
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = fdist
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to fdist
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 michael d. towle. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "fdist"
18
+ gem.homepage = "http://github.com/gametheoretic/fdist"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{quickie add-ons to the Array class}
21
+ gem.description = %Q{Array methods now include :freq and :fdist, the first of which returns a Rational, and the second of which returns a hash of expression => count pairs}
22
+ gem.email = "gametheoretic@gmail.com"
23
+ gem.authors = ["michael d. towle"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2
data/fdist.gemspec ADDED
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fdist"
8
+ s.version = "0.2.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["michael d. towle"]
12
+ s.date = "2013-11-28"
13
+ s.description = "Array methods now include :freq and :fdist, the first of which returns a Rational, and the second of which returns a hash of expression => count pairs"
14
+ s.email = "gametheoretic@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "fdist.gemspec",
28
+ "lib/fdist.rb"
29
+ ]
30
+ s.homepage = "http://github.com/gametheoretic/fdist"
31
+ s.licenses = ["MIT"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = "2.0.3"
34
+ s.summary = "quickie add-ons to the Array class"
35
+
36
+ if s.respond_to? :specification_version then
37
+ s.specification_version = 4
38
+
39
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
40
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
41
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
42
+ else
43
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
44
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
45
+ end
46
+ else
47
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
48
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
49
+ end
50
+ end
51
+
data/lib/fdist.rb ADDED
@@ -0,0 +1,70 @@
1
+ require 'mathn'
2
+
3
+ module Headers
4
+
5
+ def headers
6
+ begin
7
+ [0].keys
8
+ rescue
9
+ nil
10
+ end
11
+ end
12
+
13
+ def headers= param_list
14
+ if first.class != Hash
15
+ map! do |val_set|
16
+
17
+
18
+ hash = {}
19
+ arrayify(val_set).each_with_index do |elem, idx|
20
+ hash[param_list[idx += 1]] = elem
21
+ end
22
+ hash
23
+ end
24
+ end
25
+ map! do |val_hash|
26
+ redo_headers(val_hash, param_list)
27
+ end
28
+ param_list
29
+ end
30
+
31
+ private
32
+
33
+ def redo_headers old_hash, new_headers
34
+ new_hash = {}
35
+ new_headers.each_with_index do |new_header,idx|
36
+ new_hash[new_header] = old_hash.values[idx]
37
+ end
38
+ new_hash
39
+ end
40
+
41
+ def arrayify thing
42
+ begin
43
+ thing.values
44
+ rescue
45
+ thing.strip.split ","
46
+ rescue
47
+ thing
48
+ end
49
+ end
50
+ end
51
+
52
+
53
+ module Frequency
54
+
55
+ def freq &expression
56
+ Rational.instance_eval("#{count(&expression)}/#{length}")
57
+ end
58
+
59
+ def fdist
60
+ hash = {}
61
+ uniq.each do |el| hash[el] = count(el) end
62
+ hash
63
+ end
64
+
65
+ end
66
+
67
+ class Array
68
+ include Frequency
69
+ include Headers
70
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fdist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - michael d. towle
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jeweler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.7
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.7
41
+ description: Array methods now include :freq and :fdist, the first of which returns
42
+ a Rational, and the second of which returns a hash of expression => count pairs
43
+ email: gametheoretic@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files:
47
+ - LICENSE.txt
48
+ - README.rdoc
49
+ files:
50
+ - .document
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.rdoc
55
+ - Rakefile
56
+ - VERSION
57
+ - fdist.gemspec
58
+ - lib/fdist.rb
59
+ homepage: http://github.com/gametheoretic/fdist
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: quickie add-ons to the Array class
83
+ test_files: []