codes21 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/codes21 +15 -0
  3. data/lib/codes21.rb +37 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d2cd7566b8b3bf506136983268a4a51b918fbf4
4
+ data.tar.gz: 00d2511f5061b73651c5074a9ea7901c84607e58
5
+ SHA512:
6
+ metadata.gz: b3403256bafeb106604795c76d053bf1a9c7eed44f3228d3d499ac68b7dad8a5eeedc7c61c1e74695bd6bdc0c555654a4d3fc94adc88e853f9034ad69078cde2
7
+ data.tar.gz: 3c377b818a545735adf1a497d3d6bd61f83e01d11570720a16cef84b373e7f8278aa6312f673e8bbe92ecf87f7a6be1394422f798de449228d22c838cb38cce4
data/bin/codes21 ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'codes21'
4
+
5
+ if ARGV.count != 3
6
+ puts "With the given suffixes merge multiple files code into one file."
7
+ puts "use: ruby codes21.rb /path/to/project rb,js result.txt"
8
+ exit
9
+ end
10
+
11
+ path = ARGV[0]
12
+ suffixes = ARGV[1]
13
+ output = ARGV[2]
14
+
15
+ Codes21.run path, suffixes, output
data/lib/codes21.rb ADDED
@@ -0,0 +1,37 @@
1
+ class Codes21
2
+ def get_codes(path, suffixes)
3
+ @items ||= []
4
+ Dir.glob("#{path}/**/*.{#{suffixes}}").each do |file|
5
+ title = file.split('/').last
6
+ puts file
7
+
8
+ puts '*' * 70
9
+ codes = File.read(file)
10
+ codes.squeeze! "\n"
11
+ puts codes
12
+
13
+ item = {title: title, codes: codes}
14
+ @items << item
15
+ end
16
+ end
17
+
18
+ def write_result(result_file_path)
19
+ File.open(result_file_path, 'w') do |f|
20
+ @items.each do |item|
21
+ f.puts "File:" + item[:title]
22
+ f.puts "Code:"
23
+ f.puts item[:codes]
24
+ end
25
+ end
26
+
27
+ puts '*' * 70
28
+ puts "codes files count: #{@items.size}"
29
+ end
30
+
31
+ def self.run(path, suffixes, result_file_path)
32
+ codes21 = Codes21.new
33
+ codes21.get_codes(path, suffixes)
34
+ codes21.write_result(result_file_path)
35
+ end
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: codes21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aston Fu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: With the given suffixes merge multiple files code into one file.
14
+ email: im@fuhao.im
15
+ executables:
16
+ - codes21
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/codes21
21
+ - lib/codes21.rb
22
+ homepage: https://github.com/astonfu/codes21
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.4
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Codes to One.
46
+ test_files: []