action_csv 0.1.0 → 0.1.1

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: e0fa68fa768acfd2ebf1f0c639ffa5dfd396ef0ea27fb5eca4da297d3771d3c5
4
- data.tar.gz: 73f2de04b1a3e5564cadf0823f6b62edd24f94c9971949d3467169a3cea87ac3
3
+ metadata.gz: 8030f01b05744157fc78a295401bdada61df1e53eaf2655a83c251bcb70a6534
4
+ data.tar.gz: 3591a84c072103d466237a53c81661e5910dce0859a10830ea6e455dcbceafbd
5
5
  SHA512:
6
- metadata.gz: 29f9c0147a77447cc72a5e2ed9991b4a0d3808e2e1fc1ec2528d59bdebd69f57a71fc637f861811156bb1f32fbb619821217fd01fa8004ac33e1cdfc88b967e5
7
- data.tar.gz: e0103d2b11fb0bc5bbc6a565903a902c33240245b434ae4fcc1ddfbd3cca065c6aa62f50a913c7333e8906eacf3475d2070a20547ac83039fbc2b4e9c7422bb7
6
+ metadata.gz: bf9023730b25b1ead96751df62e0b9646d957020fce5489efdd213ba182d170fabf4e773b119f9dec7d6dc489f6564b14e7a7b3a27c1ec68cf39dceb5d7f0d08
7
+ data.tar.gz: 91e013d338773d87753d276becf171b8fafc4594d34d2b628fbb0b515bb0f79e73749a53d2631d2fe0622c35a15fbe15c436f63e85b8ee21c0e75be2f04e33ed
data/.irb_history ADDED
File without changes
data/.irbrc CHANGED
@@ -0,0 +1 @@
1
+ require "lib/action_csv"
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in action_csv.gemspec
6
6
  gemspec
7
7
 
8
+ gem "activerecord", "6.1.3.1"
8
9
  gem "rake", "13.0.3"
9
10
  gem "rspec", "3.10.0"
10
11
  gem "rubocop", "1.12.1"
data/Gemfile.lock CHANGED
@@ -6,8 +6,23 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ activemodel (6.1.3.1)
10
+ activesupport (= 6.1.3.1)
11
+ activerecord (6.1.3.1)
12
+ activemodel (= 6.1.3.1)
13
+ activesupport (= 6.1.3.1)
14
+ activesupport (6.1.3.1)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ zeitwerk (~> 2.3)
9
20
  ast (2.4.2)
21
+ concurrent-ruby (1.1.8)
10
22
  diff-lcs (1.4.4)
23
+ i18n (1.8.10)
24
+ concurrent-ruby (~> 1.0)
25
+ minitest (5.14.4)
11
26
  parallel (1.20.1)
12
27
  parser (3.0.1.0)
13
28
  ast (~> 2.4.1)
@@ -40,15 +55,19 @@ GEM
40
55
  rubocop-ast (1.4.1)
41
56
  parser (>= 2.7.1.5)
42
57
  ruby-progressbar (1.11.0)
58
+ tzinfo (2.0.4)
59
+ concurrent-ruby (~> 1.0)
43
60
  unicode-display_width (2.0.0)
61
+ zeitwerk (2.4.2)
44
62
 
45
63
  PLATFORMS
46
64
  x86_64-linux
47
65
 
48
66
  DEPENDENCIES
49
67
  action_csv!
50
- rake (~> 13.0)
51
- rspec (~> 3.0)
68
+ activerecord (= 6.1.3.1)
69
+ rake (= 13.0.3)
70
+ rspec (= 3.10.0)
52
71
  rubocop (= 1.12.1)
53
72
 
54
73
  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,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_record"
3
4
  require_relative "action_csv/version"
4
5
 
5
6
  module ActionCsv
6
7
  class Error < StandardError; end
7
- # Your code goes here...
8
+ COLUMNS = YAML.safe_load_file "./config/column_names.yml"
9
+ def self.export_csv model_name
10
+ singularized_name = model_name.singularize.underscore
11
+ file_dir = "./db/csv"
12
+ FileUtiles.mkdir_p file_dir unless Dir.exist? file_dir
13
+ file_path = ENV["RACK_ENV"] == "production" ? "#{file_dir}#{model_name.pluralize.underscore}_production.csv" : "#{file_dir}#{model_name.pluralize.underscore}.csv"
14
+ CSV.open(file_path, "w") do |csv|
15
+ if COLUMNS[singularized_name].present?
16
+ 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
17
+ csv << class_name.column_names.map { |c| COLUMNS[singularized_name][c] }
18
+ else
19
+ csv << class_name.column_names
20
+ end
21
+ class_name.all.reverse.each do |item|
22
+ csv << item.attributes.values
23
+ end
24
+ end
25
+ puts "Export Success!:#{file_path}"
26
+ true
27
+ rescue StandardError => error
28
+ error.backtrace
29
+ end
8
30
  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.1"
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.1
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