chansu 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f4ba8ed2317017e71a0eb192f19947a7792fcb6eb43eb12107a803d69d7a62b
4
- data.tar.gz: 88b4ad19c077b7d43b3a87f72ab4ccc35fc566d02e14fd7f5eca26d28904d8b6
3
+ metadata.gz: c2bd3a9802f008e4b9045a46bc9025143a67963bbcdf7a587b794e97b0193704
4
+ data.tar.gz: 4ea0f19eca8a4e5fdcd5779e5fa443dc51ede58846254bcce035555253858504
5
5
  SHA512:
6
- metadata.gz: 67558f2e8bb41692107016f049488e0b4e417f2f84aac4fba67837f7165528b4711998f8a99a35319fea898f46799e7f12f876291f1a72e3792f8a01ce90698d
7
- data.tar.gz: 491b9dd2d5ec2a1566febfc4a3a87a98f53d7bfd1f10c7c9fc267fd71e5901c64e44f3000646ee278e50ffb1cc8adf4b48f6f37c4e4f79ebbaa05cb1ab96c324
6
+ metadata.gz: 0b5cfe052b373060bcc1b5a128cf3933b3fdfd641fad9fe5fc87cd5de64820289276c34c4b3a8dae33fd0ffe11c5060217bfb0afcd7f43736436e3f56bb06f9d
7
+ data.tar.gz: a241fb82a1711f896ada8e273a06a49b462b018e092a5455b746d922b420a3f45b4f7a9dece615e75c99dc6fb4c19a5bddaf903d27a715b9be19b90227522d44
data/README.md CHANGED
@@ -1,43 +1,148 @@
1
- # Chansu
1
+ # Chansu 🎲
2
+ *A Ruby gem for probability-driven DSLs and dice rolls.*
2
3
 
3
- TODO: Delete this and the text below, and describe your gem
4
+ **ãƒãƒŖãƒŗã‚š** gives you cool ways to write code with probabilities, dice rolls, and randomness.
5
+ It comes with a natural-language DSL for describing likelihoods (`probably`, `rarely`, `always`, etc.) and utility methods like dice rolls (`d6`, `d20`, â€Ļ).
4
6
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/chansu`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+ ---
6
8
 
7
- ## Installation
9
+ ## ✨ Features
10
+ - 🎲 **Dice rolls**: `d6`, `d20`, `d100` and even ([dice notation](https://en.wikipedia.org/wiki/Dice_notation)).
11
+ - 📊 **Probability DSL**: Write code like:
12
+ ```ruby
13
+ probably { puts "this happens ~60% of the time" }
14
+ rarely { puts "this almost never happens" }
15
+ always { puts "this always happens" }
8
16
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
17
+ - 🌍 **Globally available** by default – no need to include anything. - (Can be disabled with Chansu.disable_globals!)
18
+ - đŸ•šī¸ Useful for games, simulations, generative art, or just spicing up your Ruby scripts.
10
19
 
11
- Install the gem and add to the application's Gemfile by executing:
20
+ ---
12
21
 
