chansu 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f4ba8ed2317017e71a0eb192f19947a7792fcb6eb43eb12107a803d69d7a62b
4
- data.tar.gz: 88b4ad19c077b7d43b3a87f72ab4ccc35fc566d02e14fd7f5eca26d28904d8b6
3
+ metadata.gz: 367057f628d86ce66226f7997bafbeb9ab8d858cacc9aa1fd8f70afcbe60e9d6
4
+ data.tar.gz: 4fc96d800011066f267f1c377c80c3a171068f7302e8164c666492e78d8dff45
5
5
  SHA512:
6
- metadata.gz: 67558f2e8bb41692107016f049488e0b4e417f2f84aac4fba67837f7165528b4711998f8a99a35319fea898f46799e7f12f876291f1a72e3792f8a01ce90698d
7
- data.tar.gz: 491b9dd2d5ec2a1566febfc4a3a87a98f53d7bfd1f10c7c9fc267fd71e5901c64e44f3000646ee278e50ffb1cc8adf4b48f6f37c4e4f79ebbaa05cb1ab96c324
6
+ metadata.gz: 51d3a8fe17e2936802cd60a9bbde6ad961a74b8554f5754c27bff48bd05006be0f953c6e24cd88b299fa0fb979330c113db5bfc2603081a0d74b8a9c6030c53a
7
+ data.tar.gz: 144b2fd17763d88ab025ea9092c05d9d54bf82f9037befcf38c1d474bda4c160ab7439513ca7ba0179ae4a20a0a8d22aedba5dc9d9b0b0f19c4aebfa67069a0a
data/README.md CHANGED
@@ -1,43 +1,118 @@
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.
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 the created tag, 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]/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).
38
+ ## đŸ› ī¸ Usage
39
+ ### Probability DSL
40
+ ```ruby
41
+ require "chansu"
36
42
 
37
- ## License
43
+ probably { puts "Hello, world!" } # ~60% chance
44
+ rarely { puts "Surprise!" } # ~10% chance
45
+ always { puts "Guaranteed!" } # 100%
46
+ ```
38
47
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+ ### DSL Reference Table
49
+ | Method | Probability | Example |
50
+ |-------------------------|-------------|-----------------------------------------------|
51
+ | `always` | 100% | `always { puts "Guaranteed!" }` |
52
+ | `certainly` | 90% | `certainly { puts "Very likely" }` |
53
+ | `almost_always` | 85% | `almost_always { puts "Pretty often" }` |
54
+ | `usually` | 80% | `usually { puts "Most of the time" }` |
55
+ | `often` | 75% | `often { puts "Happens often" }` |
56
+ | `likely` | 70% | `likely { puts "Quite probable" }` |
57
+ | `frequently` | 65% | `frequently { puts "Fairly frequent" }` |
58
+ | `probably` | 60% | `probably { puts "More often than not" }` |
59
+ | `more_often_than_not` | 60% | `more_often_than_not { puts "Similar to probably" }` |
60
+ | `maybe` | 50% | `maybe { puts "Flip a coin" }` |
61
+ | `possibly` | 40% | `possibly { puts "Could happen" }` |
62
+ | `not_often` | 35% | `not_often { puts "Less common" }` |
63
+ | `unlikely` | 25% | `unlikely { puts "Not very likely" }` |
64
+ | `with_low_probability` | 15% | `with_low_probability { puts "Long shot" }` |
65
+ | `rarely` | 10% | `rarely { puts "Almost never" }` |
66
+ | `never` | ~0% 😉 | `never { puts "Basically never" }` |
67
+
68
+
69
+ ### Dice Rolls
70
+ ```ruby
71
+ require "chansu"
72
+
73
+ dice # 2
74
+ dice(42) # 31
75
+ dice(15, 3) # [15, 9, 15]
76
+ d6 # 6
77
+ d20 # 11
78
+ d100 # 90
79
+ dice("2d10") # {:rolls=>[9, 5], :total=>14}
80
+ dice("3d8+5") # {:rolls=>[3, 3, 4], :total=>15}
81
+ ```
82
+ ---
83
+ ## âš™ī¸ Config
84
+ ### Controlling globals
85
+ By default, all DSL methods are available globally
86
+ If you want to remove them from your global namespace, disable them with:
87
+ ```ruby
88
+ Chansu.disable_globals!
89
+ ```
90
+ And include them in your own modules/classes:
91
+ ```ruby
92
+ class MyClass
93
+ include Chansu
94
+ end
95
+ ```
96
+ ---
97
+ ## đŸ“Ļ Development
98
+ Clone and install dependencies:
99
+ ```bash
100
+ bundle install
101
+ ```
102
+ Run tests
103
+ ```bash
104
+ rake test
105
+ ```
106
+ Build gem
107
+ ```
108
+ gem build
109
+ ```
110
+ ---
111
+ ## 🤝 Contributing
40
112
 
41
- ## Code of Conduct
113
+ Bug reports and pull requests are welcome on GitHub at https://github.com/escalderong/chansu
114
+ Feel free to suggest new probability words, dice, or randomness helpers!
42
115
 
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).
116
+ ---
117
+ ## 📜 License
118
+ The gem is available as open source under the terms of the MIT License.
data/chansu-0.1.0.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.1'
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Santiago Calderon
@@ -29,6 +29,7 @@ files:
29
29
  - LICENSE.txt
30
30
  - README.md
31
31
  - Rakefile
32
+ - chansu-0.1.0.gem
32
33
  - lib/chansu.rb
33
34
  - lib/chansu/dsl.rb
34
35
  - lib/chansu/loops.rb