solargraph-rspec 0.5.3 → 0.5.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: 593f35289c326ff7ba5d2660c3789291f15130271a8253331fdea500168d0251
4
- data.tar.gz: c0e81f264776b2681edc1b83ed709013aaf2aaf8daf6f522b51b50e18ebfa11b
3
+ metadata.gz: 8be3e0236b9ee7ad2bc78abe9764001fc4ec2432a381571e23dddc27923caacb
4
+ data.tar.gz: 217d891f9561406a322f037948f13a3197f39d980f8394e36fc86304b8bccde9
5
5
  SHA512:
6
- metadata.gz: 869aad91f21b1b1713375013408dbfd1a6e7522013972a884ff3398135f77029f70f47c779d08a2f5c017135099e88dca7d4bae2cc661b9602a4eb50189d2cf7
7
- data.tar.gz: '0699722e685b86450179829c6818cfe75b434ed53956df6edbcfda36771faba8e0155bd8909cf5f8fe984d8b9b3e1cef6a8be5e79d0e8fe2722442adfc502ec0'
6
+ metadata.gz: 1c91744f1a8a2bb3a021f6cf008d627a292bf112c15b8215d7c9217d7bddf812b1f73b92a8d434d54755b10dd77b1f6b571c0b77ada0087b28e01e9f311e9c58
7
+ data.tar.gz: 3d9a7e4405f2ce232d31e7310a2af32c1f0e1d86cc8b48b461c899310b6bf9a8c9f43a1a0c661074fd670d1433827472161618a3ddb0cbfda551b8ab06953bac
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Credits: This file is a copy of the file from the solargraph-rspec gem
3
+ # Credits: This file was originally copied and adapted from the log_bench gem.
4
4
 
5
5
  module Solargraph
6
6
  module Rspec
@@ -11,6 +11,8 @@ module Solargraph
11
11
  return unless block_ast.is_a?(::Parser::AST::Node)
12
12
 
13
13
  ast = NodeTypes.context_description_node(block_ast)
14
+ return unless ast
15
+
14
16
  if ast.type == :str
15
17
  string_to_const_name(ast)
16
18
  elsif NodeTypes.a_constant?(ast)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Solargraph
4
4
  module Rspec
5
- VERSION = '0.5.3'
5
+ VERSION = '0.5.4'
6
6
  end
7
7
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Credits: This file was originally copied and adapted from the solargraph-rails gem
5
+
3
6
  module Solargraph
4
7
  module Rspec
5
8
  class Walker