13
- ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
- ```
16
-
17
- If bundler is not being used to manage dependencies, install the gem by executing:
22
+ ## 🚀 Installation
18
23
 
19
- ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
24
+ Add this line to your application's Gemfile:
25
+ ```ruby
26
+ gem 'chansu'
21
27
  ```
28
+ Then execute
29
+ ```bash
30
+ bundle install
31
+ ```
32
+ Or just do
33
+ ```bash
34
+ gem install chansu
35
+ ```
36
+ ---
22
37
 
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. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+ ## đŸ› ī¸ Usage
30
39
 
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+ ### Basic chance
41
+ ```ruby
42
+ chance # true/false with 50% chance
43
+ chance(10) # 10% chance
44
+ chance(0.65) # 60% chance
45
+ chance("38%") # 38% chance
46
+ ```
47
+ It also receives a block
48
+ ```ruby
49
+ chance(40) {
50
+ puts "There's a 40% chance this was printed"
51
+ }
52
+ ```
32
53
 
33
- ## Contributing
54
+ ### Loop until probability is met
55
+ You are provided with two methods that take a block and execute it until it either success or fails
56
+ ```ruby
57
+ until_success {
58
+ p "this will be printed until it is successfull!"
59
+ } #returns the number of attempts it took
34
60
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/chansu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/chansu/blob/master/CODE_OF_CONDUCT.md).
61
+ until_failure(chance: 0.1, max_attempts: 25) {
62
+ p "this will be printed until it fails or hits 25 attempts!"
63
+ } #returns the number of attempts it took
64
+ ```
65
+ Keep in mind the arguments work for both methods
66
+ ### Probability DSL
67
+ ```ruby
68
+ require "chansu"
69
+
70
+ probably { puts "Hello, world!" } # ~60% chance
71
+ rarely { puts "Surprise!" } # ~10% chance
72
+ always { puts "Guaranteed!" } # 100%
73
+ ```
36
74
 
37
- ## License
75
+ ### DSL Reference Table
76
+ | Method | Probability | Example |
77
+ |-------------------------|-------------|-----------------------------------------------|
78
+ | `always` | 100% | `always { puts "Guaranteed!" }` |
79
+ | `certainly` | 90% | `certainly { puts "Very likely" }` |
80
+ | `almost_always` | 85% | `almost_always { puts "Pretty often" }` |
81
+ | `usually` | 80% | `usually { puts "Most of the time" }` |
82
+ | `often` | 75% | `often { puts "Happens often" }` |
83
+ | `likely` | 70% | `likely { puts "Quite probable" }` |
84
+ | `frequently` | 65% | `frequently { puts "Fairly frequent" }` |
85
+ | `probably` | 60% | `probably { puts "More often than not" }` |
86
+ | `more_often_than_not` | 60% | `more_often_than_not { puts "Similar to probably" }` |
87
+ | `maybe` | 50% | `maybe { puts "Flip a coin" }` |
88
+ | `possibly` | 40% | `possibly { puts "Could happen" }` |
89
+ | `not_often` | 35% | `not_often { puts "Less common" }` |
90
+ | `unlikely` | 25% | `unlikely { puts "Not very likely" }` |
91
+ | `with_low_probability` | 15% | `with_low_probability { puts "Long shot" }` |
92
+ | `rarely` | 10% | `rarely { puts "Almost never" }` |
93
+ | `never` | ~0% 😉 | `never { puts "Basically never" }` |
94
+
95
+
96
+ ### Dice Rolls
97
+ ```ruby
98
+ require "chansu"
99
+
100
+ coin # :tails or :heads
101
+ dice # 2
102
+ dice(42) # 31
103
+ dice(15, 3) # [15, 9, 15]
104
+ d6 # 6
105
+ d20 # 11
106
+ d100 # 90
107
+ dice("2d10") # {:rolls=>[9, 5], :total=>14}
108
+ dice("3d8+5") # {:rolls=>[3, 3, 4], :total=>15}
109
+ roll # is an alias of dice
110
+ ```
38
111
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
112
+ ---
113
+ ## âš™ī¸ Config
114
+ ### Controlling globals
115
+ By default, all DSL methods are available globally
116
+ If you want to remove them from your global namespace, disable them with:
117
+ ```ruby
118
+ Chansu.disable_globals!
119
+ ```
120
+ And include them in your own modules/classes:
121
+ ```ruby
122
+ class MyClass
123
+ include Chansu
124
+ end
125
+ ```
126
+ ---
127
+ ## đŸ“Ļ Development
128
+ Clone and install dependencies:
129
+ ```bash
130
+ bundle install
131
+ ```
132
+ Run tests
133
+ ```bash
134
+ rake test
135
+ ```
136
+ Build gem
137
+ ```
138
+ gem build
139
+ ```
140
+ ---
141
+ ## 🤝 Contributing
40
142
 
41
- ## Code of Conduct
143
+ Bug reports and pull requests are welcome on GitHub at https://github.com/escalderong/chansu
144
+ Feel free to suggest new probability words, dice, or randomness helpers!
42
145
 
43
- Everyone interacting in the Chansu project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/chansu/blob/master/CODE_OF_CONDUCT.md).
146
+ ---
147
+ ## 📜 License
148
+ The gem is available as open source under the terms of the MIT License.
data/chansu-0.1.0.gem ADDED
Binary file
data/chansu-0.1.1.gem ADDED
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chansu
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chansu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Santiago Calderon
@@ -9,8 +9,8 @@ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
- description: |-
13
- \
12
+ description: |2-
13
+
14
14
  Chansu is a Ruby DSL for working with randomness and probability.
15
15
  It provides helpers like `chance("35%")`, `dice(6, 3)`, and RPG-style
16
16
  aliases such as `d20` and `d100`. It also includes higher-level
@@ -29,6 +29,8 @@ files:
29
29
  - LICENSE.txt
30
30
  - README.md
31
31
  - Rakefile
32
+ - chansu-0.1.0.gem
33
+ - chansu-0.1.1.gem
32
34
  - lib/chansu.rb
33
35
  - lib/chansu/dsl.rb
34
36
  - lib/chansu/loops.rb