export_strings 0.1.0.dev → 0.1.1.dev

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: 354c2feb87b39392da57d57f849d391e15c13964d466007e15b889ca023c72e0
4
- data.tar.gz: 64b346af4bf07783ef0d22ef15c14bb0a3afb7f032a7f095ddcf0ff7dfe1d1a6
3
+ metadata.gz: e21380cd54e9dc9ae6e6997e81fa6cd42d906d85a04cdf3fb36acee14c528c5d
4
+ data.tar.gz: 30cc394113e1930dfa50e041613185fff8299c498a733f7d2e27a5cc3551825d
5
5
  SHA512:
6
- metadata.gz: 62d4a08cbcd1478a54299300245898ff8e1ab156c3d9e29134332e6434c75f657558e282048631154c681e631b6720698af510cfccd8c671167e65fdc4f850d5
7
- data.tar.gz: 506474efd892df0c6b759eed43efcb43fc38661ca4697b4dd595ed13b059ab71788b3db2a3e2fa4fa5f17158bdc584c959601b277017984ce5208c0c0533515f
6
+ metadata.gz: 0463f6e011828bc681e5949b8c49ed068d49874666b929600d7b45b813bc2caa92ad68ea7836fd22b06a7cc2e466aa502625dd4e1e32c037e5009b33c4826714
7
+ data.tar.gz: 83b2bb92b4d376ee065f9b56f78fe50af3383a373e45042a9d1dc14dded25dcb8d666079158cc6dc53041d5558e98c3ee2e91a9b5c07f96d50b756d1abe08a37
data/CHANGELOG.md CHANGED
@@ -0,0 +1,4 @@
1
+ # export_strings chagelogs
2
+ ## 0.1.1.dev
3
+ - Implement 60%
4
+ - Export strings from easy .rb file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- export_strings (0.1.0.dev)
4
+ export_strings (0.1.1.dev)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,10 +1,4 @@
1
1
  # ExportStrings
