versacommerce-theme_api_client 0.1.2 → 1.0.1

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
- SHA1:
3
- metadata.gz: ddae795537f35e2728dcf6116c65685321c76508
4
- data.tar.gz: 07dadb3ee73691942fdc0dd81e342fc2c2ec6de1
2
+ SHA256:
3
+ metadata.gz: 4fcf2656faa757b046931d4a22ead1d4cfa15758320b1c32504f897565a5eaba
4
+ data.tar.gz: 4f9bcef22485ca0be490100dee1153b33f916b7f6b840aae47196458a39c141b
5
5
  SHA512:
6
- metadata.gz: 86056b19788e9d2e16755cc70bd66fab38ad5451a74630071e68ca3c761a4768d0906659895e9ad749a8b45f91cf2a87f30a0861c7edcbbd17ed95fd62870838
7
- data.tar.gz: 1bed5146aca67d503c1431e267e82aec087ac2daad155ff5f390260a81adbcd46060e2c5987bfd910e2ed0a5598f356dfc0c9a12d766d1c94e2406906c547da2
6
+ metadata.gz: 6805af2804b62be8808a3119b1bc280b1264a6f711a333b26b86e7bce7198201773fd22b0c929346c8daa4f021b578d44131048a3805916ed305c47ea210980d
7
+ data.tar.gz: 2b3a4a26c23598b963deb0a7fe9941e9ee45df6e8fdd99bec939f7e221c49bdaac5043505ccc3b6406f4828459afa92c70c0b0b5b0e6b0b254664f1d79f4a2df
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.3
data/CLAUDE.md ADDED
@@ -0,0 +1,104 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a Ruby gem that provides an API client for the VersaCommerce Theme API. It allows developers to programmatically manage theme files and directories for VersaCommerce shops.
8
+
9
+ ## Requirements
10
+
11
+ - Ruby >= 3.3.0
12
+ - Dependencies: http (~> 5.0), activesupport (>= 4.2, < 8.0), activemodel (>= 4.2, < 8.0)
13
+
14
+ ## Common Commands
15
+
16
+ ### Setup and Development
17
+ ```bash
18
+ bin/setup # Install dependencies
19
+ bin/console # Launch interactive console for experimentation
20
+ bundle install # Install gem dependencies
21
+ ```
22
+
23
+ ### Building and Publishing
24
+ ```bash
25
+ rake build # Build the gem
26
+ rake install # Build and install gem locally
27
+ rake release # Create git tag, build and push gem to rubygems.org
28
+ ```
29
+
30
+ ## Architecture
31
+
32
+ ### Core Components
33
+
34
+ **Client (lib/versacommerce/theme_api_client.rb)**
35
+ - Entry point for the gem
36
+ - Initialized with authorization token
37
+ - Provides `directories()` and `files()` methods that return relation objects
38
+ - Configurable `base_url` (defaults to https://theme-api.versacommerce.de)
39
+ - Dynamically creates resource classes tied to the client instance
40
+
41
+ **Fetcher (lib/versacommerce/theme_api_client/fetcher.rb)**
42
+ - HTTP communication layer using the `http` gem
43
+ - Handles all HTTP verbs (GET, POST, PATCH, DELETE, HEAD)
44
+ - Adds Theme-Authorization header to all requests
45
+ - Defines custom errors: `RecordNotFoundError` and `UnauthorizedError`
46
+ - Extends HTTP::Response with a `json` method for parsing JSON responses
47
+
48
+ **Relation (lib/versacommerce/theme_api_client/relation.rb)**
49
+ - Base class for DirectoryRelation and FileRelation
50
+ - Implements Enumerable for iteration
51
+ - Provides ActiveRecord-like interface: `find()`, `build()`, `create()`, `delete()`
52
+ - Supports path scoping with `in_path()` method
53
+ - Handles recursive vs non-recursive queries
54
+
55
+ **Resource (lib/versacommerce/theme_api_client/resource.rb)**
56
+ - Base class for Directory and File resources
57
+ - Uses ActiveModel for validations and dirty tracking
58
+ - Implements `save()`, `update()`, `new_record?` methods
59
+ - Each resource class is dynamically created per client instance (see `directory_class` and `file_class` in client)
60
+
61
+ ### Resource Types
62
+
63
+ **Directory (lib/versacommerce/theme_api_client/resources/directory.rb)**
64
+ - Represents theme directories
65
+ - Has `path` attribute
66
+ - Provides `files()` method to access files within the directory
67
+
68
+ **File (lib/versacommerce/theme_api_client/resources/file.rb)**
69
+ - Represents theme files
70
+ - Has `path` and `content` attributes
71
+ - Content loading is conditional: text files load automatically, binary files require explicit `load_content: true`
72
+ - Provides `reload_content()` and `has_content?` methods
73
+
74
+ ### Key Design Patterns
75
+
76
+ **Dynamic Class Creation**: The client creates subclasses of Directory and File at runtime (via `directory_class` and `file_class`), binding them to the specific client instance. This allows each resource to access the client's fetcher and configuration.
77
+
78
+ **Relation Pattern**: Inspired by ActiveRecord, relations provide chainable query interfaces and lazy evaluation. The `in_path()` method modifies the relation's path scope without executing queries.
79
+
80
+ **Path Helpers**: The client provides `directory_path()`, `file_path()`, `download_path()`, and `tree_path()` helper methods that build Pathname objects for API endpoints.
81
+
82
+ ## Module Structure
83
+
84
+ ```
85
+ lib/versacommerce/
86
+ theme_api_client.rb # Main client class
87
+ theme_api_client/
88
+ client.rb # (Appears to be duplicate/alternative entry point)
89
+ fetcher.rb # HTTP client wrapper
90
+ relation.rb # Base relation class
91
+ resource.rb # Base resource class with ActiveModel
92
+ version.rb # Gem version constant
93
+ relations/
94
+ directory_relation.rb
95
+ file_relation.rb
96
+ resources/
97
+ directory.rb
98
+ file.rb
99
+ file_behaviour.rb # Shared file behavior module
100
+ ```
101
+
102
+ ## Testing
103
+
104
+ This gem does not appear to have a test suite in the repository. When adding tests, consider creating a spec/ or test/ directory.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 VersaCommerce
3
+ Copyright (c) 2025 VersaCommerce
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -6,7 +6,7 @@ Versacommerce::ThemeAPIClient is a library to consume the VersaCommerce Theme AP
6
6
 
7
7
  ## Requirements
8
8
 
9
- Ruby ≥ 2.0.0
9
+ Ruby ≥ 3.1.0
10
10
 
11
11
  ## Installation
12
12
 
@@ -84,7 +84,7 @@ module Versacommerce
84
84
  end
85
85
 
86
86
  def with_headers
87
- HTTP.with_headers(accept: 'application/json', 'Theme-Authorization' => authorization)
87
+ HTTP.headers(accept: 'application/json', 'Theme-Authorization' => authorization)
88
88
  end
89
89
  end
90
90
  end
@@ -73,7 +73,7 @@ module Versacommerce
73
73
 
74
74
  def delete
75
75
  unless new_record?
76
- response = fetcher.delete(file_path(path))
76
+ fetcher.delete(file_path(path))
77
77
  content_will_change!
78
78
  self.new_record = true
79
79
  end
@@ -94,7 +94,7 @@ module Versacommerce
94
94
  unless new_record?
95
95
  response = fetcher.get(download_path(path))
96
96
  self.content = response.to_s
97
- clear_attribute_changes(:content)
97
+ clear_attribute_changes([:content])
98
98
  end
99
99
 
100
100
  self
@@ -1,5 +1,5 @@
1
1
  module Versacommerce
2
2
  class ThemeAPIClient
3
- VERSION = Gem::Version.new('0.1.2')
3
+ VERSION = Gem::Version.new('1.0.1')
4
4
  end
5
5
  end
@@ -3,8 +3,7 @@ require_relative 'lib/versacommerce/theme_api_client/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'versacommerce-theme_api_client'
5
5
  spec.version = Versacommerce::ThemeAPIClient::VERSION
6
- spec.authors = ['Tobias Bühlmann']
7
- spec.email = ['buehlmann@versacommerce.de']
6
+ spec.authors = ['VersaCommerce GmbH']
8
7
 
9
8
  spec.summary = 'API Client for the VersaCommercer Theme API.'
10
9
  spec.description = 'This Gem acts as an API Client for the VersaCommerce Theme API.'
@@ -16,14 +15,14 @@ Gem::Specification.new do |spec|
16
15
  spec.executables = spec.files.grep(/\Aexe/) { |f| File.basename(f) }
17
16
  spec.require_paths = ['lib']
18
17
 
19
- spec.required_ruby_version = '>= 2.0.0'
18
+ spec.required_ruby_version = '>= 3.1.0'
20
19
 
21
- spec.add_runtime_dependency 'http', '0.8.3'
22
- spec.add_runtime_dependency 'activesupport', '~> 4.2'
23
- spec.add_runtime_dependency 'activemodel', '~> 4.2'
20
+ spec.add_runtime_dependency 'http', '~> 5.0'
21
+ spec.add_runtime_dependency 'activesupport', '>= 4.2', '< 7.0'
22
+ spec.add_runtime_dependency 'activemodel', '>= 4.2', '< 7.0'
24
23
 
25
- spec.add_development_dependency 'bundler', '~> 1.8'
26
- spec.add_development_dependency 'rake', '~> 10.4'
27
- spec.add_development_dependency 'pry', '0.10.1'
28
- spec.add_development_dependency 'pry-stack_explorer', '0.4.9.2'
24
+ spec.add_development_dependency 'bundler', '>= 1.8'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
+ spec.add_development_dependency 'pry', '~> 0.14'
27
+ spec.add_development_dependency 'pry-stack_explorer', '~> 0.6'
29
28
  end
metadata CHANGED
@@ -1,69 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versacommerce-theme_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - Tobias Bühlmann
8
- autorequire:
7
+ - VersaCommerce GmbH
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2025-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.3
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.3
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.2'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '7.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '4.2'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '7.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: activemodel
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: '4.2'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '7.0'
48
57
  type: :runtime
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
- - - "~>"
61
+ - - ">="
53
62
  - !ruby/object:Gem::Version
54
63
  version: '4.2'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '7.0'
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: bundler
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
59
- - - "~>"
71
+ - - ">="
60
72
  - !ruby/object:Gem::Version
61
73
  version: '1.8'
62
74
  type: :development
63
75
  prerelease: false
64
76
  version_requirements: !ruby/object:Gem::Requirement
65
77
  requirements:
66
- - - "~>"
78
+ - - ">="
67
79
  - !ruby/object:Gem::Version
68
80
  version: '1.8'
69
81
  - !ruby/object:Gem::Dependency
@@ -72,50 +84,51 @@ dependencies:
72
84
  requirements:
73
85
  - - "~>"
74
86
  - !ruby/object:Gem::Version
75
- version: '10.4'
87
+ version: '13.0'
76
88
  type: :development
77
89
  prerelease: false
78
90
  version_requirements: !ruby/object:Gem::Requirement
79
91
  requirements:
80
92
  - - "~>"
81
93
  - !ruby/object:Gem::Version
82
- version: '10.4'
94
+ version: '13.0'
83
95
  - !ruby/object:Gem::Dependency
84
96
  name: pry
85
97
  requirement: !ruby/object:Gem::Requirement
86
98
  requirements:
87
- - - '='
99
+ - - "~>"
88
100
  - !ruby/object:Gem::Version
89
- version: 0.10.1
101
+ version: '0.14'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
93
105
  requirements:
94
- - - '='
106
+ - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: 0.10.1
108
+ version: '0.14'
97
109
  - !ruby/object:Gem::Dependency
98
110
  name: pry-stack_explorer
99
111
  requirement: !ruby/object:Gem::Requirement
100
112
  requirements:
101
- - - '='
113
+ - - "~>"
102
114
  - !ruby/object:Gem::Version
103
- version: 0.4.9.2
115
+ version: '0.6'
104
116
  type: :development
105
117
  prerelease: false
106
118
  version_requirements: !ruby/object:Gem::Requirement
107
119
  requirements:
108
- - - '='
120
+ - - "~>"
109
121
  - !ruby/object:Gem::Version
110
- version: 0.4.9.2
122
+ version: '0.6'
111
123
  description: This Gem acts as an API Client for the VersaCommerce Theme API.
112
124
  email:
113
- - buehlmann@versacommerce.de
114
125
  executables: []
115
126
  extensions: []
116
127
  extra_rdoc_files: []
117
128
  files:
118
129
  - ".gitignore"
130
+ - ".ruby-version"
131
+ - CLAUDE.md
119
132
  - Gemfile
120
133
  - LICENSE.txt
121
134
  - README.md
@@ -138,7 +151,7 @@ homepage: https://github.com/versacommerce/versacommerce-theme_api_client
138
151
  licenses:
139
152
  - MIT
140
153
  metadata: {}
141
- post_install_message:
154
+ post_install_message:
142
155
  rdoc_options: []
143
156
  require_paths:
144
157
  - lib
@@ -146,16 +159,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
159
  requirements:
147
160
  - - ">="
148
161
  - !ruby/object:Gem::Version
149
- version: 2.0.0
162
+ version: 3.1.0
150
163
  required_rubygems_version: !ruby/object:Gem::Requirement
151
164
  requirements:
152
165
  - - ">="
153
166
  - !ruby/object:Gem::Version
154
167
  version: '0'
155
168
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.4.5
158
- signing_key:
169
+ rubygems_version: 3.3.26
170
+ signing_key:
159
171
  specification_version: 4
160
172
  summary: API Client for the VersaCommercer Theme API.
161
173
  test_files: []