From 0bee2ab829b30ce51513a6c3094ff289757438aa Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 10:29:32 +1100 Subject: [PATCH 1/9] day1 --- .gitignore | 3 +- .rspec | 5 +- .rubocop.yml | 43 +++++++++++- Gemfile | 5 -- Gemfile.lock | 142 ++++++++++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 20 +++++- spec/support/helpers.rb | 21 ++++++ vistar_client.gemspec | 34 ++++++---- 8 files changed, 249 insertions(+), 24 deletions(-) create mode 100644 Gemfile.lock create mode 100644 spec/support/helpers.rb diff --git a/.gitignore b/.gitignore index 78ae128..490dd22 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ # rspec failure tracking .rspec_status -/docs/internal/* \ No newline at end of file +/docs/internal/* +.github/copilot-instructions.md diff --git a/.rspec b/.rspec index 34c5164..64ffd32 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,4 @@ ---format documentation ---color --require spec_helper +--color +--format documentation +--order random diff --git a/.rubocop.yml b/.rubocop.yml index ae378d0..099a6c6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,45 @@ AllCops: - TargetRubyVersion: 3.2 + NewCops: enable + TargetRubyVersion: 3.0 + Exclude: + - 'bin/*' + - 'vendor/**/*' + - 'node_modules/**/*' + +require: + - rubocop-performance + - rubocop-rspec + +# Gem-specific customizations +Style/Documentation: + Enabled: false Style/StringLiterals: - EnforcedStyle: double_quotes + EnforcedStyle: single_quotes Style/StringLiteralsInInterpolation: - EnforcedStyle: double_quotes + EnforcedStyle: single_quotes + +Metrics/BlockLength: + Exclude: + - 'spec/**/*.rb' + - '*.gemspec' + +Metrics/MethodLength: + Max: 15 + Exclude: + - 'spec/**/*.rb' + +Layout/LineLength: + Max: 120 + Exclude: + - 'spec/**/*.rb' + +RSpec/MultipleExpectations: + Max: 5 + +RSpec/NestedGroups: + Max: 4 + +RSpec/ExampleLength: + Max: 15 diff --git a/Gemfile b/Gemfile index 2b96ca3..0a98a51 100644 --- a/Gemfile +++ b/Gemfile @@ -6,8 +6,3 @@ source "https://rubygems.org" gemspec gem "irb" -gem "rake", "~> 13.0" - -gem "rspec", "~> 3.0" - -gem "rubocop", "~> 1.21" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0f44528 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,142 @@ +PATH + remote: . + specs: + vistar_client (0.1.0) + faraday (~> 2.7) + faraday-retry (~> 2.2) + +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.3) + byebug (12.0.0) + coderay (1.1.3) + date (3.5.0) + diff-lcs (1.6.2) + docile (1.4.1) + erb (5.1.3) + faraday (2.14.0) + faraday-net_http (>= 2.0, < 3.5) + json + logger + faraday-net_http (3.4.1) + net-http (>= 0.5.0) + faraday-retry (2.3.2) + faraday (~> 2.0) + io-console (0.8.1) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.15.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + method_source (1.1.0) + net-http (0.6.0) + uri + parallel (1.27.0) + parser (3.3.10.0) + ast (~> 2.4.1) + racc + pp (0.6.3) + prettyprint + prettyprint (0.2.0) + prism (1.6.0) + pry (0.15.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.11.0) + byebug (~> 12.0) + pry (>= 0.13, < 0.16) + psych (5.2.6) + date + stringio + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.1) + rdoc (6.15.0) + erb + psych (>= 4.0.0) + tsort + regexp_parser (2.11.3) + reline (0.6.2) + io-console (~> 0.5) + rspec (3.13.2) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.6) + rubocop (1.81.6) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.47.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.47.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-capybara (2.22.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-factory_bot (2.27.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-performance (1.26.1) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + rubocop-rspec (2.31.0) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.29.1) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.2) + simplecov_json_formatter (0.1.4) + stringio (3.1.7) + tsort (0.2.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + uri (1.0.4) + yard (0.9.37) + +PLATFORMS + arm64-darwin-23 + ruby + +DEPENDENCIES + irb + pry (~> 0.14) + pry-byebug (~> 3.10) + rake (~> 13.0) + rspec (~> 3.12) + rubocop (~> 1.50) + rubocop-performance (~> 1.19) + rubocop-rspec (~> 2.22) + simplecov (~> 0.22) + vistar_client! + yard (~> 0.9) + +BUNDLED WITH + 2.7.1 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3155323..2698ebd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,19 @@ # frozen_string_literal: true -require "vistar_client" +require 'simplecov' + +SimpleCov.start do + add_filter '/spec/' + add_filter '/vendor/' + minimum_coverage 95 + minimum_coverage_by_file 80 +end + +require 'vistar_client' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" + config.example_status_persistence_file_path = '.rspec_status' # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! @@ -12,4 +21,11 @@ config.expect_with :rspec do |c| c.syntax = :expect end + + # Run specs in random order + config.order = :random + Kernel.srand config.seed end + +# Load support files +Dir[File.join(__dir__, 'support', '**', '*.rb')].each { |f| require f } diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb new file mode 100644 index 0000000..c84e561 --- /dev/null +++ b/spec/support/helpers.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module VistarClient + module TestHelpers + def fixture_path(filename) + File.join(File.dirname(__FILE__), '../fixtures', filename) + end + + def load_fixture(filename) + File.read(fixture_path(filename)) + end + + def json_fixture(filename) + JSON.parse(load_fixture("#{filename}.json")) + end + end +end + +RSpec.configure do |config| + config.include VistarClient::TestHelpers +end diff --git a/vistar_client.gemspec b/vistar_client.gemspec index 3650887..fc6c3fa 100644 --- a/vistar_client.gemspec +++ b/vistar_client.gemspec @@ -8,16 +8,19 @@ Gem::Specification.new do |spec| spec.authors = ["Chayut Orapinpatipat"] spec.email = ["chayut@canopusnet.com"] - spec.summary = "TODO: Write a short summary, because RubyGems requires one." - spec.description = "TODO: Write a longer description or delete this line." - spec.homepage = "TODO: Put your gem's website or public repo URL here." + spec.summary = "Ruby client library for Vistar Media API" + spec.description = "A production-grade Ruby gem for interacting with the Vistar Media DOOH " \ + "advertising platform. Provides clean interfaces for ad serving, " \ + "proof-of-play submission, and campaign management." + spec.homepage = "https://github.com/Sentia/vistar_client" spec.license = "MIT" - spec.required_ruby_version = ">= 3.2.0" + spec.required_ruby_version = ">= 3.0.0" - spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." - spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." + spec.metadata["source_code_uri"] = "https://github.com/Sentia/vistar_client" + spec.metadata["changelog_uri"] = "https://github.com/Sentia/vistar_client/blob/main/CHANGELOG.md" + spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/vistar_client" + spec.metadata["bug_tracker_uri"] = "https://github.com/Sentia/vistar_client/issues" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. @@ -32,9 +35,18 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - # Uncomment to register a new dependency of your gem - # spec.add_dependency "example-gem", "~> 1.0" + # Runtime dependencies + spec.add_dependency "faraday", "~> 2.7" + spec.add_dependency "faraday-retry", "~> 2.2" - # For more information and examples about making a new gem, check out our - # guide at: https://bundler.io/guides/creating_gem.html + # Development dependencies + spec.add_development_dependency "pry", "~> 0.14" + spec.add_development_dependency "pry-byebug", "~> 3.10" + spec.add_development_dependency "rake", "~> 13.0" + spec.add_development_dependency "rspec", "~> 3.12" + spec.add_development_dependency "rubocop", "~> 1.50" + spec.add_development_dependency "rubocop-performance", "~> 1.19" + spec.add_development_dependency "rubocop-rspec", "~> 2.22" + spec.add_development_dependency "simplecov", "~> 0.22" + spec.add_development_dependency "yard", "~> 0.9" end From e0f0515a239840552162082e7370e36d8ac12822 Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 12:07:11 +1100 Subject: [PATCH 2/9] setup1 --- .env.example | 13 +++ .github/workflows/ci.yml | 67 ++++++++++++++++ .github/workflows/release.yml | 38 +++++++++ .gitignore | 5 ++ .rubocop.yml | 5 ++ CHANGELOG.md | 32 +++++++- Gemfile | 15 +++- README.md | 51 ++++++++++-- RELEASING.md | 147 ++++++++++++++++++++++++++++++++++ Rakefile | 6 +- bin/console | 33 ++++++-- bin/setup | 20 ++++- lib/vistar_client.rb | 2 +- lib/vistar_client/version.rb | 2 +- spec/vistar_client_spec.rb | 8 +- vistar_client.gemspec | 52 +++++------- 16 files changed, 438 insertions(+), 58 deletions(-) create mode 100644 .env.example create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 RELEASING.md diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c2d8541 --- /dev/null +++ b/.env.example @@ -0,0 +1,13 @@ +# Vistar Media API Credentials + +# Staging Environment +VISTAR_STAGING_NETWORK_ID=your_staging_network_id +VISTAR_STAGING_API_KEY=your_staging_api_key + +# Production Environment (use with caution) +# VISTAR_PRODUCTION_NETWORK_ID=your_production_network_id +# VISTAR_PRODUCTION_API_KEY=your_production_api_key + +# Optional: API Base URLs (defaults provided) +# VISTAR_STAGING_API_URL=https://sandbox-api.vistarmedia.com +# VISTAR_PRODUCTION_API_URL=https://api.vistarmedia.com diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3d4f7d7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: ['3.0', '3.1', '3.2', '3.3'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Run tests + run: bundle exec rspec + + - name: Upload coverage to Codecov + if: matrix.ruby == '3.3' + uses: codecov/codecov-action@v3 + with: + files: ./coverage/.resultset.json + fail_ci_if_error: false + + rubocop: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Run RuboCop + run: bundle exec rubocop + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Build gem + run: bundle exec rake build + + - name: List contents + run: ls -la pkg/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a01569b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Build gem + run: bundle exec rake build + + - name: Publish to RubyGems + env: + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + run: | + mkdir -p ~/.gem + gem push pkg/*.gem + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: pkg/*.gem + generate_release_notes: true diff --git a/.gitignore b/.gitignore index 490dd22..0aa7d5e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,10 @@ # rspec failure tracking .rspec_status + +# Environment variables +.env + +# Internal documentation and instructions /docs/internal/* .github/copilot-instructions.md diff --git a/.rubocop.yml b/.rubocop.yml index 099a6c6..ecffeb3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ AllCops: NewCops: enable TargetRubyVersion: 3.0 + SuggestExtensions: false Exclude: - 'bin/*' - 'vendor/**/*' @@ -10,6 +11,10 @@ require: - rubocop-performance - rubocop-rspec +# Disable buggy Capybara cop +Capybara/RSpec/PredicateMatcher: + Enabled: false + # Gem-specific customizations Style/Documentation: Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index e8fe441..7d9f182 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + ## [Unreleased] +### Added +- Nothing yet + +### Changed +- Nothing yet + +### Fixed +- Nothing yet + ## [0.1.0] - 2025-10-31 -- Initial release +### Added +- Initial project scaffolding +- Basic gem structure with Bundler +- MIT License +- Documentation structure +- Sprint 0: Production infrastructure setup + - Production-grade RuboCop configuration + - RSpec with SimpleCov integration (95% coverage target) + - GitHub Actions CI/CD pipeline + - Complete gemspec with all dependencies + - Development environment setup (.env, bin/setup, bin/console) + - Release and contribution documentation + +[Unreleased]: https://github.com/Sentia/vistar_client/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/Sentia/vistar_client/releases/tag/v0.1.0 diff --git a/Gemfile b/Gemfile index 0a98a51..893c2cd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,19 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' # Specify your gem's dependencies in vistar_client.gemspec gemspec -gem "irb" +gem 'irb' + +# Development dependencies +gem 'pry', '~> 0.14' +gem 'pry-byebug', '~> 3.10' +gem 'rake', '~> 13.0' +gem 'rspec', '~> 3.12' +gem 'rubocop', '~> 1.50' +gem 'rubocop-performance', '~> 1.19' +gem 'rubocop-rspec', '~> 2.22' +gem 'simplecov', '~> 0.22' +gem 'yard', '~> 0.9' diff --git a/README.md b/README.md index 6041bc7..e453fe1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # VistarClient +![CI](https://github.com/Sentia/vistar_client/workflows/CI/badge.svg) +[![Gem Version](https://badge.fury.io/rb/vistar_client.svg)](https://badge.fury.io/rb/vistar_client) +[![codecov](https://codecov.io/gh/Sentia/vistar_client/branch/main/graph/badge.svg)](https://codecov.io/gh/Sentia/vistar_client) + A Ruby client library for the Vistar Media API. Provides a clean, type-safe interface for ad serving, proof-of-play submission, and campaign management. ## Installation @@ -71,17 +75,52 @@ rescue VistarClient::ConnectionError => e end ``` -## Development and Testing +## Development + +After checking out the repo, run `bin/setup` to install dependencies. + +### Environment Setup + +1. Copy `.env.example` to `.env` +2. Add your Vistar API credentials +3. Use `staging_client` helper in console for testing + +### Running Tests + +```bash +bundle exec rspec # Run all tests +bundle exec rspec --tag focus # Run focused tests +bundle exec rspec --profile # Show slowest tests +``` + +### Code Quality + +```bash +bundle exec rubocop # Check code style +bundle exec rubocop -A # Auto-correct offenses +``` + +### Documentation + +```bash +bundle exec yard doc # Generate documentation +bundle exec yard server # View docs at http://localhost:8808 +``` -After checking out the repo, run `bin/setup` to install dependencies. Then run: +### Interactive Console ```bash -rake spec # Run tests -rubocop # Check code style -yard doc # Generate documentation +bin/console # Start Pry console with gem loaded ``` -To install locally: `bundle exec rake install` +The console provides helper methods: +- `staging_client` - Creates a client configured for Vistar staging environment + +### Installing Locally + +```bash +bundle exec rake install # Install gem locally +``` ## Contributing diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..b6ee870 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,147 @@ +# Release Process for VistarClient + +This document describes the process for releasing new versions of the VistarClient gem. + +## Semantic Versioning + +We follow [Semantic Versioning 2.0.0](https://semver.org/): + +- **MAJOR** (x.0.0): Breaking changes to public API +- **MINOR** (0.x.0): New features, backward compatible +- **PATCH** (0.0.x): Bug fixes, backward compatible + +## Pre-Release Checklist + +- [ ] All tests passing (`bundle exec rspec`) +- [ ] RuboCop clean (`bundle exec rubocop`) +- [ ] Coverage ≥95% (check SimpleCov report) +- [ ] CHANGELOG.md updated with changes +- [ ] Version bumped in `lib/vistar_client/version.rb` +- [ ] Documentation updated (if API changes) +- [ ] README updated (if needed) +- [ ] All PRs merged to `main` + +## Release Steps + +### 1. Update Version and Changelog + +```bash +# Edit version +vim lib/vistar_client/version.rb + +# Update CHANGELOG.md +vim CHANGELOG.md +``` + +### 2. Commit Changes + +```bash +git add lib/vistar_client/version.rb CHANGELOG.md +git commit -m "Bump version to X.Y.Z" +git push origin main +``` + +### 3. Create and Push Tag + +```bash +git tag -a vX.Y.Z -m "Release version X.Y.Z" +git push origin vX.Y.Z +``` + +The GitHub Actions workflow will automatically: +- Run tests +- Build the gem +- Publish to RubyGems.org +- Create GitHub release + +### 4. Verify Release + +- Check [RubyGems.org](https://rubygems.org/gems/vistar_client) +- Check [GitHub Releases](https://github.com/Sentia/vistar_client/releases) +- Test installation: `gem install vistar_client` + +## Rollback a Release + +If a critical issue is found: + +```bash +# Yank the gem (discouraged, only for critical security issues) +gem yank vistar_client -v X.Y.Z + +# Release a patch version with fix immediately +``` + +## RubyGems API Key Setup + +For maintainers: Add `RUBYGEMS_API_KEY` to GitHub Secrets: + +1. Get API key from [RubyGems.org profile](https://rubygems.org/profile/edit) +2. Go to repo Settings → Secrets and variables → Actions +3. Click "New repository secret" +4. Name: `RUBYGEMS_API_KEY` +5. Value: Your API key +6. Click "Add secret" + +## Release Checklist Template + +When releasing version X.Y.Z: + +```markdown +## Release X.Y.Z + +- [ ] Tests passing +- [ ] RuboCop clean +- [ ] Coverage ≥95% +- [ ] CHANGELOG.md updated +- [ ] Version bumped +- [ ] Committed and pushed to main +- [ ] Tag created: vX.Y.Z +- [ ] Tag pushed +- [ ] CI/CD passed +- [ ] Gem published to RubyGems +- [ ] GitHub release created +- [ ] Installation verified +``` + +## Version Numbering Guidelines + +### MAJOR version (breaking changes) +- Removing public methods +- Changing method signatures +- Changing return values in breaking ways +- Renaming classes or modules +- Changing constructor arguments + +### MINOR version (new features) +- Adding new public methods +- Adding new classes +- Adding optional parameters +- Deprecating features (with warnings) +- Internal improvements with no public API changes + +### PATCH version (bug fixes) +- Fixing bugs +- Updating documentation +- Refactoring internal code +- Updating dependencies (non-breaking) +- Performance improvements + +## Post-Release Communication + +After release: + +1. Announce on relevant channels (if applicable) +2. Update documentation sites if needed +3. Monitor for issues in first 24-48 hours +4. Respond to bug reports promptly + +## Emergency Hotfix Process + +For critical bugs in production: + +1. Create hotfix branch from affected version tag +2. Fix the bug +3. Run full test suite +4. Bump PATCH version +5. Follow normal release process +6. Merge hotfix back to main diff --git a/Rakefile b/Rakefile index cca7175..4964751 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "bundler/gem_tasks" -require "rspec/core/rake_task" +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -require "rubocop/rake_task" +require 'rubocop/rake_task' RuboCop::RakeTask.new diff --git a/bin/console b/bin/console index 435dd9e..35f0f67 100755 --- a/bin/console +++ b/bin/console @@ -1,11 +1,32 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require "bundler/setup" -require "vistar_client" +require 'bundler/setup' +require 'vistar_client' -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. +# Load environment variables if available +if File.exist?('.env') + File.readlines('.env').each do |line| + next if line.strip.empty? || line.start_with?('#') -require "irb" -IRB.start(__FILE__) + key, value = line.split('=', 2) + ENV[key.strip] = value.strip if key && value + end +end + +# Helper methods for console +def staging_client + VistarClient::Client.new( + network_id: ENV['VISTAR_STAGING_NETWORK_ID'], + api_key: ENV['VISTAR_STAGING_API_KEY'], + api_base_url: ENV.fetch('VISTAR_STAGING_API_URL', 'https://sandbox-api.vistarmedia.com') + ) +end + +puts "VistarClient #{VistarClient::VERSION} console" +puts "Type 'staging_client' to create a staging API client" +puts 'Credentials loaded from .env file' if File.exist?('.env') +puts '' + +require 'pry' +Pry.start diff --git a/bin/setup b/bin/setup index dce67d8..11fa3ef 100755 --- a/bin/setup +++ b/bin/setup @@ -3,6 +3,24 @@ set -euo pipefail IFS=$'\n\t' set -vx +echo "==> Installing dependencies..." bundle install -# Do any other automated setup that you need to do here +echo "==> Setting up environment..." +# Copy environment template if needed +if [ ! -f .env ]; then + cp .env.example .env + echo "✓ Created .env file. Please update with your credentials." +else + echo "✓ .env file already exists" +fi + +echo "" +echo "==> Setup complete!" +echo "" +echo "Next steps:" +echo " 1. Update .env with your Vistar API credentials" +echo " 2. Run 'bin/console' to start an interactive session" +echo " 3. Run 'bundle exec rspec' to run tests" +echo " 4. Run 'bundle exec rubocop' to check code style" +echo "" diff --git a/lib/vistar_client.rb b/lib/vistar_client.rb index 5733bef..db19c55 100644 --- a/lib/vistar_client.rb +++ b/lib/vistar_client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative "vistar_client/version" +require_relative 'vistar_client/version' module VistarClient class Error < StandardError; end diff --git a/lib/vistar_client/version.rb b/lib/vistar_client/version.rb index ac228bf..3563ce4 100644 --- a/lib/vistar_client/version.rb +++ b/lib/vistar_client/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module VistarClient - VERSION = "0.1.0" + VERSION = '0.1.0' end diff --git a/spec/vistar_client_spec.rb b/spec/vistar_client_spec.rb index a83f0cf..f3cf943 100644 --- a/spec/vistar_client_spec.rb +++ b/spec/vistar_client_spec.rb @@ -1,11 +1,7 @@ # frozen_string_literal: true RSpec.describe VistarClient do - it "has a version number" do - expect(VistarClient::VERSION).not_to be nil - end - - it "does something useful" do - expect(false).to eq(true) + it 'has a version number' do + expect(VistarClient::VERSION).not_to be_nil end end diff --git a/vistar_client.gemspec b/vistar_client.gemspec index fc6c3fa..c3aa659 100644 --- a/vistar_client.gemspec +++ b/vistar_client.gemspec @@ -1,26 +1,27 @@ # frozen_string_literal: true -require_relative "lib/vistar_client/version" +require_relative 'lib/vistar_client/version' Gem::Specification.new do |spec| - spec.name = "vistar_client" + spec.name = 'vistar_client' spec.version = VistarClient::VERSION - spec.authors = ["Chayut Orapinpatipat"] - spec.email = ["chayut@canopusnet.com"] + spec.authors = ['Chayut Orapinpatipat'] + spec.email = ['chayut@canopusnet.com'] - spec.summary = "Ruby client library for Vistar Media API" - spec.description = "A production-grade Ruby gem for interacting with the Vistar Media DOOH " \ - "advertising platform. Provides clean interfaces for ad serving, " \ - "proof-of-play submission, and campaign management." - spec.homepage = "https://github.com/Sentia/vistar_client" - spec.license = "MIT" - spec.required_ruby_version = ">= 3.0.0" + spec.summary = 'Ruby client library for Vistar Media API' + spec.description = 'A production-grade Ruby gem for interacting with the Vistar Media DOOH ' \ + 'advertising platform. Provides clean interfaces for ad serving, ' \ + 'proof-of-play submission, and campaign management.' + spec.homepage = 'https://github.com/Sentia/vistar_client' + spec.license = 'MIT' + spec.required_ruby_version = '>= 3.0.0' - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "https://github.com/Sentia/vistar_client" - spec.metadata["changelog_uri"] = "https://github.com/Sentia/vistar_client/blob/main/CHANGELOG.md" - spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/vistar_client" - spec.metadata["bug_tracker_uri"] = "https://github.com/Sentia/vistar_client/issues" + spec.metadata['homepage_uri'] = spec.homepage + spec.metadata['source_code_uri'] = 'https://github.com/Sentia/vistar_client' + spec.metadata['changelog_uri'] = 'https://github.com/Sentia/vistar_client/blob/main/CHANGELOG.md' + spec.metadata['documentation_uri'] = 'https://rubydoc.info/gems/vistar_client' + spec.metadata['bug_tracker_uri'] = 'https://github.com/Sentia/vistar_client/issues' + spec.metadata['rubygems_mfa_required'] = 'true' # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. @@ -31,22 +32,11 @@ Gem::Specification.new do |spec| f.start_with?(*%w[bin/ Gemfile .gitignore .rspec spec/ .github/ .rubocop.yml]) end end - spec.bindir = "exe" + spec.bindir = 'exe' spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] # Runtime dependencies - spec.add_dependency "faraday", "~> 2.7" - spec.add_dependency "faraday-retry", "~> 2.2" - - # Development dependencies - spec.add_development_dependency "pry", "~> 0.14" - spec.add_development_dependency "pry-byebug", "~> 3.10" - spec.add_development_dependency "rake", "~> 13.0" - spec.add_development_dependency "rspec", "~> 3.12" - spec.add_development_dependency "rubocop", "~> 1.50" - spec.add_development_dependency "rubocop-performance", "~> 1.19" - spec.add_development_dependency "rubocop-rspec", "~> 2.22" - spec.add_development_dependency "simplecov", "~> 0.22" - spec.add_development_dependency "yard", "~> 0.9" + spec.add_dependency 'faraday', '~> 2.7' + spec.add_dependency 'faraday-retry', '~> 2.2' end From eb213fa66b0385d01c6743f008d4e02126bed253 Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 12:39:44 +1100 Subject: [PATCH 3/9] update ci --- .github/workflows/ci.yml | 3 +++ Gemfile.lock | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d4f7d7..817c34b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + bundler: '2.5.22' - name: Run tests run: bundle exec rspec @@ -44,6 +45,7 @@ jobs: with: ruby-version: '3.3' bundler-cache: true + bundler: '2.5.22' - name: Run RuboCop run: bundle exec rubocop @@ -59,6 +61,7 @@ jobs: with: ruby-version: '3.3' bundler-cache: true + bundler: '2.5.22' - name: Build gem run: bundle exec rake build diff --git a/Gemfile.lock b/Gemfile.lock index 0f44528..5941a89 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -139,4 +139,4 @@ DEPENDENCIES yard (~> 0.9) BUNDLED WITH - 2.7.1 + 2.7.2 From 97e25e57e6401b1f85113dd9bd90b4fa71207c3f Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 12:42:54 +1100 Subject: [PATCH 4/9] fix pry-byebug --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 893c2cd..5cf5e38 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'irb' # Development dependencies gem 'pry', '~> 0.14' -gem 'pry-byebug', '~> 3.10' +gem 'pry-byebug', '~> 3.10', platform: :mri if RUBY_VERSION >= '3.1.0' gem 'rake', '~> 13.0' gem 'rspec', '~> 3.12' gem 'rubocop', '~> 1.50' From 5184ad51e0a9d3a10058545a150aac86536744a7 Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 12:53:12 +1100 Subject: [PATCH 5/9] ci2 --- Gemfile | 3 +++ Gemfile.lock | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 5cf5e38..a80cf63 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,9 @@ gemspec gem 'irb' +# Constrain erb for Ruby 3.1 compatibility +gem 'erb', '< 5.1' # erb 5.1+ requires Ruby >= 3.2 + # Development dependencies gem 'pry', '~> 0.14' gem 'pry-byebug', '~> 3.10', platform: :mri if RUBY_VERSION >= '3.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 5941a89..82642bb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ GEM date (3.5.0) diff-lcs (1.6.2) docile (1.4.1) - erb (5.1.3) + erb (5.0.3) faraday (2.14.0) faraday-net_http (>= 2.0, < 3.5) json @@ -118,7 +118,7 @@ GEM unicode-display_width (3.2.0) unicode-emoji (~> 4.1) unicode-emoji (4.1.0) - uri (1.0.4) + uri (1.1.0) yard (0.9.37) PLATFORMS @@ -126,6 +126,7 @@ PLATFORMS ruby DEPENDENCIES + erb (< 5.1) irb pry (~> 0.14) pry-byebug (~> 3.10) @@ -139,4 +140,4 @@ DEPENDENCIES yard (~> 0.9) BUNDLED WITH - 2.7.2 + 2.5.22 From d63e107b3d9be947988e1e99ae2e245064281dc7 Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 13:02:12 +1100 Subject: [PATCH 6/9] gem 'erb', '< 5.0' --- Gemfile | 2 +- Gemfile.lock | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index a80cf63..e779842 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gemspec gem 'irb' # Constrain erb for Ruby 3.1 compatibility -gem 'erb', '< 5.1' # erb 5.1+ requires Ruby >= 3.2 +gem 'erb', '< 5.0' # erb 5.0+ requires Ruby >= 3.2 # Development dependencies gem 'pry', '~> 0.14' diff --git a/Gemfile.lock b/Gemfile.lock index 82642bb..e7c647c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,11 +10,13 @@ GEM specs: ast (2.4.3) byebug (12.0.0) + cgi (0.5.0) coderay (1.1.3) date (3.5.0) diff-lcs (1.6.2) docile (1.4.1) - erb (5.0.3) + erb (4.0.4) + cgi (>= 0.3.3) faraday (2.14.0) faraday-net_http (>= 2.0, < 3.5) json @@ -126,7 +128,7 @@ PLATFORMS ruby DEPENDENCIES - erb (< 5.1) + erb (< 5.0) irb pry (~> 0.14) pry-byebug (~> 3.10) From 3b705b89c30ca79d5f9cc8f349713b0d6e70b243 Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 13:54:11 +1100 Subject: [PATCH 7/9] pry-byebug in the lockfile for all platforms --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index e779842..2011bbd 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'erb', '< 5.0' # erb 5.0+ requires Ruby >= 3.2 # Development dependencies gem 'pry', '~> 0.14' -gem 'pry-byebug', '~> 3.10', platform: :mri if RUBY_VERSION >= '3.1.0' +gem 'pry-byebug', '~> 3.10', platform: :mri gem 'rake', '~> 13.0' gem 'rspec', '~> 3.12' gem 'rubocop', '~> 1.50' diff --git a/Gemfile.lock b/Gemfile.lock index e7c647c..db7172d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,7 +35,7 @@ GEM lint_roller (1.1.0) logger (1.7.0) method_source (1.1.0) - net-http (0.6.0) + net-http (0.7.0) uri parallel (1.27.0) parser (3.3.10.0) From e0bd408ba0ad536124c2a9a2e3a67209be82601e Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 14:13:04 +1100 Subject: [PATCH 8/9] gem 'pry', '~> 0.14' --- Gemfile | 3 ++- Gemfile.lock | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 2011bbd..5a2eb5d 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,8 @@ gem 'erb', '< 5.0' # erb 5.0+ requires Ruby >= 3.2 # Development dependencies gem 'pry', '~> 0.14' -gem 'pry-byebug', '~> 3.10', platform: :mri +# Note: pry-byebug requires Ruby >= 3.1 (via byebug). Install manually if needed: +# gem install pry-byebug # on Ruby >= 3.1 gem 'rake', '~> 13.0' gem 'rspec', '~> 3.12' gem 'rubocop', '~> 1.50' diff --git a/Gemfile.lock b/Gemfile.lock index db7172d..640fadb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,6 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.3) - byebug (12.0.0) cgi (0.5.0) coderay (1.1.3) date (3.5.0) @@ -48,9 +47,6 @@ GEM pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.11.0) - byebug (~> 12.0) - pry (>= 0.13, < 0.16) psych (5.2.6) date stringio @@ -131,7 +127,6 @@ DEPENDENCIES erb (< 5.0) irb pry (~> 0.14) - pry-byebug (~> 3.10) rake (~> 13.0) rspec (~> 3.12) rubocop (~> 1.50) From 50e1700adffc5dbba4d148bdeebf680338bdc47a Mon Sep 17 00:00:00 2001 From: Chayut Orapinpatipat Date: Fri, 31 Oct 2025 14:19:28 +1100 Subject: [PATCH 9/9] cop --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5a2eb5d..f9dce4f 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'erb', '< 5.0' # erb 5.0+ requires Ruby >= 3.2 # Development dependencies gem 'pry', '~> 0.14' -# Note: pry-byebug requires Ruby >= 3.1 (via byebug). Install manually if needed: +# NOTE: pry-byebug requires Ruby >= 3.1 (via byebug). Install manually if needed: # gem install pry-byebug # on Ruby >= 3.1 gem 'rake', '~> 13.0' gem 'rspec', '~> 3.12'