From 6e01c43d76c8fc7e337c8d87ee68ea1fb2124f36 Mon Sep 17 00:00:00 2001 From: Quentin Champenois Date: Thu, 16 Jan 2025 19:41:49 +0100 Subject: [PATCH] feat: Bundler setup --- .github/workflows/main.yml | 6 +++--- .ruby-version | 2 +- Gemfile | 1 - Gemfile.lock | 4 ++-- bin/console | 2 +- grist-ruby.gemspec => grist.gemspec | 6 +++--- lib/grist.rb | 8 ++++++++ lib/grist/client.rb | 11 +++++++++++ lib/grist/ruby.rb | 10 ---------- lib/grist/{ruby => }/version.rb | 0 spec/grist/ruby_spec.rb | 6 +----- spec/lib/grist/client_spec.rb | 16 ++++++++++++++++ spec/spec_helper.rb | 3 ++- 13 files changed, 48 insertions(+), 27 deletions(-) rename grist-ruby.gemspec => grist.gemspec (92%) create mode 100644 lib/grist.rb create mode 100644 lib/grist/client.rb delete mode 100644 lib/grist/ruby.rb rename lib/grist/{ruby => }/version.rb (100%) create mode 100644 spec/lib/grist/client_spec.rb diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d57aa00..15c93b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ on: jobs: build: runs-on: ubuntu-latest - name: Ruby ${{ matrix.ruby }} + name: Ruby ${{ matrix.grist }} strategy: matrix: ruby: @@ -19,9 +19,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: grist/setup-grist@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: ${{ matrix.grist }} bundler-cache: true - name: Run the default task run: bundle exec rake diff --git a/.ruby-version b/.ruby-version index a603bb5..a4f52a5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.5 +3.2.0 \ No newline at end of file diff --git a/Gemfile b/Gemfile index 616e43b..98217ad 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -# Specify your gem's dependencies in grist-ruby.gemspec gemspec gem "rake", "~> 13.0" diff --git a/Gemfile.lock b/Gemfile.lock index d91dad9..3c1f022 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - grist-ruby (0.1.0) + grist-grist (0.1.0) GEM remote: https://rubygems.org/ @@ -52,7 +52,7 @@ PLATFORMS arm64-darwin-22 DEPENDENCIES - grist-ruby! + grist-grist! rake (~> 13.0) rspec (~> 3.0) rubocop (~> 1.21) diff --git a/bin/console b/bin/console index 1fb4b6f..5e62dbc 100755 --- a/bin/console +++ b/bin/console @@ -2,7 +2,7 @@ # frozen_string_literal: true require "bundler/setup" -require "grist/ruby" +require "grist" # 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. diff --git a/grist-ruby.gemspec b/grist.gemspec similarity index 92% rename from grist-ruby.gemspec rename to grist.gemspec index 656502a..2da37b9 100644 --- a/grist-ruby.gemspec +++ b/grist.gemspec @@ -1,9 +1,9 @@ # frozen_string_literal: true -require_relative "lib/grist/ruby/version" +require_relative "lib/grist/version" Gem::Specification.new do |spec| - spec.name = "grist-ruby" + spec.name = "grist-grist" spec.version = Grist::Ruby::VERSION spec.authors = ["quentinchampenois"] spec.email = ["26109239+Quentinchampenois@users.noreply.github.com"] @@ -12,7 +12,7 @@ Gem::Specification.new do |spec| spec.description = "Use this gem to interact with the a Grist API from your Ruby application." spec.homepage = "https://github.com/quentinchampenois/grist-ruby" spec.license = "MIT" - spec.required_ruby_version = ">= 2.6.0" + spec.required_ruby_version = ">= 3.2.0" # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" diff --git a/lib/grist.rb b/lib/grist.rb new file mode 100644 index 0000000..17be3e9 --- /dev/null +++ b/lib/grist.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require_relative "grist/version" + +module Grist + class Error < StandardError; end + # Your code goes here... +end diff --git a/lib/grist/client.rb b/lib/grist/client.rb new file mode 100644 index 0000000..e652157 --- /dev/null +++ b/lib/grist/client.rb @@ -0,0 +1,11 @@ +module Grist + class Client + attr_accessor :base_url + + BASE_URL = "https://api.getgrist.com" + + def initialize(url: nil) + @base_url = url || BASE_URL + end + end +end \ No newline at end of file diff --git a/lib/grist/ruby.rb b/lib/grist/ruby.rb deleted file mode 100644 index 09d148d..0000000 --- a/lib/grist/ruby.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -require_relative "ruby/version" - -module Grist - module Ruby - class Error < StandardError; end - # Your code goes here... - end -end diff --git a/lib/grist/ruby/version.rb b/lib/grist/version.rb similarity index 100% rename from lib/grist/ruby/version.rb rename to lib/grist/version.rb diff --git a/spec/grist/ruby_spec.rb b/spec/grist/ruby_spec.rb index e71d17e..72a721e 100644 --- a/spec/grist/ruby_spec.rb +++ b/spec/grist/ruby_spec.rb @@ -2,10 +2,6 @@ RSpec.describe Grist::Ruby do it "has a version number" do - expect(Grist::Ruby::VERSION).not_to be nil - end - - it "does something useful" do - expect(false).to eq(true) + expect(Grist::Ruby::VERSION).to eq "0.1.0" end end diff --git a/spec/lib/grist/client_spec.rb b/spec/lib/grist/client_spec.rb new file mode 100644 index 0000000..9822599 --- /dev/null +++ b/spec/lib/grist/client_spec.rb @@ -0,0 +1,16 @@ +require "spec_helper" + +RSpec.describe Grist::Client do + subject { described_class.new } + + describe "#initialize" do + it "initializes with a default base_url" do + expect(subject.base_url).to eq("https://api.getgrist.com") + end + + it "initializes with a custom base_url" do + client = described_class.new(url: "https://api.example.com") + expect(client.base_url).to eq("https://api.example.com") + end + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5fb9f56..6e3ec8f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true -require "grist/ruby" +require "bundler/setup" +require "grist/client" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure