code2rubylearning 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/Gemfile +0 -1
- data/bin/code2rubylearning +4 -4
- data/lib/code2rubylearning.rb +1 -1
- data/lib/code2rubylearning/filehandling.rb +15 -2
- data/lib/code2rubylearning/version.rb +1 -1
- data/spec/assets/file-4 +4 -0
- data/spec/assets/file-5 +3 -0
- data/spec/assets/file-python +4 -0
- data/spec/assets/file-python.py +3 -0
- data/spec/assets/hello.rb +1 -0
- data/spec/code2rubylearning/filehandling_spec.rb +29 -2
- data/spec/code2rubylearning_spec.rb +4 -4
- data/spec/spec_config.rb.example +13 -0
- data/spec/spec_helper.rb +7 -13
- metadata +20 -3
- data/config.yaml.example +0 -10
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/bin/code2rubylearning
CHANGED
@@ -15,10 +15,10 @@ begin
|
|
15
15
|
options[:stdout] = true
|
16
16
|
end
|
17
17
|
|
18
|
-
options[:combine] = false
|
19
|
-
opt.on( '-c', '--combine', 'Combine multiple files into one ( not yet implemented )' ) do
|
20
|
-
|
21
|
-
end
|
18
|
+
# options[:combine] = false
|
19
|
+
# opt.on( '-c', '--combine', 'Combine multiple files into one ( not yet implemented )' ) do
|
20
|
+
# options[:combine] = true
|
21
|
+
# end
|
22
22
|
|
23
23
|
options[:filenames] = true
|
24
24
|
opt.on( '-f', '--nofilenames', 'Suppress filename line in output' ) do
|
data/lib/code2rubylearning.rb
CHANGED
@@ -19,7 +19,7 @@ module Code2rubylearning
|
|
19
19
|
end
|
20
20
|
|
21
21
|
if options[:prg_link]
|
22
|
-
@buffer <<
|
22
|
+
@buffer << %Q|<a href="https://github.com/rudicode/code2rubylearning/wiki">Posted with code2rubylearning v#{ VERSION }</a>\n|
|
23
23
|
end
|
24
24
|
|
25
25
|
Clippy.copy @buffer unless @buffer.empty?
|
@@ -21,13 +21,26 @@ module Code2rubylearning
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
# TODO
|
25
24
|
# Sets the @type for this file
|
26
25
|
# check extension for known types
|
27
26
|
# if extension fails try checking the first line
|
28
27
|
# it may contain #! and give a clue.
|
29
28
|
def identify_file_type
|
30
|
-
@type = "
|
29
|
+
@type = "text"
|
30
|
+
|
31
|
+
data_lines = @data.split("\n")
|
32
|
+
|
33
|
+
# check for a ruby file
|
34
|
+
if @name.include?(".rb") || data_lines.first.include?("#!") && data_lines.first.include?("ruby")
|
35
|
+
@type = "ruby"
|
36
|
+
end
|
37
|
+
|
38
|
+
# check for a python file
|
39
|
+
if @name.include?(".py") || data_lines.first.include?("#!") && data_lines.first.include?("python")
|
40
|
+
@type = "python"
|
41
|
+
end
|
42
|
+
|
31
43
|
end
|
44
|
+
|
32
45
|
end
|
33
46
|
end
|
data/spec/assets/file-4
ADDED
data/spec/assets/file-5
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
def hello; "Hello World!"; end
|
@@ -12,14 +12,41 @@ describe "FileHandling" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should set the data to the contents of the file" do
|
15
|
-
expected =
|
15
|
+
expected = %Q|def hello\n "Hello"\nend\n|
|
16
16
|
@valid_file.data.must_equal expected
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should set the type to
|
19
|
+
it "should set the type to ruby" do
|
20
20
|
expected = "ruby"
|
21
21
|
@valid_file.type.must_equal expected
|
22
22
|
end
|
23
|
+
|
24
|
+
it "should set the type to ruby" do
|
25
|
+
@ruby_file_without_extension = "spec/assets/file-4"
|
26
|
+
@ruby_file = FileHandling.new(@ruby_file_without_extension)
|
27
|
+
expected = "ruby"
|
28
|
+
@ruby_file.type.must_equal expected
|
29
|
+
end
|
30
|
+
|
31
|
+
it "unknown files should default to text" do
|
32
|
+
@unknown = "spec/assets/file-5"
|
33
|
+
@unknown_file = FileHandling.new(@unknown)
|
34
|
+
expected = "text"
|
35
|
+
@unknown_file.type.must_equal expected
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set the type to python" do
|
39
|
+
@python_file_without_extension = "spec/assets/file-python"
|
40
|
+
@python_file_with_extension = "spec/assets/file-python.py"
|
41
|
+
@python = FileHandling.new(@python_file_without_extension)
|
42
|
+
@python_ext = FileHandling.new(@python_file_with_extension)
|
43
|
+
|
44
|
+
expected = "python"
|
45
|
+
|
46
|
+
@python.type.must_equal expected
|
47
|
+
@python_ext.type.must_equal expected
|
48
|
+
end
|
49
|
+
|
23
50
|
end
|
24
51
|
|
25
52
|
describe "invalid files" do
|
@@ -9,7 +9,7 @@ describe Code2rubylearning do
|
|
9
9
|
files = ["spec/assets/file-1.rb"]
|
10
10
|
from_clipboard = Code2rubylearning.start files, @options
|
11
11
|
|
12
|
-
from_clipboard.must_equal
|
12
|
+
from_clipboard.must_equal %Q|[code ruby]\r\ndef hello\r\n "Hello"\r\nend\r\n[/code]\r\n|
|
13
13
|
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ describe Code2rubylearning do
|
|
17
17
|
files = ["spec/assets/file-1.rb", "spec/assets/file-2.rb"]
|
18
18
|
from_clipboard = Code2rubylearning.start files, @options
|
19
19
|
|
20
|
-
correct_response =
|
20
|
+
correct_response = %Q|[code ruby]\r\ndef hello\r\n "Hello"\r\nend\r\n[/code]\r\n[code ruby]\r\ndef there\r\n "There"\r\nend\r\n[/code]\r\n|
|
21
21
|
from_clipboard.must_equal correct_response
|
22
22
|
|
23
23
|
end
|
@@ -26,8 +26,8 @@ describe Code2rubylearning do
|
|
26
26
|
@options = { :prg_link => true }
|
27
27
|
files = ["spec/assets/file-1.rb", "spec/assets/file-2.rb"]
|
28
28
|
from_clipboard = Code2rubylearning.start files, @options
|
29
|
-
|
30
|
-
correct_response =
|
29
|
+
|
30
|
+
correct_response = %Q|<a href="https://github.com/rudicode/code2rubylearning/wiki">Posted with code2rubylearning v|
|
31
31
|
from_clipboard.must_include correct_response
|
32
32
|
|
33
33
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Minitest Reporters Selection
|
2
|
+
# Reporter choices are case sensitive!
|
3
|
+
# uncommet the one you wish to use
|
4
|
+
|
5
|
+
Option = {
|
6
|
+
# report_style: "Default",
|
7
|
+
report_style: "Spec",
|
8
|
+
# report_style: "Progress",
|
9
|
+
# report_style: "Guard",
|
10
|
+
# report_style: "RubyMine",
|
11
|
+
# report_style: "RubyMate",
|
12
|
+
}
|
13
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -6,20 +6,14 @@ require "bundler/setup"
|
|
6
6
|
require 'minitest/autorun'
|
7
7
|
require 'minitest/reporters'
|
8
8
|
require "minitest/matchers"
|
9
|
-
require 'yaml'
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
you need to uncomment one of the choices from the menu.
|
19
|
-
#{'+-' * 33}
|
20
|
-
EOWARNING
|
21
|
-
raise
|
22
|
-
end
|
10
|
+
# To select a different reporter copy the spec/spec_config.rb.example to
|
11
|
+
# spec/spec_config.rb and select the reporter you wish to use.
|
12
|
+
File.exists?('spec/spec_config.rb') ?
|
13
|
+
require( 'spec_config') :
|
14
|
+
Option = {report_style: "Default"}
|
15
|
+
MiniTest::Reporters.use!(eval("MiniTest::Reporters::#{Option[:report_style]}Reporter.new"))
|
16
|
+
|
23
17
|
require('code2rubylearning')
|
24
18
|
require('code2rubylearning/version')
|
25
19
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code2rubylearning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clippy
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- Rakefile
|
46
46
|
- bin/code2rubylearning
|
47
47
|
- code2rubylearning.gemspec
|
48
|
-
- config.yaml.example
|
49
48
|
- lib/code2rubylearning.rb
|
50
49
|
- lib/code2rubylearning/filehandling.rb
|
51
50
|
- lib/code2rubylearning/filter.rb
|
@@ -53,10 +52,16 @@ files:
|
|
53
52
|
- spec/assets/file-1.rb
|
54
53
|
- spec/assets/file-2.rb
|
55
54
|
- spec/assets/file-3.rb
|
55
|
+
- spec/assets/file-4
|
56
|
+
- spec/assets/file-5
|
57
|
+
- spec/assets/file-python
|
58
|
+
- spec/assets/file-python.py
|
59
|
+
- spec/assets/hello.rb
|
56
60
|
- spec/code2rubylearning/filehandling_spec.rb
|
57
61
|
- spec/code2rubylearning/filter_spec.rb
|
58
62
|
- spec/code2rubylearning/version_spec.rb
|
59
63
|
- spec/code2rubylearning_spec.rb
|
64
|
+
- spec/spec_config.rb.example
|
60
65
|
- spec/spec_helper.rb
|
61
66
|
homepage: https://github.com/rudicode/code2rubylearning
|
62
67
|
licenses: []
|
@@ -70,12 +75,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
75
|
- - ! '>='
|
71
76
|
- !ruby/object:Gem::Version
|
72
77
|
version: '0'
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
hash: 3155921660826552801
|
73
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
82
|
none: false
|
75
83
|
requirements:
|
76
84
|
- - ! '>='
|
77
85
|
- !ruby/object:Gem::Version
|
78
86
|
version: '0'
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
hash: 3155921660826552801
|
79
90
|
requirements: []
|
80
91
|
rubyforge_project:
|
81
92
|
rubygems_version: 1.8.24
|
@@ -87,8 +98,14 @@ test_files:
|
|
87
98
|
- spec/assets/file-1.rb
|
88
99
|
- spec/assets/file-2.rb
|
89
100
|
- spec/assets/file-3.rb
|
101
|
+
- spec/assets/file-4
|
102
|
+
- spec/assets/file-5
|
103
|
+
- spec/assets/file-python
|
104
|
+
- spec/assets/file-python.py
|
105
|
+
- spec/assets/hello.rb
|
90
106
|
- spec/code2rubylearning/filehandling_spec.rb
|
91
107
|
- spec/code2rubylearning/filter_spec.rb
|
92
108
|
- spec/code2rubylearning/version_spec.rb
|
93
109
|
- spec/code2rubylearning_spec.rb
|
110
|
+
- spec/spec_config.rb.example
|
94
111
|
- spec/spec_helper.rb
|