codefly 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdf8a7ed23f0e857dcd2c7cf51460b2ecb4ec80d
4
- data.tar.gz: 7101eef0854af60b7496ce6553eb8ebc695c8181
3
+ metadata.gz: c570cc226d705a39be495be7555ea1882fe36b64
4
+ data.tar.gz: e4b747f462ace7008fe64603b8f8d692faa3d339
5
5
  SHA512:
6
- metadata.gz: 0999928e52779c0bca027a1de8f432c1f39b12c2f67a8c9a806b49e4ab9f17728fe9e55d3e8a7f69d3e88c1c3ecdcc145f95afd9f53bb473d0365f032f26aa0d
7
- data.tar.gz: a0373f0823745f21759b5fa1b7b8bb0054e7803cf6104aabe30beca9d7a1932e80b98ea27b1a6a0477536ac6ef1a9a4ad762518d4cc9f97e0e79f8cb5ad46b83
6
+ metadata.gz: 825671fa3341dbcb592ea57fe2db1950fa5a08b767a2c71c0cb855c60290c579aeb9c1cee24f1d3db26f330c1502def20bd342a0add639dc1e25aa0865e7cb3a
7
+ data.tar.gz: 1d8f7f4a8b21f4ffa8e67d2069e368092b67f01476c8c3c0600e991153f828ae7486598eb7f8c4d8c7fa4595746cd87ad166aa801fce4630b8c97b599c26589f
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ *.gem
data/README.md CHANGED
@@ -1,23 +1,51 @@
1
- CodeFly is a gem that allows you to execute parallel / asynchronous code in Rails, in a easy way.
1
+ With CodeFly you can execute parallel / asynchronous code in Rails, in a easy way.
2
2
 
3
- This is how a classic code looks like:
3
+ ## This is how a classic code looks like:
4
4
  ```ruby
5
- blue_cars = Vehicle.where(type: "car", color: "blue") # 1 sec
6
- accessories = Accessory.where(type: "car") # 1 sec
7
- some_code(blue_cars, accessories) # 0.5 sec
5
+ @blue_cars = Vehicle.where(type: "car", color: "blue") # 0.1 sec
6
+ @accessories = Accessory.where(type: "car") # 0.1 sec
7
+ # some code
8
+ # some code using @blue_cars and @accessories
8
9
  ```
9
10
 
10
- This is how a flied code looks like:
11
+ ## This is how a flied code looks like:
11
12
  ```ruby
12
- fly(:A) { blue_cars = Vehicle.where(type: "car", color: "blue") } # 1 sec
13
- fly(:B) { accessories = Accessory.where(type: "car") } # 1 sec
13
+ fly(:A) { @blue_cars = Vehicle.where(type: "car", color: "blue") } # 0.1 sec
14
+ fly(:B) { @accessories = Accessory.where(type: "car") } # 0.1 sec
15
+ # some code
14
16
  wait_fly(:A, :B)
15
- some_code(blue_cars, accessories) # 0.5 sec
17
+ # some code using @blue_cars and @accessories
16
18
  ```
17
19
 
18
- The first code will take 2.5 sec, but the second will take only 1.5, almost the twice of speed. On the second code, the A and B queries will be executed at the same time (I will assume that your DB have more than 1 core), and the Ruby will be free to execute your own code while these 2 queries are being processed.
20
+ The first code will take 0.2 sec, but the second will take only 0.1 sec, the twice of speed. On the second code, the A and B queries will be executed at the same time (I will assume that your DB have more than 1 core), and the Ruby will be freed to execute another code while these 2 queries are being processed.
19
21
 
20
- The CodeFly methods are:
21
22
 
22
- fly(id) { async code }
23
- wait_fly(id_1[, id_2, …]): block until the async codes terminate
23
+ ## The CodeFly methods are:
24
+
25
+ - *fly(id)* { async code }
26
+ - *wait_fly(id_1[, id_2, …])*: block until the async codes terminate
27
+
28
+
29
+ ## Advanced techniques
30
+
31
+ You can use CodeFly to make prediction algorithms:
32
+ ```ruby
33
+ fly(:ans_a) { @blue_cars = Vehicle.where(type: "car", color: "blue") }
34
+ fly(:ans_b) { @yellow_cars = Vehicle.where(type: "car", color: "yellow") }
35
+ fly(:ans_c) { @other_cars = Vehicle.where(type: "car") }
36
+
37
+ wait_fly(:ans_a)
38
+ if @blue_cars.present?
39
+ # ...
40
+ else
41
+ wait_fly(:ans_b)
42
+ if @yellow_cars.present?
43
+ #...
44
+ else
45
+ wait_fly(:ans_c)
46
+ #...
47
+ end
48
+ end
49
+ ```
50
+
51
+ In this sample, you are triggering the all queries before you know what you need. So at the time that we get the first answer, the db probally provide us the others answers, saving time.
data/codefly.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Daniel Loureiro"]
10
10
  spec.email = ["loureirorg@gmail.com"]
11
11
  spec.summary = %q{Parallel / async code in Rails}
12
- spec.description = %q{CodeFly is a gem that allows you to execute parallel / asynchronous code in Rails, in a easy way.}
12
+ spec.description = %q{Execute parallel / asynchronous code in Rails, in a easy way}
13
13
  spec.homepage = "https://github.com/loureirorg/codefly"
14
14
  spec.license = "MIT"
15
15
 
@@ -1,3 +1,3 @@
1
1
  module Codefly
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codefly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Loureiro
@@ -38,8 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- description: CodeFly is a gem that allows you to execute parallel / asynchronous code
42
- in Rails, in a easy way.
41
+ description: Execute parallel / asynchronous code in Rails, in a easy way
43
42
  email:
44
43
  - loureirorg@gmail.com
45
44
  executables: []
@@ -51,6 +50,7 @@ files:
51
50
  - LICENSE.txt
52
51
  - README.md
53
52
  - Rakefile
53
+ - codefly-0.0.1.gem
54
54
  - codefly.gemspec
55
55
  - lib/codefly.rb
56
56
  - lib/codefly/version.rb