artemis 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be41d5677f98282ad274f675f696c6d092fb7d0279d8986492a615e81c024d93
4
- data.tar.gz: d9877242e814d7c20b24b217eb2a3c762699ae21d69ddf1e926e762c79854e59
3
+ metadata.gz: fcf01b2987aaf247cee4afa02982fd582208ea0b48f3042ed207e7bb5ed6fdd8
4
+ data.tar.gz: 4eea51e39bbe709d579d08a409d09c2a95495590ab99609834d0af735cc0c46a
5
5
  SHA512:
6
- metadata.gz: 3c16b35fa42042a378ea42920155fd4ea35d1289f65868be9883a50d3ba5dfd329978ea24847f4de4372c585bdb351ab8f4a6c65072fa7d49013d9948d5f08ed
7
- data.tar.gz: a6c6034a1b524165b193a5dc96efa60a4516aa28a36fbb0a16b5fdec5bdcb868d4142f97c756cb62cfc46926d14de8aaf233b7c1876627e5806366088c898f57
6
+ metadata.gz: a0f862a4301a613dfe0fadefe9bdbad4170f2b6af1ef6f5db859fb13d40dc0065a1d93d37cab4f44790c90c1b624bf62d4b7777ebaa67e38028be0816d14d19d
7
+ data.tar.gz: 0b197e80bf6ffe84c489423804d8b67fa18f37c57679015308598284090d5ab9adcdea587a27c6e49312c741642e5fe03675a594e6b66695af08dc344fb76db3
@@ -15,6 +15,7 @@ jobs:
15
15
  - '2.7'
16
16
  - '2.6'
17
17
  gemfile:
18
+ - gemfiles/rails_71.gemfile
18
19
  - gemfiles/rails_70.gemfile
19
20
  - gemfiles/rails_61.gemfile
20
21
  - gemfiles/rails_60.gemfile
@@ -48,12 +49,16 @@ jobs:
48
49
  gemfile: gemfiles/rails_51.gemfile
49
50
  - ruby_version: '3.0'
50
51
  gemfile: gemfiles/rails_50.gemfile
52
+ - ruby_version: '2.7'
53
+ gemfile: gemfiles/rails_71.gemfile
51
54
  - ruby_version: '2.7'
52
55
  gemfile: gemfiles/rails_52.gemfile
53
56
  - ruby_version: '2.7'
54
57
  gemfile: gemfiles/rails_51.gemfile
55
58
  - ruby_version: '2.7'
56
59
  gemfile: gemfiles/rails_50.gemfile
60
+ - ruby_version: '2.6'
61
+ gemfile: gemfiles/rails_71.gemfile
57
62
  - ruby_version: '2.6'
58
63
  gemfile: gemfiles/rails_70.gemfile
59
64
  runs-on: ubuntu-22.04
@@ -96,7 +101,7 @@ jobs:
96
101
  - 'ruby-head'
97
102
  gemfile:
98
103
  - gemfiles/rails_edge.gemfile
99
- - gemfiles/rails_70.gemfile
104
+ - gemfiles/rails_71.gemfile
100
105
  runs-on: ubuntu-22.04
101
106
  env:
102
107
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
data/Appraisals CHANGED
@@ -4,6 +4,15 @@ appraise "rails_edge" do
4
4
  gem "railties"
5
5
  gem "activesupport"
6
6
  end
7
+
8
+ gem "rackup"
9
+ end
10
+
11
+ appraise "rails_71" do
12
+ gem "rails", '~> 7.1.0.beta1'
13
+ gem "railties", '~> 7.1.0.beta1'
14
+ gem "activesupport", '~> 7.1.0.beta1'
15
+ gem "rackup"
7
16
  end
8
17
 
9
18
  appraise "rails_70" do
data/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
- ## Unreleased
1
+ ## v0.9.0
2
2
 
3
- - New entries come here...
3
+ #### New Features
4
+
5
+ - Rails 7.1.0.beta1 is now officially supported
6
+
7
+ #### Fixes
8
+
9
+ - Fixes an issue where `graphql` gem `2.1.0` may not work with `graphql-client` (`b144ee2f`)
10
+
11
+ ## [v0.8.0](https://github.com/yuki24/artemis/tree/v0.8.0)
12
+
13
+ _<sup>released at 2023-01-05 05:29:37 UTC</sup>_
14
+
15
+ #### New Features
16
+
17
+ - Ruby 3.2 is now officially supported
4
18
 
5
19
  ## [v0.7.0](https://github.com/yuki24/artemis/tree/v0.7.0)
6
20
 
data/artemis.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.add_dependency "activesupport", ">= 4.0.0"
19
19
  spec.add_dependency "railties", ">= 4.0.0"
