kao-files-client 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5a28cad3f10a0a7f80686a247cf741329508392decf0fad5ef11e6918a77c77d
4
+ data.tar.gz: 8a73da77cc7d4013aa01692caea944909d231d4fad85048f92a4e86da6ff8827
5
+ SHA512:
6
+ metadata.gz: e0b8dcf4005d1762f7772e4831f41302ef48ed179cdbff91a82aa57f5482332c70bff9fe356fe4d3ad7348479cbafe9866eff7bee44d1032e5c5e49d233f4d99
7
+ data.tar.gz: 24225ebefe01fe91348f8ab19b9377864874c40fdc1e1a380bf7dccbfa5a0dc758402c1ba87078a10d68a6876a708a3be4827ba306fccda050adef4217900d00
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in kao-files-client.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kao-files-client (0.1.0)
5
+ faraday
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.4.4)
11
+ faraday (1.8.0)
12
+ faraday-em_http (~> 1.0)
13
+ faraday-em_synchrony (~> 1.0)
14
+ faraday-excon (~> 1.1)
15
+ faraday-httpclient (~> 1.0.1)
16
+ faraday-net_http (~> 1.0)
17
+ faraday-net_http_persistent (~> 1.1)
18
+ faraday-patron (~> 1.0)
19
+ faraday-rack (~> 1.0)
20
+ multipart-post (>= 1.2, < 3)
21
+ ruby2_keywords (>= 0.0.4)
22
+ faraday-em_http (1.0.0)
23
+ faraday-em_synchrony (1.0.0)
24
+ faraday-excon (1.1.0)
25
+ faraday-httpclient (1.0.1)
26
+ faraday-net_http (1.0.1)
27
+ faraday-net_http_persistent (1.2.0)
28
+ faraday-patron (1.0.0)
29
+ faraday-rack (1.0.0)
30
+ multipart-post (2.1.1)
31
+ rake (12.3.3)
32
+ rspec (3.10.0)
33
+ rspec-core (~> 3.10.0)
34
+ rspec-expectations (~> 3.10.0)
35
+ rspec-mocks (~> 3.10.0)
36
+ rspec-core (3.10.1)
37
+ rspec-support (~> 3.10.0)
38
+ rspec-expectations (3.10.1)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-mocks (3.10.2)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-support (3.10.3)
45
+ ruby2_keywords (0.0.5)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ kao-files-client!
52
+ rake (~> 12.0)
53
+ rspec (~> 3.0)
54
+
55
+ BUNDLED WITH
56
+ 2.1.4
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Kao::Files::Client
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kao/files/client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'kao-files-client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kao-files-client
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kao-files-client.
36
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kao/files/client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ require_relative 'lib/kao/files/client/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "kao-files-client"
5
+ spec.version = Kao::Files::Client::VERSION
6
+ spec.authors = ["shinichi-sesame"]
7
+ spec.email = ["mail.waka@gmail.com"]
8
+
9
+ spec.summary = %q{Kao Client for Files}
10
+ spec.description = %q{Kao Client for Files}
11
+ spec.homepage = "https://github.com/shinichi-sesame/kao-files-client"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ # if spec.respond_to?(:metadata)
15
+ # spec.metadata['allowed_push_host'] = 'http://mygemserver.com'
16
+ # else
17
+ # raise 'RubyGems 2.0 or newer is required to protect against ' \
18
+ # 'public gem pushes.'
19
+ # end
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = spec.homepage
23
+ spec.metadata["changelog_uri"] = spec.homepage
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency 'faraday'
35
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require_relative './base'
3
+
4
+ module Kao
5
+ module Files
6
+ module Adapter
7
+ class Api < Base
8
+ def initialize
9
+ url = ENV['FILES_API_URL'] || 'http://localhost:8080'
10
+ @client = Faraday.new(url: url) do |conn|
11
+ conn.adapter Faraday.default_adapter
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kao
4
+ module Files
5
+ module Adapter
6
+ class Base
7
+ attr_reader :client
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Kao
2
+ module Files
3
+ module Client
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require "kao/files/client/version"
2
+
3
+ module Kao
4
+ module Files
5
+ module Client
6
+ class Error < StandardError; end
7
+
8
+ def file(params = {})
9
+ @file ||= Kao::Files::Models::File.new(params)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ require 'kaizen/files/adapter/api'
3
+
4
+ module Kao
5
+ module Files
6
+ module Models
7
+ class Base
8
+ include ActiveModel::Model
9
+ include ActiveModel::Attributes
10
+
11
+ attribute :id, :string
12
+
13
+ attr_reader :api
14
+
15
+ def initialize(attributes = {})
16
+ @api ||= Kaizen::Files::Adapter::Api.new
17
+
18
+ super(convert_to_snake_case(attributes))
19
+ end
20
+
21
+ protected
22
+
23
+ def convert_to_snake_case(attributes)
24
+ attributes = attributes.map do |key, val|
25
+ [key.to_s.underscore, val]
26
+ end.to_h
27
+ end
28
+
29
+ def assign_attributes_only_current_attributes(attributes)
30
+ assign_attributes(attributes.deep_stringify_keys.slice(*self.class.attribute_types.keys))
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ require_relative './base'
3
+
4
+ module Kao
5
+ module Files
6
+ module Models
7
+ class File < Base
8
+ attribute :url, :string
9
+ attribute :thumbnails, array: :string
10
+
11
+ def detail
12
+ response = @api.client.get do |req|
13
+ req.url "/files/#{id}"
14
+ req.headers['Content-Type'] = 'application/json'
15
+ end
16
+
17
+ res = convert_to_snake_case(JSON.parse(response.body))
18
+ assign_attributes_only_current_attributes(res)
19
+
20
+ self
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kao-files-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - shinichi-sesame
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Kao Client for Files
28
+ email:
29
+ - mail.waka@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - README.md
38
+ - Rakefile
39
+ - bin/console
40
+ - bin/setup
41
+ - kao-files-client.gemspec
42
+ - lib/kao/files/adapter/api.rb
43
+ - lib/kao/files/adapter/base.rb
44
+ - lib/kao/files/client.rb
45
+ - lib/kao/files/client/version.rb
46
+ - lib/kao/files/models/base.rb
47
+ - lib/kao/files/models/file.rb
48
+ homepage: https://github.com/shinichi-sesame/kao-files-client
49
+ licenses: []
50
+ metadata:
51
+ homepage_uri: https://github.com/shinichi-sesame/kao-files-client
52
+ source_code_uri: https://github.com/shinichi-sesame/kao-files-client
53
+ changelog_uri: https://github.com/shinichi-sesame/kao-files-client
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.3.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.1.4
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Kao Client for Files
73
+ test_files: []