dotcodegen 0.1.3 → 0.1.4

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: e0354938621e705831e5f3f4a327b8da9e10901519e8d90181592f33dc584a53
4
- data.tar.gz: 04631eaca2b2cfff73bec57958ea6f00e2d6741657b8d95638529fb60a42bd6d
3
+ metadata.gz: e2617e3b970e9e982ba60cb5a45b686cf11d86ddf12457e289a2801d8387fe7d
4
+ data.tar.gz: 316db28cbcbfb0abb8230c080df86b065daf7361fc63e099d7615df5d0643f7c
5
5
  SHA512:
6
- metadata.gz: c83a1aba762c27be35068bc3148b32016b2505a4b63c1f1d8707685cf00654e09fdff4b8b26025972304ca304468ac493547c8af807025ec49725bae4b4d3624
7
- data.tar.gz: df25ea36901d9ac9b94da9bf1f18be5cd1fb3b76122377581a2b44dbe6257dc101f1d0a5056be92203e9470902664538a5eef7c0fee6071019458e6cadd85a4c
6
+ metadata.gz: 4bb6faa3e1944f372103946d31286143dc36ef47d5e2c4e4894fa51505ac26e0e9da3bef4bca38a2ba6497acc324466bcd3db9749f1179c6edb1df181023130a
7
+ data.tar.gz: 4e9b53b2665b436da1f65c28976333e863cbb03c18159151ae43409dd481bac188cfd0dade7921b9c14da035412e9ab7218387aeb5623a46c2ff9386ef30adca
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2024-03-11
4
+
5
+ - Strip the leading and trailing ``` from the output of the codegen command.
6
+ - Remove the organization from the OpenAI initialization code.
7
+
3
8
  # [0.1.3] - 2024-03-10
4
9
 
5
10
  - Move the execution to a /exe/codegen file. exe/run was removed.
data/README.md CHANGED
@@ -1,25 +1,38 @@
1
- # Automatic test generation for monoliths
1
+ # .codegen - Automatic test generation for your projects
2
+ [![Gem Version](https://badge.fury.io/rb/dotcodegen.svg)](https://badge.fury.io/rb/dotcodegen) [![Test Coverage](https://api.codeclimate.com/v1/badges/8a9e8ffdf8f3c5322196/test_coverage)](https://codeclimate.com/github/ferrucc-io/dotcodegen/test_coverage)
3
+
2
4
 
3
5
  Never write a test from scratch again. Automatically generate tests for any file you open in your codebase.
4
6
 
5
7
  Keep your team up to date with the latest best practices and conventions you adopt. Customize the templates to fit your team's needs.
6
8
 
7
- We're using this tool to speed up writing tests for our monolith at [June](https://june.so). We open sourced it so you can use it too.
9
+ We've built this tool internally to speed up writing tests for our monolith at [June](https://june.so). The main idea is that across your codebase, you can have a set of instructions that are used to generate tests. These templates are configurable so no matter what framework or language your current file is in, you can generate tests that fit your team's needs.
10
+
11
+ Now we're open-sourcing it so you can use it too.
12
+
13
+ https://github.com/ferrucc-io/dotcodegen/assets/8315559/aca74a87-5123-4305-88ff-cc3be3f34a9f
14
+
8
15
 
9
16
  ## Get started
10
17
 
11
18
 
12
- 1. Install our CLI by running:
19
+ 1. Install our CLI via Homebrew:
13
20
 
14
21
  ```bash
15
22
  brew tap ferrucc-io/dotcodegen-tap
16
23
  brew install dotcodegen
17
24
  ```
18
25
 
26
+ Or via RubyGems, this requires Ruby 3.3.0:
27
+
28
+ ```bash
29
+ gem install dotcodegen
30
+ ```
31
+
19
32
  2. Initialise the `.codegen` directory in your codebase:
20
33
 
21
34
  ```bash
22
- codegen init
35
+ codegen --init
23
36
  ```
24
37
 
25
38
  3. Configure the templates to fit your team's needs. See the [configuration](./docs/configuration.md) section for more details.
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotcodegen
4
+ class FormatOutput
5
+ def self.format(generated_test_code)
6
+ generated_test_code.gsub(/^```[a-zA-Z]*\n/, '').gsub(/\n```$/, '')
7
+ end
8
+ end
9
+ end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'openai'
4
+ require_relative 'format_output'
5
+
4
6
  module Dotcodegen
5
7
  class TestCodeGenerator
6
8
  attr_reader :config, :file_to_test_path, :openai_key
@@ -19,7 +21,7 @@ module Dotcodegen
19
21
  temperature: 0.7
20
22
  }
21
23
  )
22
- response.dig('choices', 0, 'message', 'content')
24
+ FormatOutput.format(response.dig('choices', 0, 'message', 'content'))
23
25
  end
24
26
 
25
27
  def test_prompt_text
@@ -53,10 +55,7 @@ module Dotcodegen
53
55
  end
54
56
 
55
57
  def openai_client
56
- @openai_client ||= OpenAI::Client.new(
57
- access_token: openai_key,
58
- organization_id: 'org-4nA9FJ8NajsLJ2fbHRAw7MLI'
59
- )
58
+ @openai_client ||= OpenAI::Client.new(access_token: openai_key)
60
59
  end
61
60
  end
62
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dotcodegen
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotcodegen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferruccio Balestreri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -75,6 +75,7 @@ files:
75
75
  - exe/codegen
76
76
  - lib/dotcodegen.rb
77
77
  - lib/dotcodegen/cli.rb
78
+ - lib/dotcodegen/format_output.rb
78
79
  - lib/dotcodegen/init.rb
79
80
  - lib/dotcodegen/test_code_generator.rb
80
81
  - lib/dotcodegen/test_file_generator.rb