20
- spec.add_dependency "graphql", ">= 1.8"
20
+ spec.add_dependency "graphql", "< 2.1"
21
21
  spec.add_dependency "graphql-client", ">= 0.13.0"
22
22
 
23
23
  spec.add_development_dependency "appraisal", ">= 2.2"
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry"
6
+ gem "pry-byebug", platforms: :mri
7
+ gem "curb", ">= 0.9.6"
8
+ gem "webrick"
9
+ gem "rails", "~> 7.1.0.beta1"
10
+ gem "railties", "~> 7.1.0.beta1"
11
+ gem "activesupport", "~> 7.1.0.beta1"
12
+ gem "rackup"
13
+
14
+ gemspec path: "../"
@@ -12,5 +12,6 @@ gem "pry"
12
12
  gem "pry-byebug", platforms: :mri
13
13
  gem "curb", ">= 0.9.6"
14
14
  gem "webrick"
15
+ gem "rackup"
15
16
 
16
17
  gemspec path: "../"
@@ -8,6 +8,12 @@ rescue LoadError
8
8
  # no-op... Rails 7.0 requires this.
9
9
  end
10
10
 
11
+ begin
12
+ require 'active_support/deprecation'
13
+ require 'active_support/deprecator'
14
+ rescue LoadError
15
+ end
16
+
11
17
  require 'active_support/core_ext/numeric/time'
12
18
  require 'net/http/persistent'
13
19
 
@@ -61,7 +61,7 @@ module Artemis
61
61
  if app.config.eager_load && app.config.cache_classes
62
62
  Artemis::GraphQLEndpoint.registered_services.each do |endpoint_name|
63
63
  begin
64
- require endpoint_name # Rails 7.0 requires this.
64
+ require_dependency endpoint_name # Rails 7.0+ requires this.
65
65
  rescue LoadError
66
66
  # no-op...
67
67
  end
@@ -1,3 +1,3 @@
1
1
  module Artemis
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -2,6 +2,13 @@ require 'json'
2
2
  require 'rack'
3
3
  require 'webrick'
4
4
 
5
+ RACK_SERVER = begin
6
+ require 'rackup/handler/webrick'
7
+ Rackup::Handler::WEBrick
8
+ rescue LoadError
9
+ Rack::Handler::WEBrick
10
+ end
11
+
5
12
  describe 'Adapters' do