data/release_gem.sh ADDED
@@ -0,0 +1,210 @@
1
+ #!/usr/bin/env bash
2
+ # Credits: This file was originally copied and adapted from the log_bench gem.
3
+ # https://raw.githubusercontent.com/silva96/log_bench/refs/heads/main/release_gem.sh
4
+ set -euo pipefail
5
+
6
+ ############################################
7
+ # Config — tweak if your gem/repo differs
8
+ ############################################
9
+ GEM_NAME="solargraph-rspec"
10
+ LIB_DIR="lib/solargraph/rspec"
11
+ DEFAULT_BRANCH="main"
12
+ VERSION_FILE="${LIB_DIR}/version.rb"
13
+ GEMSPEC_FILE="${GEM_NAME}.gemspec"
14
+ TAG_PREFIX="v"
15
+
16
+ # Bump mode: patch | minor | major (default patch)
17
+ BUMP="${BUMP:-patch}"
18
+
19
+ ############################################
20
+ # Arg parsing (optional)
21
+ ############################################
22
+ while [[ $# -gt 0 ]]; do
23
+ case "$1" in
24
+ --bump) BUMP="${2:-patch}"; shift 2 ;;
25
+ --bump=*) BUMP="${1#*=}"; shift 1 ;;
26
+ -h|--help)
27
+ cat <<EOF
28
+ Usage: $0 [--bump patch|minor|major]
29
+ Defaults to --bump patch (e.g., 0.2.6 -> 0.2.7).
30
+ EOF
31
+ exit 0 ;;
32
+ *) echo "Unknown arg: $1" >&2; exit 1 ;;
33
+ esac
34
+ done
35
+
36
+ case "$BUMP" in
37
+ patch|minor|major) : ;;
38
+ *) echo "Invalid --bump: $BUMP (use patch|minor|major)"; exit 1 ;;
39
+ esac
40
+
41
+ ############################################
42
+ # Pretty logging
43
+ ############################################
44
+ if command -v tput >/dev/null 2>&1 && [ -n "${TERM:-}" ]; then
45
+ BOLD=$(tput bold) || BOLD=""
46
+ RESET=$(tput sgr0) || RESET=""
47
+ GREEN=$(tput setaf 2) || GREEN=""
48
+ YELLOW=$(tput setaf 3) || YELLOW=""
49
+ RED=$(tput setaf 1) || RED=""
50
+ BLUE=$(tput setaf 4) || BLUE=""
51
+ else
52
+ BOLD=""; RESET=""; GREEN=""; YELLOW=""; RED=""; BLUE=""
53
+ fi
54
+
55
+ log() { printf "%b\n" "${BLUE}▸${RESET} $*"; }
56
+ success() { printf "%b\n" "${GREEN}✔${RESET} $*"; }
57
+ warn() { printf "%b\n" "${YELLOW}⚠${RESET} $*"; }
58
+ error() { printf "%b\n" "${RED}✖${RESET} $*"; }
59
+ die() { error "$*"; exit 1; }
60
+
61
+ ############################################
62
+ # Helpers
63
+ ############################################
64
+ require_cmd() { command -v "$1" >/dev/null 2>&1 || die "Missing required command: $1"; }
65
+
66
+ current_version() {
67
+ # Extract the first X.Y.Z from the VERSION file
68
+ grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' "$VERSION_FILE" | head -n1
69
+ }
70
+
71
+ validate_semver() { [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; }
72
+
73
+ bump_version() {
74
+ local mode="$1" ver="$2"
75
+ IFS='.' read -r MA MI PA <<<"$ver"
76
+ case "$mode" in
77
+ patch) echo "${MA}.${MI}.$((PA+1))" ;;
78
+ minor) echo "${MA}.$((MI+1)).0" ;;
79
+ major) echo "$((MA+1)).0.0" ;;
80
+ esac
81
+ }
82
+
83
+ update_version_file() {
84
+ local new="$1"
85
+ # Robust sed (preserves indentation, quote style, optional .freeze)
86
+ sed -E "s/^([[:space:]]*)VERSION[[:space:]]*=[[:space:]]*(['\"])[0-9]+\.[0-9]+\.[0-9]+(['\"])(\.freeze)?/\1VERSION = \2${new}\3\4/" \
87
+ "$VERSION_FILE" > "${VERSION_FILE}.tmp"
88
+ mv "${VERSION_FILE}.tmp" "$VERSION_FILE"
89
+ }
90
+
91
+ ensure_clean_worktree() {
92
+ if [ -n "$(git status --porcelain)" ]; then
93
+ warn "Your working tree has uncommitted changes:"
94
+ git status --short
95
+ read -rp "$(printf '%b' "${YELLOW}Proceed anyway? [y/N] ${RESET}")" ans
96
+ [[ "${ans:-}" =~ ^[Yy]$ ]] || die "Aborted due to dirty working tree."
97
+ fi
98
+ }
99
+
100
+ ############################################
101
+ # Checks
102
+ ############################################
103
+ require_cmd git
104
+ require_cmd bundle
105
+ require_cmd gem
106
+ require_cmd sed
107
+
108
+ if ! command -v gh >/dev/null 2>&1; then
109
+ warn "GitHub CLI (gh) not found. GitHub release creation will be skipped."
110
+ GH_AVAILABLE="false"
111
+ else
112
+ GH_AVAILABLE="true"
113
+ fi
114
+
115
+ [ -f "$VERSION_FILE" ] || die "Version file not found: $VERSION_FILE"
116
+ [ -f "$GEMSPEC_FILE" ] || die "Gemspec not found: $GEMSPEC_FILE"
117
+
118
+ ############################################
119
+ # Start
120
+ ############################################
121
+ log "${BOLD}Publishing ${GEM_NAME}${RESET}"
122
+ ensure_clean_worktree
123
+
124
+ log "Pulling latest from origin/${DEFAULT_BRANCH}…"
125
+ git checkout "$DEFAULT_BRANCH" >/dev/null 2>&1 || true
126
+ git pull origin "$DEFAULT_BRANCH"
127
+ success "Up to date."
128
+
129
+ CURR_VER="$(current_version)"
130
+ [ -n "$CURR_VER" ] || die "Could not determine current version from $VERSION_FILE"
131
+
132
+ log "Current version detected in ${VERSION_FILE}: ${BOLD}${CURR_VER}${RESET}"
133
+ PROPOSED="$(bump_version "$BUMP" "$CURR_VER")"
134
+ read -rp "$(printf '%b' "${BLUE}Proposed next ${BOLD}${BUMP}${RESET}${BLUE} version is ${BOLD}${PROPOSED}${RESET}${BLUE}. Press Enter to accept or type a different semver (X.Y.Z): ${RESET}")" NEW_VER
135
+ NEW_VER="${NEW_VER:-$PROPOSED}"
136
+ validate_semver "$NEW_VER" || die "Invalid semver: $NEW_VER"
137
+
138
+ TAG="${TAG_PREFIX}${NEW_VER}"
139
+
140
+ # Guard against existing tag
141
+ if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
142
+ die "Tag ${TAG} already exists."
143
+ fi
144
+
145
+ log "Updating version file to ${BOLD}${NEW_VER}${RESET}…"
146
+ before_contents="$(cat "$VERSION_FILE")"
147
+ update_version_file "$NEW_VER"
148
+ after_contents="$(cat "$VERSION_FILE")"
149
+ if [ "$before_contents" = "$after_contents" ]; then
150
+ AFTER_VER="$(current_version || true)"
151
+ if [ "$AFTER_VER" = "$NEW_VER" ]; then
152
+ warn "Version file already at ${NEW_VER}; nothing to change."
153
+ else
154
+ die "Failed to update ${VERSION_FILE}. Ensure it has a line like:
155
+ VERSION = \"${CURR_VER}\"
156
+ (or with single quotes / optional .freeze)."
157
+ fi
158
+ else
159
+ success "Updated ${VERSION_FILE}."
160
+ fi
161
+
162
+ log "Installing gems (bundle install)…"
163
+ bundle install
164
+ success "Dependencies installed."
165
+
166
+ log "Committing version bump (including Gemfile.lock if changed)…"
167
+ FILES_TO_COMMIT=()
168
+ if ! git diff --quiet -- "$VERSION_FILE"; then
169
+ FILES_TO_COMMIT+=("$VERSION_FILE")
170
+ fi
171
+ if [ -f "Gemfile.lock" ] && ! git diff --quiet -- "Gemfile.lock"; then
172
+ FILES_TO_COMMIT+=("Gemfile.lock")
173
+ fi
174
+
175
+ if [ "${#FILES_TO_COMMIT[@]}" -gt 0 ]; then
176
+ git add "${FILES_TO_COMMIT[@]}"
177
+ git commit -m "Bump version to ${NEW_VER}"
178
+ success "Committed: ${FILES_TO_COMMIT[*]}"
179
+ else
180
+ warn "No changes to commit (version file and Gemfile.lock unchanged)."
181
+ fi
182
+
183
+ log "Creating tag ${BOLD}${TAG}${RESET}…"
184
+ git tag "${TAG}" -m "Release version ${NEW_VER}"
185
+ success "Tag created."
186
+
187
+ log "Pushing branch & tag to origin…"
188
+ git push origin "$DEFAULT_BRANCH"
189
+ git push origin "${TAG}"
190
+ success "Pushed."
191
+
192
+ if [ "$GH_AVAILABLE" = "true" ]; then
193
+ log "Creating GitHub release ${BOLD}${TAG}${RESET} with auto-generated notes…"
194
+ gh release create "${TAG}" --title "Release version ${NEW_VER}" --generate-notes || warn "Failed to create GitHub release via gh."
195
+ success "GitHub release created."
196
+ else
197
+ warn "Skipping GitHub release creation (gh not installed)."
198
+ fi
199
+
200
+ log "Building gem…"
201
+ gem build "$GEMSPEC_FILE"
202
+ GEM_FILE="${GEM_NAME}-${NEW_VER}.gem"
203
+ [ -f "$GEM_FILE" ] || die "Gem file not found after build: $GEM_FILE"
204
+ success "Built ${GEM_FILE}."
205
+
206
+ log "Pushing gem to RubyGems…"
207
+ gem push "$GEM_FILE"
208
+ success "Gem pushed to RubyGems."
209
+
210
+ success "${BOLD}${GEM_NAME} ${NEW_VER}${RESET} has been published! 🎉"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lekë Mula
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-09-02 00:00:00.000000000 Z
10
+ date: 2025-09-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: solargraph
@@ -64,6 +64,7 @@ files:
64
64
  - lib/solargraph/rspec/version.rb
65
65
  - lib/solargraph/rspec/walker.rb
66
66
  - lib/solargraph_rspec.rb
67
+ - release_gem.sh
67
68
  - sig/solargraph/rspec.rbs
68
69
  - solargraph-rspec.gemspec
69
70
  licenses: