activeadmin_active_resource 0.2.0 → 0.2.4

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: 41b5f19734c7469213f38f9fd7ac85f74ba8c948dc6d0ef8ec04d7b4744ed9cf
4
- data.tar.gz: af34834021706ff0e853e0bfa5f3fa3df4de4cfa4f2eda8c3661896a9118a2b2
3
+ metadata.gz: 90cbc4a293441580fae9b56c4ca2e5174df2c2e1db140a1e06be080e214af5e1
4
+ data.tar.gz: fffc4c46e2aa3c352d8d8e94fa0f6adb13b16ee2c094941484b5e7b4246c0981
5
5
  SHA512:
6
- metadata.gz: c2f20563d2be4dc09e7abf208de66300a1d53cca8418ebdceca441f88eb4ba7c189687df2d5af08d6e9714437126651dae33bd2d566920fc17e44f52c14e2a78
7
- data.tar.gz: fae82fe5f50484456d1668d5566eda4e87ecc6299f261e439a3f8a4179b654f53fb6f18f9d86066dd667dd77f07beaa833e2f22df1d2665901d41bdec78a0cf9
6
+ metadata.gz: 7d17626dfce7aec903b32dc299856397bc01cfb92ec93ca4d133e46c52224a2bbf4527da5f64c157e63c1c8cb8ac125ff8a0f8215caebc1fed085eac2be5eccd
7
+ data.tar.gz: 92638fb4870396b7824eeefb47035285517b4f689a9416e2cd5ada29b9ef7d58d45eadb99c36ce0cdcc7b78ea731ba4d2babc7abef02bae1cf5f57c3b719e7e7
data/README.md CHANGED
@@ -1,18 +1,26 @@
1
- # ActiveAdmin + Active Resource [![Gem Version](https://badge.fury.io/rb/activeadmin_active_resource.svg)](https://badge.fury.io/rb/activeadmin_active_resource)
1
+ # Active Admin + Active Resource
2
+ [![Gem Version](https://badge.fury.io/rb/activeadmin_active_resource.svg)](https://badge.fury.io/rb/activeadmin_active_resource) [![CircleCI](https://circleci.com/gh/blocknotes/activeadmin_active_resource.svg?style=svg)](https://circleci.com/gh/blocknotes/activeadmin_active_resource)
2
3
 
3
- An ActiveAdmin plugin to use a REST API in place of a local database as data source using [Active Resource](https://github.com/rails/activeresource).
4
+ An Active Admin plugin to use a REST API data source in place of a local database using [Active Resource](https://github.com/rails/activeresource).
4
5
 
5
- WARNING: this component is a Beta version, some Active Admin functionalities don't work as expected:
6
+ NOTICE: currently some Active Admin features don't work as expected:
6
7
  - Filters: partially supported (see example)
7
- - Edit: fields must be configured explicitly
8
+ - Form fields: some fields must be configured explicitly
8
9
  - Comments: not supported
9
10
 
10
11
  ## Install
11
- - Add to your Gemfile: `gem 'activeadmin_active_resource'`
12
+ - Add to your project's Gemfile (with Active Admin installed): `gem 'activeadmin_active_resource'`
12
13
  - Execute bundle
13
- - Disable comments in active_admin config initializer
14
+ - Disable comments in Active Admin config initializer (`config.comments = false`)
14
15
 
15
- ## Example
16
+ ## Examples
17
+ Please take a look at the examples folder:
18
+ - a Rails6 application with Active Admin and this component, see [here](examples/rails6-admin);
19
+ - a Rails6 API application used as data source, see [here](examples/rails6-api).
20
+
21
+ For another example check the [specs](spec).
22
+
23
+ Basic instructions:
16
24
  - Post model:
17
25
  ```rb
18
26
  class Post < ActiveResource::Base
@@ -72,15 +80,15 @@ end
72
80
  ```
73
81
 
74
82
  ## Notes
75
- If you create a new rails project don't use *--skip-active-record*
83
+ If you create a new rails project don't use *--skip-active-record*.
76
84
 
77
85
  ## Do you like it? Star it!
78
86
  If you use this component just star it. A developer is more motivated to improve a project when there is some interest.
79
87
 
80
- Take a look at [other ActiveAdmin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source) that I made if you are curious.
88
+ Take a look at [other Active Admin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source) if you are curious.
81
89
 
82
90
  ## Contributors
83
- [Mattia Roccoberton](http://blocknot.es): author
91
+ - [Mattia Roccoberton](http://blocknot.es): author
84
92
 
85
93
  ## License
86
- [MIT](LICENSE.txt)
94
+ The gem is available as open-source under the terms of the [MIT](LICENSE.txt).
@@ -15,6 +15,13 @@ end
15
15
 
16
16
  self.collection_parser = ActiveAdmin::ActiveResource::Results
17
17
 
18
+ # ref: https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/ClassMethods.html#method-i-column_for_attribute
19
+ def column_for_attribute(name)
20
+ # => ActiveRecord::ConnectionAdapters::Column
21
+ col_name = name.to_s
22
+ send(:class).columns.find { |col| col.name == col_name }
23
+ end
24
+
18
25
  class << self
19
26
  prepend(FindExt = Module.new do
20
27
  def find(*arguments)
@@ -35,14 +42,32 @@ end
35
42
  {}
36
43
  end
37
44
 
38
- # -> http://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-column_names
45
+ # ref: https://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-content_columns
46
+ def content_columns
47
+ @content_columns ||= columns.reject do |c|
48
+ # c.name == primary_key || # required to update enities
49
+ c.name == inheritance_column ||
50
+ c.name.end_with?("_id") ||
51
+ c.name.end_with?("_count")
52
+ end
53
+ end
54
+
55
+ # ref: http://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-column_names
39
56
  def column_names
40
57
  @column_names ||= columns.map(&:name)
41
58
  end
42
59
 
43
- # -> http://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-columns
60
+ # ref: http://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-columns
44
61
  def columns
45
- @columns ||= known_attributes.map { |col| OpenStruct.new(name: col) }
62
+ # => array of ActiveRecord::ConnectionAdapters::Column
63
+ @columns ||= begin
64
+ schema.map do |name, type|
65
+ col_name = name.to_s
66
+ col_type = type.to_sym
67
+ col_type = :hidden if col_name == 'id'
68
+ OpenStruct.new(name: col_name, type: col_type)
69
+ end
70
+ end
46
71
  end
47
72
 
48
73
  def find_all(options = {})
@@ -111,7 +136,8 @@ end
111
136
  end
112
137
 
113
138
  ::ActiveResource::Connection.class_eval do
139
+ # ref: https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Quoting.html#method-i-quote_column_name
114
140
  def quote_column_name(column_name)
115
- column_name
141
+ column_name.to_s
116
142
  end
117
143
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module ActiveResource
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_active_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-11 00:00:00.000000000 Z
11
+ date: 2020-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 5.1.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: activestorage
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 6.0.3.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 6.0.3.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.33.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.33.0
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: pry
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +80,48 @@ dependencies:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: 0.13.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: puma
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 4.3.5
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 4.3.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec_junit_formatter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.4.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.4.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 4.0.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 4.0.1
55
125
  - !ruby/object:Gem::Dependency
56
126
  name: rubocop
57
127
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +136,62 @@ dependencies:
66
136
  - - "~>"
67
137
  - !ruby/object:Gem::Version
68
138
  version: 0.90.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: selenium-webdriver
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 3.142.7
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 3.142.7
153
+ - !ruby/object:Gem::Dependency
154
+ name: sqlite3
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.4.2
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.4.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: vcr
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 6.0.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 6.0.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: webmock
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 3.9.2
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 3.9.2
69
195
  description: An Active Admin plugin to use Active Resource
70
196
  email: mat@blocknot.es
71
197
  executables: []