piece 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-version +1 -0
- data/.travis.yml +26 -0
- data/Gemfile +4 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/piece/pieces.rb +36 -0
- data/lib/piece/version.rb +3 -0
- data/lib/piece.rb +11 -0
- data/piece.gemspec +24 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6a32b1e236bdb20a821224472acb68f2252731dd
|
4
|
+
data.tar.gz: f90826f899d653027275792b73a1c5635341c305
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b21a4f0be7d3ea735e6eae5d0a46755fbc38c66ecb0190aa09f14b7b796dfedbf39d2438197c736106bd220da0e1862324eedecec830825e61312f4db00cf47
|
7
|
+
data.tar.gz: 4ccfaebcac23f6bd4f61f88d50cc48c97e73265f175138d0d267d652486f937b68b3bb024fefb353ff7175c5317fc77171f4aeb67d638d6cabf2398fa74593bd
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.1
|
data/.travis.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
4
|
+
gemfile:
|
5
|
+
- Gemfile
|
6
|
+
- Gemfile.rack-1.3.x
|
7
|
+
language: ruby
|
8
|
+
rvm:
|
9
|
+
# - 1.8.7
|
10
|
+
- 1.9.3
|
11
|
+
- 2.0.0
|
12
|
+
- 2.1
|
13
|
+
- 2.2.1
|
14
|
+
# - jruby-18mode
|
15
|
+
- jruby-19mode
|
16
|
+
- jruby-head
|
17
|
+
- rbx-2
|
18
|
+
- ruby-head
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: jruby-head
|
22
|
+
- rvm: rbx-2
|
23
|
+
- rvm: ruby-head
|
24
|
+
fast_finish: true
|
25
|
+
sudo: false
|
26
|
+
before_install: gem install bundler -v 1.10.2
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Piece [![Build Status](https://snap-ci.com/ThoughtWorksStudios/piece/branch/master/build_image)](https://snap-ci.com/ThoughtWorksStudios/piece/branch/master) [![Build Status](https://travis-ci.org/ThoughtWorksStudios/piece.svg?branch=master)](https://travis-ci.org/ThoughtWorksStudios/piece)
|
2
|
+
|
3
|
+
[Built with :yellow_heart: and :coffee: in San Francisco](http://thoughtworks.com/mingle/team)
|
4
|
+
|
5
|
+
User privileges and feature toggles
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'piece'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install piece
|
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 false` 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]/piece.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "piece"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/piece/pieces.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
module Piece
|
3
|
+
class Pieces
|
4
|
+
def initialize(data)
|
5
|
+
@data = data
|
6
|
+
end
|
7
|
+
|
8
|
+
def has?(key)
|
9
|
+
!!get(@data, parts(key))
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](key)
|
13
|
+
get(@data, parts(key))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def parts(key)
|
18
|
+
key.split(':')
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(data, keys)
|
22
|
+
return data.nil? ? nil : Array(data) if keys.empty?
|
23
|
+
|
24
|
+
case data
|
25
|
+
when Hash
|
26
|
+
get(data[keys.shift], keys)
|
27
|
+
when Array
|
28
|
+
'*' if data.include?('*') || data.include?(keys.shift)
|
29
|
+
when NilClass
|
30
|
+
nil
|
31
|
+
else
|
32
|
+
get([data], keys)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/piece.rb
ADDED
data/piece.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'piece/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "piece"
|
8
|
+
spec.version = Piece::VERSION
|
9
|
+
spec.authors = ["Xiao Li"]
|
10
|
+
spec.email = ["swing1979@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{User privileges and feature toggle}
|
13
|
+
spec.description = %q{It's time to make it simpler}
|
14
|
+
spec.homepage = "https://github.com/ThoughtWorksStudios/piece"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "test-unit", "~> 3.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: piece
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Xiao Li
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-02 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.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: It's time to make it simpler
|
56
|
+
email:
|
57
|
+
- swing1979@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".ruby-version"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/piece.rb
|
71
|
+
- lib/piece/pieces.rb
|
72
|
+
- lib/piece/version.rb
|
73
|
+
- piece.gemspec
|
74
|
+
homepage: https://github.com/ThoughtWorksStudios/piece
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.5
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: User privileges and feature toggle
|
97
|
+
test_files: []
|