qi 3.0.0

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: f86240fea64da5950164c94462e9a50b100f040a
4
+ data.tar.gz: 5bda28f399b21e2a486f3e3bfb88a1423ca2d273
5
+ SHA512:
6
+ metadata.gz: 247e75d1e1060f34fe9a32b408e623d32808e8756f2e76726ab3b9ab30a6cad139e2cbfae5574dfa6adfb07b1cf926b245fc963711e19b94b508ccfd6c0d0185
7
+ data.tar.gz: 1ed3dfb76f1827883f7f9476f0e23307508bcc35fb45575118eb671b6f37cf7ef17565d8d4a15d3d27a4278235a3cbe6883a9e712348bb7d666cf2a8f1304f0d
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.ruby-version
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ script: 'bundle exec rake test:coverage --trace'
5
+ before_install:
6
+ - gem install bundler
7
+ rvm:
8
+ - 1.9.3
9
+ - 2.0
10
+ - 2.1
11
+ - 2.2
12
+ - ruby-head
13
+ - jruby
14
+ - jruby-head
15
+ - rbx-2
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ - README.md
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Cyril Wack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Qi
2
+
3
+ [![Build Status](https://travis-ci.org/cyril/qi.svg?branch=master)][travis]
4
+ [![Gem Version](https://badge.fury.io/rb/qi.svg)][gem]
5
+ [![Inline docs](http://inch-ci.org/github/cyril/qi.svg?branch=master)][inchpages]
6
+ [![Documentation](http://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
7
+
8
+ > An ordered store to collect symbols for Ruby.
9
+
10
+ ## Rubies
11
+
12
+ * [MRI](https://www.ruby-lang.org/)
13
+ * [Rubinius](http://rubini.us/)
14
+ * [JRuby](http://jruby.org/)
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'qi'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install qi
29
+
30
+ ## Example
31
+
32
+ ```ruby
33
+ require 'qi'
34
+
35
+ db = Qi::Store.new(8) # => #<Qi::Store:0x007f8c0a82f300 @cells=[nil, nil, nil, nil, nil, nil, nil, nil]>
36
+
37
+ result = db.call(2, 3, '♙'.to_sym) # => #<Qi::Result:0x007ff3539d71e8 @store=#<Qi::Store:0x007ff3539d7238 @cells=[nil, nil, nil, :♙, nil, nil, nil, nil]>, @deleted_content=nil>
38
+ result.store.cells # => [nil, nil, nil, :♙, nil, nil, nil, nil]
39
+ result.deleted_content # => nil
40
+ ```
41
+
42
+ ## Versioning
43
+
44
+ __Qi__ follows [Semantic Versioning 2.0](http://semver.org/).
45
+
46
+ ## Contributing
47
+
48
+ 1. [Fork it](https://github.com/sashite/qi/fork)
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
53
+
54
+ ## License
55
+
56
+ See `LICENSE.md` file.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'rubocop/rake_task'
4
+
5
+ RuboCop::RakeTask.new
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.verbose = true
9
+ t.warning = true
10
+ t.pattern = File.join('fix', '**', '*_fix.rb')
11
+ end
12
+
13
+ namespace :test do
14
+ task :coverage do
15
+ ENV['COVERAGE'] = 'true'
16
+ Rake::Task['test'].invoke
17
+ end
18
+ end
19
+
20
+ task(:doc_stats) { ruby '-S yard stats' }
21
+ task default: [:test, :doc_stats, :rubocop]
data/VERSION.semver ADDED
@@ -0,0 +1 @@
1
+ 3.0.0
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'qi'
5
+
6
+ require 'irb'
7
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
data/fix/store_fix.rb ADDED
@@ -0,0 +1,30 @@
1
+ require_relative File.join 'support', 'coverage'
2
+ require_relative File.join '..', 'lib', 'qi'
3
+ require 'fix'
4
+
5
+ Fix.describe Qi::Store do
6
+ on :new, 64 do
7
+ on :call, 52, 36, '♙'.to_sym do
8
+ on :store do
9
+ on :cells do
10
+ it do
11
+ MUST eql [
12
+ nil, nil, nil, nil, nil, nil, nil, nil,
13
+ nil, nil, nil, nil, nil, nil, nil, nil,
14
+ nil, nil, nil, nil, nil, nil, nil, nil,
15
+ nil, nil, nil, nil, nil, nil, nil, nil,
16
+ nil, nil, nil, nil, :'♙', nil, nil, nil,
17
+ nil, nil, nil, nil, nil, nil, nil, nil,
18
+ nil, nil, nil, nil, nil, nil, nil, nil,
19
+ nil, nil, nil, nil, nil, nil, nil, nil
20
+ ]
21
+ end
22
+ end
23
+ end
24
+
25
+ on :deleted_content do
26
+ it { MUST be_nil }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start
data/lib/qi.rb ADDED
@@ -0,0 +1,5 @@
1
+ # Namespace for the library.
2
+ module Qi
3
+ end
4
+
5
+ require_relative File.join 'qi', 'store'
data/lib/qi/result.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Qi
2
+ # Result class.
3
+ class Result
4
+ # @param store [Store] Collection of data.
5
+ # @param deleted_content [Symbol, nil] Last deleted content.
6
+ def initialize(store, deleted_content)
7
+ @store = store
8
+ @deleted_content = deleted_content
9
+ end
10
+
11
+ # @!attribute [r] store
12
+ #
13
+ # @return [Store] Collection of data.
14
+ attr_reader :store
15
+
16
+ # @!attribute [r] deleted_content
17
+ #
18
+ # @return [Symbol, nil] Last deleted content.
19
+ attr_reader :deleted_content
20
+ end
21
+ end
data/lib/qi/store.rb ADDED
@@ -0,0 +1,44 @@
1
+ module Qi
2
+ # Main class.
3
+ class Store
4
+ # @param size [Fixnum] The number of cell.
5
+ # @param options [Hash] A content per cell.
6
+ def initialize(size, options = {})
7
+ @cells = Array.new(size)
8
+
9
+ options.each do |cell, piece|
10
+ @cells[cell] = piece
11
+ end
12
+ end
13
+
14
+ # @!attribute [r] cells
15
+ #
16
+ # @return [Array] The cells in the store.
17
+ attr_reader :cells
18
+
19
+ # @param src_cell [Fixnum] Source cell.
20
+ # @param dst_cell [Fixnum] Destination cell.
21
+ # @param content [Symbol] Content.
22
+ #
23
+ # @return [Store] The new store.
24
+ def call(src_cell, dst_cell, content)
25
+ h = contents
26
+ h.delete(src_cell)
27
+ deleted_content = h.delete(dst_cell)
28
+ h[dst_cell] = content
29
+
30
+ new_store = self.class.new(cells.length, h)
31
+
32
+ Result.new(new_store, deleted_content)
33
+ end
34
+
35
+ private
36
+
37
+ # @return [Hash] The contents in the store.
38
+ def contents
39
+ Hash[[*cells.map.with_index]].invert
40
+ end
41
+ end
42
+ end
43
+
44
+ require_relative 'result'
data/pkg_checksum ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'digest/sha2'
4
+
5
+ gemname = :qi
6
+ ARGV[0] = File.read('VERSION.semver').chomp if ARGV[0].nil?
7
+ built_gem_path = "pkg/#{gemname}-#{ARGV[0]}.gem"
8
+ checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
9
+ checksum_path = "checksum/#{gemname}-#{ARGV[0]}.gem.sha512"
10
+
11
+ File.open(checksum_path, 'w') { |f| f.write("#{checksum}\n") }
data/qi.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'qi'
3
+ spec.version = File.read('VERSION.semver').chomp
4
+ spec.authors = ['Cyril Wack']
5
+ spec.email = ['contact@cyril.email']
6
+
7
+ spec.summary = 'Store collections of ordered symbol.'
8
+ spec.description = 'An ordered store to collect symbols for Ruby.'
9
+ spec.homepage = 'https://github.com/cyril/qi.rb'
10
+ spec.license = 'MIT'
11
+
12
+ spec.files =
13
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
14
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_development_dependency 'bundler', '~> 1.10'
18
+ spec.add_development_dependency 'rake', '~> 10.4'
19
+ spec.add_development_dependency 'yard', '~> 0.8'
20
+ spec.add_development_dependency 'simplecov', '~> 0.10'
21
+ spec.add_development_dependency 'rubocop', '~> 0.34'
22
+ spec.add_development_dependency 'fix', '~> 0.16'
23
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qi
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Cyril Wack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-07 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.34'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.34'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fix
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.16'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.16'
97
+ description: An ordered store to collect symbols for Ruby.
98
+ email:
99
+ - contact@cyril.email
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - ".yardopts"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.md
110
+ - README.md
111
+ - Rakefile
112
+ - VERSION.semver
113
+ - bin/console
114
+ - bin/setup
115
+ - fix/store_fix.rb
116
+ - fix/support/coverage.rb
117
+ - lib/qi.rb
118
+ - lib/qi/result.rb
119
+ - lib/qi/store.rb
120
+ - pkg_checksum
121
+ - qi.gemspec
122
+ homepage: https://github.com/cyril/qi.rb
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.4.5.1
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Store collections of ordered symbol.
146
+ test_files: []
147
+ has_rdoc: