app_rail-airtable 0.2.2 → 0.2.3

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: 193745b5de817c15958fbc4fbfe358d3ea1d13ed265bd1dd5719c72d114d342e
4
- data.tar.gz: 49fb36514620c9080bf86d2be89d4d350e537d82b92849c0f2be99c49c030631
3
+ metadata.gz: c2f18121969b1289392808cbd8d44b13c24fdadee380024e1f84815f9c439197
4
+ data.tar.gz: 7d81150a6b3a7c23f147a536488d24461e074ae13b51558164ce1006ab9e7e79
5
5
  SHA512:
6
- metadata.gz: 194060b4bc2767cd88a216d822ab42078756333fa131f72753f3aeb7cf023c99b4670803224d4ac29000d770c24a526fa821d420de1ac69d9588e60121aad4e2
7
- data.tar.gz: 716ddb944e105eccc2afda93ec24d203731bd3d0fababa9f0267421015a77544a1944b911a14713f1b16ce03c01d04a554e14a8cc5fc0fc3ac203eb76747b315
6
+ metadata.gz: 7177fc23a347032cc2b03041e6d74238789b937e9e73fea3fee66584c78ddf6928ece275780be6882af03fc624f665797049eb70266412589cb52d3ec810d4d5
7
+ data.tar.gz: d137d55da455f248203ed5b6996d23b54f2f7cb1301a8e07f8506c37bed397d44456076e61819faaa370d2412cff06e90aa47a824fbe990c1f60495709bc22a7
data/.byebug_history ADDED
@@ -0,0 +1,14 @@
1
+ exit
2
+ @table_definitions.first.all.first.fields.keys
3
+ @table_definitions.first.all.first.fields
4
+ @table_definitions.first.all.first
5
+ @table_definitions.first.first
6
+ @table_definitions.first.instance_variable_get("@fields")
7
+ @table_definitions.first.instance_variable_get("fields")
8
+ @table_definitions.first.instance_variable_get("@fields")
9
+ @table_definitions.first.fields
10
+ @table_definitions.first.table_name
11
+ @table_definitions.first.name
12
+ @table_definitions.first.all
13
+ @table_definitions.first
14
+ @table_definitions
data/Gemfile CHANGED
@@ -5,3 +5,5 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
+ gem "thor"
9
+ gem "byebug"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- app_rail-airtable (0.2.2)
4
+ app_rail-airtable (0.2.3)
5
5
  activesupport
6
6
  airrecord
7
7
  sinatra
@@ -18,6 +18,7 @@ GEM
18
18
  airrecord (1.0.7)
19
19
  faraday (>= 0.10, < 2.0)
20
20
  net-http-persistent
21
+ byebug (11.1.3)
21
22
  concurrent-ruby (1.1.9)
22
23
  connection_pool (2.2.5)
23
24
  diff-lcs (1.4.4)
@@ -73,6 +74,7 @@ GEM
73
74
  rack (~> 2.2)
74
75
  rack-protection (= 2.1.0)
75
76
  tilt (~> 2.0)
77
+ thor (1.1.0)
76
78
  tilt (2.0.10)
77
79
  tzinfo (2.0.4)
78
80
  concurrent-ruby (~> 1.0)
@@ -83,9 +85,11 @@ PLATFORMS
83
85
 
84
86
  DEPENDENCIES
85
87
  app_rail-airtable!
88
+ byebug
86
89
  rack-test
87
90
  rake (~> 12.0)
88
91
  rspec (~> 3.0)
92
+ thor
89
93
 
90
94
  BUNDLED WITH
91
95
  2.1.4
data/bin/ara_generator ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require 'app_rail/airtable'
4
+ require 'byebug'
5
+
6
+ AppRail::Airtable::Generator.start(ARGV)
@@ -1,12 +1,6 @@
1
1
  require 'airrecord'
2
2
  require 'active_support/core_ext/string/inflections'
3
3
 
4
- class String
5
- def snake_case
6
- gsub(" ", "_").underscore
7
- end
8
- end
9
-
10
4
  module AppRail
11
5
  module Airtable
12
6
  class ApplicationRecord < Airrecord::Table
@@ -0,0 +1,28 @@
1
+ require 'active_support/core_ext/string/inflections'
2
+ require 'thor'
3
+ require 'airrecord'
4
+ require 'app_rail/airtable/string_ext'
5
+
6
+ class AppRail::Airtable::Generator < Thor::Group
7
+ include Thor::Actions
8
+
9
+ argument :output_directory
10
+ argument :api_key
11
+ argument :base_id
12
+ argument :tables
13
+
14
+ def self.source_root
15
+ File.join(File.dirname(__FILE__), "..", "..", "..")
16
+ end
17
+
18
+ def create_project
19
+ # Build tables
20
+ @table_definitions = tables.split(",").map {|t| Airrecord.table(api_key, base_id, t.strip) }
21
+ directory('templates/project', output_directory)
22
+ end
23
+
24
+ def self.exit_on_failure?
25
+ true
26
+ end
27
+
28
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def snake_case
3
+ gsub(" ", "_").underscore
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module AppRail
2
2
  module Airtable
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
@@ -1,6 +1,8 @@
1
1
  require "app_rail/airtable/version"
2
2
  require "app_rail/airtable/application_record"
3
3
  require "app_rail/airtable/sinatra"
4
+ require "app_rail/airtable/generator"
5
+ require "app_rail/airtable/string_ext"
4
6
 
5
7
  module AppRail
6
8
  module Airtable
