Skip to content

Commit 59e26bc

Browse files
committed
Updates readme and docs, Bumping version to 0.2.0.
1 parent 754d2a8 commit 59e26bc

File tree

3 files changed

+61
-57
lines changed

3 files changed

+61
-57
lines changed

README.md

+59-45
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# can_use
22

3-
🤔 Can I use this feature? Yes, sure!
3+
🤔Can I use this feature? Hmm, let me see.
44

55
> CanUse is a minimalist feature toggle/flag for crystal, based on yaml file.
66
7-
[![GitHub release](https://img.shields.io/github/release/rodrigopinto/can_use.svg)](https://github.com/rodrigopinto/can_use/releases)
8-
9-
[![Build Status](https://travis-ci.org/rodrigopinto/can_use.svg?branch=master)](https://travis-ci.org/rodrigopinto/can_use)
7+
[![GitHub release](https://img.shields.io/github/release/rodrigopinto/can_use.svg)](https://github.com/rodrigopinto/can_use/releases) [![Build Status](https://travis-ci.org/rodrigopinto/can_use.svg?branch=master)](https://travis-ci.org/rodrigopinto/can_use)
108

119
## Installation
1210

@@ -21,73 +19,91 @@ dependencies:
2119

2220
## Usage
2321

24-
2522
1. Require the library on your code base.
2623

27-
```crystal
28-
require "can_use"
29-
```
24+
```crystal
25+
require "can_use"
26+
```
3027

3128
2. Create a file with the features toggle definitions.
3229
We suggest to name it as `featutes.yaml`, but it is up to you.
3330

3431
**Note:** The `defaults` block is mandatory, as it will be used as fallback when values are not defined on the environment set on `configuration`. Example:
3532

36-
```yaml
37-
defaults:
38-
new_payment_flow: false
39-
rating_service: false
33+
```yaml
34+
defaults:
35+
new_payment_flow: false
36+
rating_service: false
4037
41-
development:
42-
new_payment_flow: true
43-
rating_service: false
38+
development:
39+
new_payment_flow: true
40+
rating_service: false
4441
45-
your_environment:
46-
new_payment_flow: true
47-
```
42+
your_environment:
43+
new_payment_flow: true
44+
```
4845

4946
3. Configure the environment and the path to the yaml.
5047

51-
```crystal
52-
CanUse.configure do |config|
53-
config.file = "path/to/features.yaml"
54-
config.environment = "your_environment"
55-
end
56-
```
48+
```crystal
49+
CanUse.configure do |config|
50+
config.file = "path/to/features.yaml"
51+
config.environment = "your_environment"
52+
end
53+
```
5754

5855
4. Verify if a feature is toggled on/off
5956

60-
```crystal
61-
if CanUse.feature?("new_payment_flow")
62-
# do_something
63-
end
64-
```
57+
```crystal
58+
if CanUse.feature?("new_payment_flow")
59+
# do_something
60+
end
61+
```
62+
63+
5. Enabling or Disabling a feature is simple as
64+
65+
> Enabling
66+
67+
```crystal
68+
CanUse.feature?("feature_a") # => false
69+
70+
CanUse.enable("feature_a") # => true
71+
72+
CanUse.feature?("feature_a") # => true
73+
```
74+
75+
> Disabling
76+
77+
```crystal
78+
CanUse.feature?("feature_b") # => true
6579
80+
CanUse.disable("feature_b") # => false
81+
82+
CanUse.feature?("feature_b") # => false
83+
```
6684

6785
## Development
6886

6987
1. Install the dependencies.
7088

71-
```bash
72-
$ shards install
73-
```
89+
```bash
90+
$ shards install
91+
```
7492

7593
2. Implement and test your changes.
7694

77-
```bash
78-
$ crystal spec
79-
```
80-
95+
```bash
96+
$ crystal spec
97+
```
8198

8299
3. Run fomart tool to verify code style.
83100

84-
```bash
85-
$ crystal tool format
86-
```
101+
```bash
102+
$ crystal tool format
103+
```
87104

88105
## TODO
89106

90-
- [ ] Add ability to toggle on/off a feature programatically, ex: `CanUse.enable("feature")`.
91107
- [ ] Allows ENVIRONMENT variables to set/override a value for a key.
92108

93109
## Contributing
@@ -98,12 +114,10 @@ We suggest to name it as `featutes.yaml`, but it is up to you.
98114
4. Push to the branch (`git push origin my-new-feature`)
99115
5. Create a new Pull Request
100116

101-
## Credits
102-
103-
This shard was initially inspired by [can_do][1] (Ruby).
104-
105117
## Contributors
106118

107119
- [Rodrigo Pinto](https://github.com/rodrigopinto) - creator and maintainer
108120

109-
[1]: https://github.com/blacklane/can_do
121+
## Credits
122+
123+
This shard was initially inspired by [can_do](https://github.com/blacklane/can_do).

shard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: can_use
2-
version: 0.0.1
2+
version: 0.2.0
33

44
authors:
55
- Rodrigo Pinto <contato@rodrigopinto.me>

src/can_use.cr

+1-11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ require "yaml"
22

33
# CanUse is a minimalist feature toggle for Crystal.
44
module CanUse
5-
VERSION = "0.1.0"
5+
VERSION = "0.2.0"
66

77
@@features = Hash(YAML::Any, YAML::Any).new
88
@@config = Config.new
99

1010
# Sets the configuration for `CanUse`
1111
#
12-
# ### Example
13-
#
1412
# ```
1513
# CanUse.configure do |config|
1614
# config.environment = "development"
@@ -25,8 +23,6 @@ module CanUse
2523
# Returns `true` or `false` based on the feature configuration.
2624
# Otherwise, reads from the default value.
2725
#
28-
# ### Example
29-
#
3026
# ```
3127
# if CanUse.feature?("feature_one")
3228
# # do_something
@@ -40,8 +36,6 @@ module CanUse
4036

4137
# Evaluates the block if the feature returns `true`..
4238
#
43-
# ### Example
44-
#
4539
# ```
4640
# CanUse.feature?("feature_one") do
4741
# puts "Yeah, I cam use!"
@@ -55,8 +49,6 @@ module CanUse
5549

5650
# Enables the feature and returns `true`.
5751
#
58-
# ### Example
59-
#
6052
# ```
6153
# CanUse.enable("feature_three") # => true
6254
# ```
@@ -66,8 +58,6 @@ module CanUse
6658

6759
# Disables the feature and returns `false`.
6860
#
69-
# ### Example
70-
#
7161
# ```
7262
# CanUse.disable("feature_two") # => false
7363
# ```

0 commit comments

Comments
 (0)