progne_tapera 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.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/CHANGELOG +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/lib/progne_tapera.rb +11 -0
- data/lib/progne_tapera/enum_code.rb +25 -0
- data/lib/progne_tapera/enum_config.rb +25 -0
- data/lib/progne_tapera/enum_item.rb +42 -0
- data/lib/progne_tapera/enum_list.rb +77 -0
- data/lib/progne_tapera/version.rb +3 -0
- data/progne_tapera.gemspec +26 -0
- data/spec/progne_tapera/enum_item_spec.rb +35 -0
- data/spec/progne_tapera/enum_list_spec.rb +113 -0
- data/spec/spec_helper.rb +103 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fd661dd328a0cca1b2cbe396620e0fdcf890cced
|
4
|
+
data.tar.gz: 392c0a5cdd3b5dce2eaf38c0eac3a01c747de6e5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22d0667f8df930b057ac45c28af5a0b27eb0c0835e70e2e30a108bbcfce347591a03a6e8e153d7e3f0e6d41f5e5d8da67a01d2f6d10a461a8460a52fc284a35f
|
7
|
+
data.tar.gz: 8d0f4d43dac0fe24fe10b50362a8de3ff1956dfa0af233b8ffa79ba9ec59bf643b7209ef8e7b08ce21963776762b913566adb801372d2bc4517249a0fc7b6865
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Version 0.0.1: The initial EnumListing module and EnumItem class is released.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Du Hengfeng
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# ProgneTapera
|
2
|
+
|
3
|
+
Progne Tapera is a Rails-based configurable enumeration implementation. Progne Tapera is the Brown-chested Martin in Latin.
|
4
|
+
Progne Tapera 是基于 Rails 的可配置的枚举实现。Progne Tapera 是棕胸崖燕的拉丁学名。
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'progne_tapera'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install progne_tapera
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
TODO: Write usage instructions here
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/[my-github-username]/progne_tapera/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module ProgneTapera::EnumCode
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do |includer|
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
def code(field, enum)
|
11
|
+
code_field_name = :"#{field}_code"
|
12
|
+
validates code_field_name, inclusion: enum.all.map { |item| item.code }
|
13
|
+
instance_eval do
|
14
|
+
define_method field do
|
15
|
+
enum.select { |item| item.code==send(code_field_name.to_sym) }.first
|
16
|
+
end
|
17
|
+
define_method "#{field}=" do |value|
|
18
|
+
send "#{code_field_name}=".to_sym, value.code
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ProgneTapera::EnumConfig
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include ProgneTapera::EnumList
|
5
|
+
|
6
|
+
included do |includer|
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def enum(name = nil)
|
12
|
+
name = enum_name(name).to_s
|
13
|
+
enumerations = Rails.configuration.enum[name]
|
14
|
+
raise ArgumentError.new "The enum.#{name} was not configured in the config/enum.yml file." if enumerations.blank?
|
15
|
+
enumerations.each do |key, value|
|
16
|
+
options = value.map { |k, v| [ k.to_sym, v ] }.to_h
|
17
|
+
code = options.delete :code
|
18
|
+
options[:localized_name] = I18n.t "enum.#{name}.#{key}"
|
19
|
+
safe_add_item ProgneTapera::EnumItem.new(code, key, options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
class ProgneTapera::EnumItem
|
4
|
+
|
5
|
+
attr_reader :code, :name
|
6
|
+
|
7
|
+
# code = HA (value)
|
8
|
+
# name = han
|
9
|
+
# options = { localized_name: '汉' }
|
10
|
+
# -> constant: HAN
|
11
|
+
def initialize(code, name, options = {})
|
12
|
+
|
13
|
+
raise ArgumentError.new 'The code argument is required.' if code.blank?
|
14
|
+
raise ArgumentError.new 'The name argument is required.' if name.blank?
|
15
|
+
|
16
|
+
@code = code
|
17
|
+
@name = name
|
18
|
+
@options = options
|
19
|
+
|
20
|
+
@options.each do |key, value|
|
21
|
+
class_eval do
|
22
|
+
define_method(key.to_sym) do
|
23
|
+
value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def ==(that)
|
31
|
+
self.code==that.code
|
32
|
+
end
|
33
|
+
|
34
|
+
def <=>(that)
|
35
|
+
self.code<=>that.code
|
36
|
+
end
|
37
|
+
|
38
|
+
def constant_name
|
39
|
+
name.to_s.upcase
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module ProgneTapera::EnumList
|
4
|
+
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do |includer|
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
# Define the Enum type
|
15
|
+
def enum_name(name = nil)
|
16
|
+
return @enum_name if @enum_name.present?
|
17
|
+
@enum_name = (name||self.name.demodulize.underscore).to_sym
|
18
|
+
end
|
19
|
+
|
20
|
+
# Define the Enum Items
|
21
|
+
def item_defined?(item)
|
22
|
+
const_defined? item.constant_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_item(item)
|
26
|
+
raise ArgumentError.new "The #{item.inspect} item should be an instance of ProgneTapera::EnumItem." unless item.is_a? ProgneTapera::EnumItem
|
27
|
+
raise ArgumentError.new "The #{item.constant_name} enum item was defined already." if item_defined? item
|
28
|
+
|
29
|
+
item_methods_module = "#{self.name}::ItemMethods".safe_constantize
|
30
|
+
item.class.include item_methods_module if item_methods_module.present?
|
31
|
+
|
32
|
+
const_set item.constant_name, item
|
33
|
+
end
|
34
|
+
|
35
|
+
def safe_add_item(item)
|
36
|
+
const_set item.constant_name, item if item.is_a?(ProgneTapera::EnumItem)&&!item_defined?(item)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Infrastructure for the Enumerable
|
40
|
+
def enum_constants
|
41
|
+
constants.select { |constant|
|
42
|
+
value = const_get constant
|
43
|
+
value.is_a? ProgneTapera::EnumItem
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def all
|
48
|
+
enum_constants.map { |constant| const_get constant }
|
49
|
+
end
|
50
|
+
|
51
|
+
def selected
|
52
|
+
block_given? ? yield(all) : all
|
53
|
+
end
|
54
|
+
|
55
|
+
# Enumerable
|
56
|
+
def each(&block)
|
57
|
+
all.each &block
|
58
|
+
end
|
59
|
+
|
60
|
+
# Form Option
|
61
|
+
def form_options(&block)
|
62
|
+
items = block_given? ? selected(&block) : selected
|
63
|
+
items.map { |item| [ item.localized_name, item.code ] }.to_h
|
64
|
+
end
|
65
|
+
|
66
|
+
# ActiveRecord::Type::Value
|
67
|
+
def deserialize(value)
|
68
|
+
select { |item| item.code==value }
|
69
|
+
end
|
70
|
+
|
71
|
+
def serialize(value)
|
72
|
+
value.respond_to?(:code) ? value.code : value
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'progne_tapera/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "progne_tapera"
|
8
|
+
spec.version = ProgneTapera::VERSION
|
9
|
+
spec.authors = ["Du Hengfeng"]
|
10
|
+
spec.email = ["topbit.du@gmail.com"]
|
11
|
+
spec.summary = %q{A configurable enumeration for Ruby.}
|
12
|
+
spec.description = %q{Progne Tapera is another enum implementation for Ruby. It focuses on configurable enumeration.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rails", "~> 5.0"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 11.3"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'progne_tapera'
|
3
|
+
|
4
|
+
describe ProgneTapera::EnumItem do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
@ethnicity_item = described_class.new 'HA', :han, localized_name: '汉', numeric_code: '01'
|
8
|
+
@gender_item = described_class.new '1', :male, localized_name: '男'
|
9
|
+
@algorithm_item = described_class.new 'AES8', :aes_256, localized_name: 'AES-256', digits: 256
|
10
|
+
end
|
11
|
+
|
12
|
+
after :each do
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have constant name' do
|
16
|
+
expect(@ethnicity_item.constant_name).to eq('HAN')
|
17
|
+
expect(@gender_item.constant_name).to eq('MALE')
|
18
|
+
expect(@algorithm_item.constant_name).to eq('AES_256')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have localized name' do
|
22
|
+
expect(@ethnicity_item.localized_name).to eq('汉')
|
23
|
+
expect(@gender_item.localized_name).to eq('男')
|
24
|
+
expect(@algorithm_item.localized_name).to eq('AES-256')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have digits' do
|
28
|
+
expect(@algorithm_item.digits).to eq(256)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have numeric code' do
|
32
|
+
expect(@ethnicity_item.numeric_code).to eq('01')
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'progne_tapera'
|
3
|
+
|
4
|
+
describe ProgneTapera::EnumList do
|
5
|
+
|
6
|
+
let :subject do
|
7
|
+
class GenderEnum
|
8
|
+
include ProgneTapera::EnumList
|
9
|
+
module ItemMethods
|
10
|
+
def hello(name)
|
11
|
+
case code
|
12
|
+
when '1' then "#{name}先生"
|
13
|
+
when '2' then "#{name}女士"
|
14
|
+
else name.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
GenderEnum
|
20
|
+
end
|
21
|
+
|
22
|
+
let :male do ProgneTapera::EnumItem.new '1', :male, localized_name: '男' end
|
23
|
+
let :female do ProgneTapera::EnumItem.new '2', :female, localized_name: '女' end
|
24
|
+
let :not_specified do ProgneTapera::EnumItem.new '9', :not_specified, localized_name: '未指定' end
|
25
|
+
|
26
|
+
before :each do
|
27
|
+
subject.add_item male unless subject.item_defined? male
|
28
|
+
subject.add_item female unless subject.item_defined? female
|
29
|
+
subject.add_item not_specified unless subject.item_defined? not_specified
|
30
|
+
end
|
31
|
+
|
32
|
+
after :each do
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have enum name' do
|
36
|
+
expect(subject.enum_name).to eq(:gender_enum)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should respond to each' do
|
40
|
+
expect(subject).to respond_to(:each)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should respond to map' do
|
44
|
+
expect(subject).to respond_to(:map)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should be able to count' do
|
48
|
+
expect(subject).to respond_to(:count)
|
49
|
+
expect(subject.count).to eq(3)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should reject duplicate item' do
|
53
|
+
expect { subject.add_item male }.to raise_error(ArgumentError)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should reject wrong type' do
|
57
|
+
expect { subject.add_item 'MALE' }.to raise_error(ArgumentError)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should be able to add item safely' do
|
61
|
+
expect(subject.count).to eq(3)
|
62
|
+
subject.safe_add_item male
|
63
|
+
expect(subject.count).to eq(3)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have all' do
|
67
|
+
gender_enums = GenderEnum.all
|
68
|
+
|
69
|
+
expect(gender_enums).to be_present
|
70
|
+
expect(gender_enums.count).to eq(3)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should have selected' do
|
74
|
+
gender_enums = GenderEnum.selected
|
75
|
+
|
76
|
+
expect(gender_enums).to be_present
|
77
|
+
expect(gender_enums.count).to eq(3)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should have customized selected' do
|
81
|
+
gender_enums = GenderEnum.selected do |items| items.select { |item| ['1', '2'].include? item.code } end
|
82
|
+
|
83
|
+
expect(gender_enums).to be_present
|
84
|
+
expect(gender_enums.count).to eq(2)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should have form options' do
|
88
|
+
options = GenderEnum.form_options
|
89
|
+
|
90
|
+
expect(options).to be_present
|
91
|
+
expect(options.size).to eq(3)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should have customized form options' do
|
95
|
+
options = GenderEnum.form_options do |items| items.select { |item| ['1', '2'].include? item.code } end
|
96
|
+
|
97
|
+
expect(options).to be_present
|
98
|
+
expect(options.size).to eq(2)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should hello to male' do
|
102
|
+
expect(GenderEnum::MALE.hello 'Wu').to eq('Wu先生')
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should hello to female' do
|
106
|
+
expect(GenderEnum::FEMALE.hello 'Wu').to eq('Wu女士')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should hello to not specified' do
|
110
|
+
expect(GenderEnum::NOT_SPECIFIED.hello 'Wu').to eq('Wu')
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
44
|
+
# have no way to turn it off -- the option exists only for backwards
|
45
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
46
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
47
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
=begin
|
53
|
+
# This allows you to limit a spec run to individual examples or groups
|
54
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
55
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
+
config.filter_run_when_matching :focus
|
59
|
+
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# you configure your source control system to ignore this file.
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# recommended. For more details, see:
|
67
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
+
config.disable_monkey_patching!
|
71
|
+
|
72
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
73
|
+
# be too noisy due to issues in dependencies.
|
74
|
+
config.warnings = true
|
75
|
+
|
76
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
77
|
+
# file, and it's useful to allow more verbose output when running an
|
78
|
+
# individual spec file.
|
79
|
+
if config.files_to_run.one?
|
80
|
+
# Use the documentation formatter for detailed output,
|
81
|
+
# unless a formatter has already been configured
|
82
|
+
# (e.g. via a command-line flag).
|
83
|
+
config.default_formatter = 'doc'
|
84
|
+
end
|
85
|
+
|
86
|
+
# Print the 10 slowest examples and example groups at the
|
87
|
+
# end of the spec run, to help surface which specs are running
|
88
|
+
# particularly slow.
|
89
|
+
config.profile_examples = 10
|
90
|
+
|
91
|
+
# Run specs in random order to surface order dependencies. If you find an
|
92
|
+
# order dependency and want to debug it, you can fix the order by providing
|
93
|
+
# the seed, which is printed after each run.
|
94
|
+
# --seed 1234
|
95
|
+
config.order = :random
|
96
|
+
|
97
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
98
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
99
|
+
# test failures related to randomization by passing the same `--seed` value
|
100
|
+
# as the one that triggered the failure.
|
101
|
+
Kernel.srand config.seed
|
102
|
+
=end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: progne_tapera
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Du Hengfeng
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.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.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.5'
|
69
|
+
description: Progne Tapera is another enum implementation for Ruby. It focuses on
|
70
|
+
configurable enumeration.
|
71
|
+
email:
|
72
|
+
- topbit.du@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- CHANGELOG
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/progne_tapera.rb
|
85
|
+
- lib/progne_tapera/enum_code.rb
|
86
|
+
- lib/progne_tapera/enum_config.rb
|
87
|
+
- lib/progne_tapera/enum_item.rb
|
88
|
+
- lib/progne_tapera/enum_list.rb
|
89
|
+
- lib/progne_tapera/version.rb
|
90
|
+
- progne_tapera.gemspec
|
91
|
+
- spec/progne_tapera/enum_item_spec.rb
|
92
|
+
- spec/progne_tapera/enum_list_spec.rb
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
homepage: ''
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.6.4
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: A configurable enumeration for Ruby.
|
118
|
+
test_files:
|
119
|
+
- spec/progne_tapera/enum_item_spec.rb
|
120
|
+
- spec/progne_tapera/enum_list_spec.rb
|
121
|
+
- spec/spec_helper.rb
|