@@ -0,0 +1,2 @@
1
+ AIRTABLE_API_KEY=<%= api_key %>
2
+ AIRTABLE_BASE_ID=<%= base_id %>
@@ -0,0 +1,8 @@
1
+ .DS_STORE
2
+ *.swp
3
+ *.rbc
4
+ *.sass-cache
5
+ /pkg
6
+ /coverage
7
+ .yardoc
8
+ /doc
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ ruby '2.7.4'
7
+
8
+ gem 'app_rail-airtable'
9
+
10
+ # dev
11
+ gem 'dotenv'
12
+
13
+ # test
14
+ gem "rspec"
15
+ gem "rack-test"
@@ -0,0 +1,90 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (6.1.4.1)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (>= 1.6, < 2)
7
+ minitest (>= 5.1)
8
+ tzinfo (~> 2.0)
9
+ zeitwerk (~> 2.3)
10
+ airrecord (1.0.7)
11
+ faraday (>= 0.10, < 2.0)
12
+ net-http-persistent
13
+ app_rail-airtable (0.2.2)
14
+ activesupport
15
+ airrecord
16
+ sinatra
17
+ concurrent-ruby (1.1.9)
18
+ connection_pool (2.2.5)
19
+ diff-lcs (1.4.4)
20
+ dotenv (2.7.6)
21
+ faraday (1.8.0)
22
+ faraday-em_http (~> 1.0)
23
+ faraday-em_synchrony (~> 1.0)
24
+ faraday-excon (~> 1.1)
25
+ faraday-httpclient (~> 1.0.1)
26
+ faraday-net_http (~> 1.0)
27
+ faraday-net_http_persistent (~> 1.1)
28
+ faraday-patron (~> 1.0)
29
+ faraday-rack (~> 1.0)
30
+ multipart-post (>= 1.2, < 3)
31
+ ruby2_keywords (>= 0.0.4)
32
+ faraday-em_http (1.0.0)
33
+ faraday-em_synchrony (1.0.0)
34
+ faraday-excon (1.1.0)
35
+ faraday-httpclient (1.0.1)
36
+ faraday-net_http (1.0.1)
37
+ faraday-net_http_persistent (1.2.0)
38
+ faraday-patron (1.0.0)
39
+ faraday-rack (1.0.0)
40
+ i18n (1.8.10)
41
+ concurrent-ruby (~> 1.0)
42
+ minitest (5.14.4)
43
+ multipart-post (2.1.1)
44
+ mustermann (1.1.1)
45
+ ruby2_keywords (~> 0.0.1)
46
+ net-http-persistent (4.0.1)
47
+ connection_pool (~> 2.2)
48
+ rack (2.2.3)
49
+ rack-protection (2.1.0)
50
+ rack
51
+ rack-test (1.1.0)
52
+ rack (>= 1.0, < 3)
53
+ rspec (3.10.0)
54
+ rspec-core (~> 3.10.0)
55
+ rspec-expectations (~> 3.10.0)
56
+ rspec-mocks (~> 3.10.0)
57
+ rspec-core (3.10.1)
58
+ rspec-support (~> 3.10.0)
59
+ rspec-expectations (3.10.1)
60
+ diff-lcs (>= 1.2.0, < 2.0)
61
+ rspec-support (~> 3.10.0)
62
+ rspec-mocks (3.10.2)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.10.0)
65
+ rspec-support (3.10.2)
66
+ ruby2_keywords (0.0.5)
67
+ sinatra (2.1.0)
68
+ mustermann (~> 1.0)
69
+ rack (~> 2.2)
70
+ rack-protection (= 2.1.0)
71
+ tilt (~> 2.0)
72
+ tilt (2.0.10)
73
+ tzinfo (2.0.4)
74
+ concurrent-ruby (~> 1.0)
75
+ zeitwerk (2.4.2)
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ app_rail-airtable
82
+ dotenv
83
+ rack-test
84
+ rspec
85
+
86
+ RUBY VERSION
87
+ ruby 2.7.4p191
88
+
89
+ BUNDLED WITH
90
+ 2.1.4
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "App Rail Airtable Service",
3
+ "description": "A barebones template to convert Airtable data to App Rail format",
4
+ "buildpacks": [
5
+ {
6
+ "url": "heroku/ruby"
7
+ }
8
+ ],
9
+ "env": {
10
+ "AIRTABLE_API_KEY": {
11
+ "description": "Your Airtable API key."
12
+ },
13
+ "AIRTABLE_BASE_ID": {
14
+ "description": "The ID of the Base you'd like to connect to."
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,5 @@
1
+ $stdout.sync = true
2
+
3
+ require 'dotenv/load'
4
+ require './lib/server'
5
+ run Server
@@ -0,0 +1,15 @@
1
+ require 'app_rail/airtable'
2
+
3
+ <% @table_definitions.each do |td| -%>
4
+ <% keys = td.all.first.fields.keys -%>
5
+ class <%= td.table_name.singularize %> < AppRail::Airtable::ApplicationRecord
6
+ airtable_attr <%= keys.map{|f| "\"#{f}\""}.join(", ") %>
7
+ ar_list_item text: :<%= keys.first.snake_case %>
8
+ end
9
+
10
+ <% end -%>
11
+ class Server < AppRail::Airtable::Sinatra
12
+ <% @table_definitions.each do |td| -%>
13
+ resources :<%= td.table_name.snake_case %>
14
+ <% end -%>
15
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Server do
4
+
5
+ def app
6
+ Server
7
+ end
8
+
9
+ end
@@ -0,0 +1,115 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+
17
+ # Dummy ENV Setup
18
+ ENV['AIRTABLE_API_KEY'] = 'keyABC123'
19
+ ENV['AIRTABLE_BASE_ID'] = 'appABC123'
20
+ ENV['RACK_ENV'] = 'test'
21
+
22
+ require "rack/test"
23
+ require "app_rail/airtable"
24
+
25
+ require './lib/server'
26
+ require './lib/item_recommender'
27
+
28
+ RSpec.configure do |config|
29
+ # rspec-expectations config goes here. You can use an alternate
30
+ # assertion/expectation library such as wrong or the stdlib/minitest
31
+ # assertions if you prefer.
32
+ config.expect_with :rspec do |expectations|
33
+ # This option will default to `true` in RSpec 4. It makes the `description`
34
+ # and `failure_message` of custom matchers include text for helper methods
35
+ # defined using `chain`, e.g.:
36
+ # be_bigger_than(2).and_smaller_than(4).description
37
+ # # => "be bigger than 2 and smaller than 4"
38
+ # ...rather than:
39
+ # # => "be bigger than 2"
40
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
41
+ end
42
+
43
+ # rspec-mocks config goes here. You can use an alternate test double
44
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
45
+ config.mock_with :rspec do |mocks|
46
+ # Prevents you from mocking or stubbing a method that does not exist on
47
+ # a real object. This is generally recommended, and will default to
48
+ # `true` in RSpec 4.
49
+ mocks.verify_partial_doubles = true
50
+ end
51
+
52
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
53
+ # have no way to turn it off -- the option exists only for backwards
54
+ # compatibility in RSpec 3). It causes shared context metadata to be
55
+ # inherited by the metadata hash of host groups and examples, rather than
56
+ # triggering implicit auto-inclusion in groups with matching metadata.
57
+ config.shared_context_metadata_behavior = :apply_to_host_groups
58
+
59
+ # The settings below are suggested to provide a good initial experience
60
+ # with RSpec, but feel free to customize to your heart's content.
61
+ =begin
62
+ # This allows you to limit a spec run to individual examples or groups
63
+ # you care about by tagging them with `:focus` metadata. When nothing
64
+ # is tagged with `:focus`, all examples get run. RSpec also provides
65
+ # aliases for `it`, `describe`, and `context` that include `:focus`
66
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
67
+ config.filter_run_when_matching :focus
68
+
69
+ # Allows RSpec to persist some state between runs in order to support
70
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
71
+ # you configure your source control system to ignore this file.
72
+ config.example_status_persistence_file_path = "spec/examples.txt"
73
+
74
+ # Limits the available syntax to the non-monkey patched syntax that is
75
+ # recommended. For more details, see:
76
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
77
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
78
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
79
+ config.disable_monkey_patching!
80
+
81
+ # This setting enables warnings. It's recommended, but in some cases may
82
+ # be too noisy due to issues in dependencies.
83
+ config.warnings = true
84
+
85
+ # Many RSpec users commonly either run the entire suite or an individual
86
+ # file, and it's useful to allow more verbose output when running an
87
+ # individual spec file.
88
+ if config.files_to_run.one?
89
+ # Use the documentation formatter for detailed output,
90
+ # unless a formatter has already been configured
91
+ # (e.g. via a command-line flag).
92
+ config.default_formatter = "doc"
93
+ end
94
+
95
+ # Print the 10 slowest examples and example groups at the
96
+ # end of the spec run, to help surface which specs are running
97
+ # particularly slow.
98
+ config.profile_examples = 10
99
+
100
+ # Run specs in random order to surface order dependencies. If you find an
101
+ # order dependency and want to debug it, you can fix the order by providing
102
+ # the seed, which is printed after each run.
103
+ # --seed 1234
104
+ config.order = :random
105
+
106
+ # Seed global randomization in this process using the `--seed` CLI option.
107
+ # Setting this allows you to use `--seed` to deterministically reproduce
108
+ # test failures related to randomization by passing the same `--seed` value
109
+ # as the one that triggered the failure.
110
+ Kernel.srand config.seed
111
+ =end
112
+
113
+ config.include Rack::Test::Methods
114
+
115
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_rail-airtable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-18 00:00:00.000000000 Z
11
+ date: 2021-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -88,6 +88,7 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - ".DS_Store"
91
+ - ".byebug_history"
91
92
  - ".gitignore"
92
93
  - ".rspec"
93
94
  - ".travis.yml"
@@ -97,12 +98,24 @@ files:
97
98
  - README.md
98
99
  - Rakefile
99
100
  - app_rail-airtable.gemspec
101
+ - bin/ara_generator
100
102
  - bin/console
101
103
  - bin/setup
102
104
  - lib/app_rail/airtable.rb
103
105
  - lib/app_rail/airtable/application_record.rb
106
+ - lib/app_rail/airtable/generator.rb
104
107
  - lib/app_rail/airtable/sinatra.rb
108
+ - lib/app_rail/airtable/string_ext.rb
105
109
  - lib/app_rail/airtable/version.rb
110
+ - templates/project/.env.tt
111
+ - templates/project/.gitignore
112
+ - templates/project/Gemfile
113
+ - templates/project/Gemfile.lock
114
+ - templates/project/app.json
115
+ - templates/project/config.ru
116
+ - templates/project/lib/server.rb.tt
117
+ - templates/project/spec/server_spec.rb
118
+ - templates/project/spec/spec_helper.rb
106
119
  homepage: https://github.com/FutureWorkshops/app_rail-airtable
107
120
  licenses:
108
121
  - MIT