2
- - In development
3
- - Release schedule in June
4
-
5
- <!-- 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/export_strings`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- TODO: Delete this and the text above, and describe your gem
8
2
 
9
3
  ## Installation
10
4
 
@@ -16,7 +10,7 @@ gem 'export_strings'
16
10
 
17
11
  And then execute:
18
12
 
19
- $ bundle
13
+ $ bundle install
20
14
 
21
15
  Or install it yourself as:
22
16
 
@@ -24,7 +18,44 @@ Or install it yourself as:
24
18
 
25
19
  ## Usage
26
20
 
27
- TODO: Write usage instructions here
21
+ ```rb
22
+ require 'export_strings'
23
+
24
+ ExportString.execute rb_file_path
25
+
26
+ => [String, String, String, String]
27
+ ```
28
+
29
+
30
+ ## Example
31
+
32
+ ```rb
33
+ # =======example.rb=======
34
+ class Example
35
+ def str1
36
+ <<-SQL
37
+ SELECT *
38
+ FROM users
39
+ WHERE id > 100
40
+ SQL
41
+ end
42
+
43
+ def str2
44
+ "I like gohan. Do you like gohan.Oh Yeah."
45
+ end
46
+ end
47
+
48
+ # =======your irb console=======
49
+ require 'export_strings'
50
+
51
+ pp ExportStrings.execute 'example.rb'
52
+
53
+ [" SELECT *\n" + " FROM users\n" + " WHERE id > 100\n",
54
+ "I like gohan. Do you like gohan.Oh Yeah."]
55
+
56
+ => [" SELECT *\n FROM users\n WHERE id > 100\n", "I like gohan. Do you like gohan.Oh Yeah."]
57
+
58
+ ```
28
59
 
29
60
  ## Development
30
61
 
@@ -32,9 +63,17 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
32
63
 
33
64
  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).
34
65
 
66
+ ## Schedule
67
+
68
+ ### I want to develop this to make gem of format or parce.
69
+
70
+ - Implement to export from singleton_method
71
+ - Implement to export from string interpolation
72
+ - Implement to export from `hoge ? 'page' : 'peke'`
73
+
35
74
  ## Contributing
36
75
 
37
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/export_strings. 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.
76
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tashirosota/ruby-export_strings. 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.
38
77
 
39
78
  ## License
40
79
 
@@ -42,4 +81,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
42
81
 
43
82
  ## Code of Conduct
44
83
 
45
- Everyone interacting in the ExportStrings project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/export_strings/blob/master/CODE_OF_CONDUCT.md). -->
84
+ Everyone interacting in the ExportStrings project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/export_strings/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,57 @@
1
+ class Example
2
+
3
+ def str
4
+ <<-SQL
5
+ sasdfasdf
6
+ adsafsdf
7
+ ssdfghs
8
+ dfasdfa
9
+ dfasdf
10
+ a asdfasdfasdfasdfsh
11
+ SQL
12
+ end
13
+
14
+ def sql1
15
+ <<-SQL
16
+ select * from users where user.id > 100
17
+ SQL
18
+ end
19
+
20
+ def sql2
21
+ "
22
+ SELECT *
23
+ from users
24
+ where user.id > 100
25
+ JOIN profiles ON profiles.user_id =users.id
26
+ "
27
+ end
28
+
29
+ def sql3
30
+ "
31
+ SELECT *
32
+ from users
33
+ where user.id > 100
34
+ JOIN profiles ON profiles.user_id =users.id
35
+ GROUP BY gender
36
+ HAVING 100 > Max(#{hogeo})
37
+ AND HAVING 1000 < Max(#{test})
38
+ #{!!test ? 'page' : 'hoge'}
39
+ "
40
+ end
41
+
42
+ def hogeo
43
+ 'test'
44
+ "test"
45
+ 'test' + "test"
46
+ 'test' << 'test'
47
+ end
48
+
49
+ def test
50
+ 'hi'
51
+ end
52
+
53
+ def single_auot
54
+ 'single_quot_str'
55
+ end
56
+
57
+ end
@@ -1,4 +1,5 @@
1
1
  require "export_strings/version"
2
+ require "export_strings/core"
2
3
 
3
4
  module ExportStrings
4
5
  class Error < StandardError; end
@@ -1,5 +1,43 @@
1
+ require 'ripper'
2
+
1
3
  module ExportStrings
2
4
  class Core
3
-
5
+ class << self
6
+ def execute(rb_text)
7
+ @str_nodes = []
8
+ recursively_push_str_nodes Ripper.sexp(rb_text)
9
+ to_strings @str_nodes
10
+ end
11
+
12
+ private
13
+
14
+ def recursively_push_str_nodes(tree)
15
+ tree.each do |node|
16
+ if node.class == Array && node[0] == :string_content
17
+ @str_nodes << node
18
+ elsif node.class == Array
19
+ recursively_push_str_nodes(node)
20
+ end
21
+ end
22
+ end
23
+
24
+ def to_strings(nodes)
25
+ nodes.map do |node|
26
+ @string = ''
27
+ str_content_node2str node
28
+ end
29
+ end
30
+
31
+ def str_content_node2str(string_content_node)
32
+ string_content_node.each do |leaf|
33
+ if leaf.class == Array && leaf[0] == :@tstring_content
34
+ @string << leaf[1]
35
+ elsif leaf.class == Array
36
+ str_content_node2str(leaf)
37
+ end
38
+ end
39
+ @string
40
+ end
41
+ end
4
42
  end
5
43
  end
@@ -1,3 +1,3 @@
1
1
  module ExportStrings
2
- VERSION = "0.1.0.dev"
2
+ VERSION = "0.1.1.dev"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: export_strings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.dev
4
+ version: 0.1.1.dev
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tashiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2019-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - Rakefile
72
72
  - bin/console
73
73
  - bin/setup
74
+ - example/example.rb
74
75
  - export_strings.gemspec
75
76
  - lib/export_strings.rb
76
77
  - lib/export_strings/core.rb