action_csv 0.1.0 → 0.1.5

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
2
  SHA256:
3
- metadata.gz: e0fa68fa768acfd2ebf1f0c639ffa5dfd396ef0ea27fb5eca4da297d3771d3c5
4
- data.tar.gz: 73f2de04b1a3e5564cadf0823f6b62edd24f94c9971949d3467169a3cea87ac3
3
+ metadata.gz: 10da0112b4e38dc497b11442f127a1e3bee478a19f975fc963484a71eed68e71
4
+ data.tar.gz: 568017d0c3cec0a38f2c0c7658b8251db98923c9fc448cfb9b25ba4171fe7104
5
5
  SHA512:
6
- metadata.gz: 29f9c0147a77447cc72a5e2ed9991b4a0d3808e2e1fc1ec2528d59bdebd69f57a71fc637f861811156bb1f32fbb619821217fd01fa8004ac33e1cdfc88b967e5
7
- data.tar.gz: e0103d2b11fb0bc5bbc6a565903a902c33240245b434ae4fcc1ddfbd3cca065c6aa62f50a913c7333e8906eacf3475d2070a20547ac83039fbc2b4e9c7422bb7
6
+ metadata.gz: d17eb20257d83ba338ec86cdfd4f709c63ccac8d9cad63f4ab3b29a0eec8c6a47f7131db1606635b1f957cbe903a3e6819980048905235872dc494b64947e070
7
+ data.tar.gz: 5a281662d284d984d6ed5ead5eb87fabec49bfc0f333bc59a42a2835faea2d2b2a4414731c39bc2770995de78c1f227fdc91c6594d6a36d74dd531596ea588bb
data/.irb_history ADDED
@@ -0,0 +1,13 @@
1
+ FileUtiles
2
+ FileUtils
3
+ Dir.exist? "./db"
4
+ YAML.\
5
+ load
6
+ YAML.safe_load_file "./config/column_names.yml"
7
+ require "yaml"
8
+ YAML.safe_load_file "./config/column_names.yml"
9
+ CSV
10
+ require "csv"
11
+ CSV
12
+ ENV
13
+ File
data/.irbrc CHANGED
@@ -0,0 +1 @@
1
+ require "lib/action_csv"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- action_csv (0.1.0)
4
+ action_csv (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -47,8 +47,8 @@ PLATFORMS
47
47
 
48
48
  DEPENDENCIES
49
49
  action_csv!
50
- rake (~> 13.0)
51
- rspec (~> 3.0)
50
+ rake (= 13.0.3)
51
+ rspec (= 3.10.0)
52
52
  rubocop (= 1.12.1)
53
53
 
54
54
  BUNDLED WITH
data/README.md CHANGED
@@ -1,8 +1,35 @@
1
- # ActionCsv
1
+ [![ActionCSV](https://firebasestorage.googleapis.com/v0/b/el-quest.appspot.com/o/mediaLibrary%2F1605615287402_souls-ogp.jpg?alt=media&token=1115aa76-6863-469d-acc8-9815ca7fac37)](https://rubygems.org/gems/souls)
2
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/action_csv`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ <p align="center">
4
+ <a aria-label="Ruby logo" href="https://el-soul.com">
5
+ <img src="https://badgen.net/badge/icon/Made%20by%20ELSOUL?icon=ruby&label&color=black&labelColor=black">
6
+ </a>
7
+ <br/>
8
+
9
+ <a aria-label="Ruby Gem version" href="https://rubygems.org/gems/action_csv">
10
+ <img alt="" src="https://badgen.net/rubygems/v/action_csv/latest">
11
+ </a>
12
+ <a aria-label="Downloads Number" href="https://rubygems.org/gems/action_csv">
13
+ <img alt="" src="https://badgen.net/rubygems/dt/action_csv">
14
+ </a>
15
+ <a aria-label="License" href="https://github.com/elsoul/action_csv/blob/master/LICENSE">
16
+ <img alt="" src="https://badgen.net/badge/license/Apache/blue">
17
+ </a>
18
+ </p>
19
+
20
+ ## What's Action CSV?
21
+
22
+ Welcome to SOULs Framework!
23
+
24
+ SOULS is a Web Application Framework based on GraphQL Relay ( Ruby )
25
+ This is Cloud Based APP Framework. Easy Deployment.
26
+ Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition.
27
+ You can focus on business logic. No more infra problems.
28
+
29
+ ## Dependency
30
+
31
+ - [Google Cloud Storage](https://github.com/googleapis/google-cloud-ruby)
4
32
 
5
- TODO: Delete this and the text above, and describe your gem
6
33
 
7
34
  ## Installation
8
35
 
@@ -20,24 +47,25 @@ Or install it yourself as:
20
47
 
21
48
  $ gem install action_csv
22
49
 
23
- ## Usage
50
+ If You are using SOULs APP
51
+
52
+ $ ActionCSV.export $MODEL_NAME
24
53
 
25
- TODO: Write usage instructions here
26
54
 
27
55
  ## Development
28
56
 
29
57
  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
58
 
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
+ 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/gems/action_csv).
32
60
 
33
61
  ## Contributing
34
62
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/action_csv. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/action_csv/blob/master/CODE_OF_CONDUCT.md).
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/elsoul/action_csv. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
64
 
37
65
  ## License
38
66
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
67
+ The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
40
68
 
41
69
  ## Code of Conduct
42
70
 
43
- Everyone interacting in the ActionCsv project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/action_csv/blob/master/CODE_OF_CONDUCT.md).
71
+ Everyone interacting in the HotelPrice projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elsoul/action_csv/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "lib/action_csv"
3
4
  require "bundler/gem_tasks"
4
5
  require "rspec/core/rake_task"
5
6
 
File without changes
data/lib/action_csv.rb CHANGED
@@ -1,8 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "action_csv/version"
4
+ require "yaml"
5
+ require "csv"
4
6
 
5
7
  module ActionCsv
6
8
  class Error < StandardError; end
7
- # Your code goes here...
9
+ COLUMNS = YAML.safe_load_file "./config/column_names.yml"
10
+ def self.export_csv model_name
11
+ singularized_name = model_name.singularize.underscore
12
+ file_dir = "./db/csv/"
13
+ FileUtils.mkdir_p file_dir unless Dir.exist? file_dir
14
+ file_path = ENV["RACK_ENV"] == "production" ? "#{file_dir}#{model_name.pluralize.underscore}_production.csv" : "#{file_dir}#{model_name.pluralize.underscore}.csv"
15
+ CSV.open(file_path, "w") do |csv|
16
+ if COLUMNS[singularized_name].present?
17
+ return "Columns number doesn't match! Please check ./config/column_names.yml !" unless COLUMNS[singularized_name].size == Object.const_get(singularized_name.camelize).column_names.size
18
+ csv << class_name.column_names.map { |c| COLUMNS[singularized_name][c] }
19
+ else
20
+ csv << class_name.column_names
21
+ end
22
+ class_name.all.reverse.each do |item|
23
+ csv << item.attributes.values
24
+ end
25
+ end
26
+ puts "Export Success!:#{file_path}"
27
+ true
28
+ rescue StandardError => error
29
+ error.backtrace
30
+ end
31
+
32
+ def self.get_tables
33
+ path = "./db/schema.rb"
34
+ tables = []
35
+ File.open(path, "r") do |f|
36
+ f.each_line.with_index do |line, i|
37
+ tables << line.split("\"")[1] if line.include?("create_table")
38
+ end
39
+ end
40
+ puts tables
41
+ tables
42
+ end
8
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionCsv
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -20,6 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - ".github/workflows/main.yml"
22
22
  - ".gitignore"
23
+ - ".irb_history"
23
24
  - ".irbrc"
24
25
  - ".rspec"
25
26
  - ".rubocop.yml"
@@ -33,6 +34,7 @@ files:
33
34
  - action_csv.gemspec
34
35
  - bin/console
35
36
  - bin/setup
37
+ - config/column_names.yml
36
38
  - lib/action_csv.rb
37
39
  - lib/action_csv/version.rb
38
40
  homepage: https://github.com/elsoul/action_csv