6
13
  FakeServer = ->(env) {
7
14
  case env['PATH_INFO']
@@ -61,7 +68,7 @@ describe 'Adapters' do
61
68
  Artemis::Adapters::AbstractAdapter.send(:attr_writer, :uri, :timeout)
62
69
 
63
70
  @server_thread = Thread.new do
64
- Rack::Handler::WEBrick.run(FakeServer, Port: 8000, Logger: WEBrick::Log.new('/dev/null'), AccessLog: [])
71
+ RACK_SERVER.run(FakeServer, Port: 8000, Logger: WEBrick::Log.new('/dev/null'), AccessLog: [])
65
72
  end
66
73
 
67
74
  loop do
@@ -75,7 +82,7 @@ describe 'Adapters' do
75
82
  end
76
83
 
77
84
  after :all do
78
- Rack::Handler::WEBrick.shutdown
85
+ RACK_SERVER.shutdown
79
86
  @server_thread.terminate
80
87
  end
81
88
 
@@ -1,56 +1,63 @@
1
1
  describe "#{GraphQL::Client} Autoloading" do
2
2
  describe ".load_constant" do
3
3
  it "loads the specified constant if there is a matching graphql file" do
4
- Metaphysics.send(:remove_const, :Artist) if Metaphysics.constants.include?(:Artist)
4
+ Github.send(:remove_const, :User) if Github.constants.include?(:User)
5
5
 
6
- Metaphysics.load_constant(:Artist)
6
+ Github.load_constant(:User)
7
7
 
8
- expect(defined?(Metaphysics::Artist)).to eq('constant')
8
+ expect(defined?(Github::User)).to eq('constant')
9
9
  end
10
10
 
11
11
  it "does nothing and returns nil if there is no matching file" do
12
- expect(Metaphysics.load_constant(:DoesNotExist)).to be_nil
12
+ expect(Github.load_constant(:DoesNotExist)).to be_nil
13
13
  end
14
14
  end
15
15
 
16
16
  describe ".preload!" do
17
17
  it "preloads all the graphQL files in the query paths" do
18
- %i(Artist Artists Artwork ArtistFields)
19
- .select {|const_name| Metaphysics.constants.include?(const_name) }
20
- .each {|const_name| Metaphysics.send(:remove_const, const_name) }
18
+ %i(User UserRepositories Repository RepositoryFields)
19
+ .select {|const_name| Github.constants.include?(const_name) }
20
+ .each {|const_name| Github.send(:remove_const, const_name) }
21
21
 
22
- Metaphysics.preload!
22
+ Github.preload!
23
23
 
24
- expect(defined?(Metaphysics::Artist)).to eq('constant')
25
- expect(defined?(Metaphysics::Artwork)).to eq('constant')
24
+ expect(defined?(Github::User)).to eq('constant')
25
+ expect(defined?(Github::Repository)).to eq('constant')
26
26
  end
27
27
  end
28
28
 
29
29
  it "dynamically loads the matching GraphQL query and sets it to a constant" do
30
- Metaphysics.send(:remove_const, :Artist) if Metaphysics.constants.include?(:Artist)
30
+ Github.send(:remove_const, :User) if Github.constants.include?(:User)
31
31
 
32
- query = Metaphysics::Artist
32
+ query = Github::User
33
33
 
34
34
  expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
35
- query Metaphysics__Artist($id: String!) {
36
- artist(id: $id) {
35
+ query Github__User {
36
+ user(login: "yuki24") {
37
+ id
37
38
  name
38
- bio
39
- birthday
40
39
  }
41
40
  }
42
41
  GRAPHQL
43
42
  end
44
43
 
45
44
  it "dynamically loads the matching GraphQL fragment and sets it to a constant" do
46
- Metaphysics.send(:remove_const, :ArtistFields) if Metaphysics.constants.include?(:ArtistFields)
45
+ Github.send(:remove_const, :RepositoryFields) if Github.constants.include?(:RepositoryFields)
47
46
 
48
- query = Metaphysics::ArtistFields
47
+ query = Github::RepositoryFields
49
48
 
50
49
  expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
51
- fragment Metaphysics__ArtistFields on Artist {
52
- hometown
53
- deathday
50
+ fragment Github__RepositoryFields on Repository {
51
+ name
52
+ nameWithOwner
53
+ url
54
+ updatedAt
55
+ languages(first: 1) {
56
+ nodes {
57
+ name
58
+ color
59
+ }
60
+ }
54
61
  }
55
62
  GRAPHQL
56
63
  end
@@ -58,25 +65,24 @@ describe "#{GraphQL::Client} Autoloading" do
58
65
  it "correctly loads the matching GraphQL query even when the top-level constant with the same name exists" do
59
66
  # In Ruby <= 2.4 top-level constants can be looked up through a namespace, which turned out to be a bad practice.
60
67
  # This has been removed in 2.5, but in earlier versions still suffer from this behaviour.
61
- Metaphysics.send(:remove_const, :Artist) if Metaphysics.constants.include?(:Artist)
62
- Object.send(:remove_const, :Artist) if Object.constants.include?(:Artist)
68
+ Github.send(:remove_const, :User) if Github.constants.include?(:User)
69
+ Object.send(:remove_const, :User) if Object.constants.include?(:User)
63
70
 
64
71
  begin
65
- Object.send(:const_set, :Artist, 1)
72
+ Object.send(:const_set, :User, 1)
66
73
 
67
- Metaphysics.artist
74
+ Github.user
68
75
  ensure
69
- Object.send(:remove_const, :Artist)
76
+ Object.send(:remove_const, :User)
70
77
  end
71
78
 
72
- query = Metaphysics::Artist
79
+ query = Github::User
73
80
 
74
81
  expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
75
- query Metaphysics__Artist($id: String!) {
76
- artist(id: $id) {
82
+ query Github__User {
83
+ user(login: "yuki24") {
84
+ id
77
85
  name
78
- bio
79
- birthday
80
86
  }
81
87
  }
82
88
  GRAPHQL
@@ -84,63 +90,63 @@ describe "#{GraphQL::Client} Autoloading" do
84
90
 
85
91
  it "raises an exception when the path was resolved but the file does not exist" do
86
92
  begin
87
- Metaphysics.graphql_file_paths << "metaphysics/removed.graphql"
93
+ Github.graphql_file_paths << "github/removed.graphql"
88
94
 
89
- expect { Metaphysics::Removed }.to raise_error(Errno::ENOENT)
95
+ expect { Github::Removed }.to raise_error(Errno::ENOENT)
90
96
  ensure
91
- Metaphysics.graphql_file_paths.delete("metaphysics/removed.graphql")
97
+ Github.graphql_file_paths.delete("github/removed.graphql")
92
98
  end
93
99
  end
94
100
 
95
101
  it "raises an NameError when there is no graphql file that matches the const name" do
96
- expect { Metaphysics::DoesNotExist }.to raise_error(NameError)
102
+ expect { Github::DoesNotExist }.to raise_error(NameError)
97
103
  end
98
104
 
99
105
  xit "defines the query method when the matching class method gets called for the first time" do
100
- Metaphysics.undef_method(:artwork) if Metaphysics.public_instance_methods.include?(:artwork)
106
+ Github.undef_method(:user) if Github.public_instance_methods.include?(:user)
101
107
 
102
- Metaphysics.artwork
108
+ Github.user
103
109
 
104
- expect(Metaphysics.public_instance_methods).to include(:artwork)
110
+ expect(Github.public_instance_methods).to include(:user)
105
111
  end
106
112
 
107
113
  it "raises an NameError when there is no graphql file that matches the class method name" do
108
- expect { Metaphysics.does_not_exist }.to raise_error(NameError)
114
+ expect { Github.does_not_exist }.to raise_error(NameError)
109
115
  end
110
116
 
111
117
  it "raises an NameError when the class method name matches a fragment name" do
112
- expect { Metaphysics.artist_fragment }.to raise_error(NameError)
118
+ expect { Github.repository_fields_fragment }.to raise_error(NameError)
113
119
  end
114
120
 
115
121
  it "responds to a class method that has a matching graphQL file" do
116
- expect(Metaphysics).to respond_to(:artwork)
122
+ expect(Github).to respond_to(:user)
117
123
  end
118
124
 
119
125
  it "does not respond to class methods that do not have a matching graphQL file" do
120
- expect(Metaphysics).not_to respond_to(:does_not_exist)
126
+ expect(Github).not_to respond_to(:does_not_exist)
121
127
  end
122
128
 
123
129
  xit "defines the query method when the matching instance method gets called for the first time" do
124
- Metaphysics.undef_method(:artwork) if Metaphysics.public_instance_methods.include?(:artwork)
130
+ Github.undef_method(:user) if Github.public_instance_methods.include?(:user)
125
131
 
126
- Metaphysics.new.artwork
132
+ Github.new.user
127
133
 
128
- expect(Metaphysics.public_instance_methods).to include(:artwork)
134
+ expect(Github.public_instance_methods).to include(:user)
129
135
  end
130
136
 
131
137
  it "raises an NameError when there is no graphql file that matches the instance method name" do
132
- expect { Metaphysics.new.does_not_exist }.to raise_error(NameError)
138
+ expect { Github.new.does_not_exist }.to raise_error(NameError)
133
139
  end
134
140
 
135
141
  it "raises an NameError when the instance method name matches a fragment name" do
136
- expect { Metaphysics.new.artist_fragment }.to raise_error(NameError)
142
+ expect { Github.new.repository_fields_fragment }.to raise_error(NameError)
137
143
  end
138
144
 
139
145
  it "responds to the method that has a matching graphQL file" do
140
- expect(Metaphysics.new).to respond_to(:artwork)
146
+ expect(Github.new).to respond_to(:user)
141
147
  end
142
148
 
143
149
  it "does not respond to methods that do not have a matching graphQL file" do
144
- expect(Metaphysics.new).not_to respond_to(:does_not_exist)
150
+ expect(Github.new).not_to respond_to(:does_not_exist)
145
151
  end
146
152
  end
@@ -3,7 +3,7 @@ require 'active_support/core_ext/module/attribute_accessors'
3
3
  describe "#{GraphQL::Client} Callbacks" do
4
4
  Client = Class.new(Artemis::Client) do
5
5
  def self.name
6
- 'Metaphysics'
6
+ 'Github'
7
7
  end
8
8
 
9
9
  mattr_accessor :before_callback, :after_callback
@@ -35,20 +35,20 @@ describe "#{GraphQL::Client} Callbacks" do
35
35
 
36
36
  describe ".before_execute" do
37
37
  it "gets invoked before executing" do
38
- Client.artist(id: 'yayoi-kusama', context: { user_id: 'yuki24' })
38
+ Client.repository(owner: "yuki24", name: "artemis", context: { user_id: 'yuki24' })
39
39
 
40
40
  document, operation_name, variables, context = Client.before_callback
41
41
 
42
- expect(document).to eq(Client::Artist.document)
43
- expect(operation_name).to eq('Client__Artist')
44
- expect(variables).to eq('id' => 'yayoi-kusama')
42
+ expect(document).to eq(Client::Repository.document)
43
+ expect(operation_name).to eq('Client__Repository')
44
+ expect(variables).to eq("name" => "artemis", "owner" => "yuki24")
45
45
  expect(context).to eq(user_id: 'yuki24')
46
46
  end
47
47
  end
48
48
 
49
49
  describe ".after_execute" do
50
50
  it "gets invoked after executing" do
51
- Client.artwork
51
+ Client.user
52
52
 
53
53
  data, errors, extensions = Client.after_callback
54
54