Pickaxe 0.5.5 → 0.6.0

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.
data/Gemfile CHANGED
@@ -3,4 +3,5 @@ source "http://rubygems.org"
3
3
 
4
4
  gem 'activesupport', "3.0.1", :require => 'active_support/all'
5
5
  gem 'i18n', "0.4.2"
6
+ gem 'unidecoder', '1.1.1'
6
7
 
@@ -3,10 +3,13 @@ GEM
3
3
  specs:
4
4
  activesupport (3.0.1)
5
5
  i18n (0.4.2)
6
+ unidecoder (1.1.1)
6
7
 
7
8
  PLATFORMS
8
9
  ruby
10
+ x86-mingw32
9
11
 
10
12
  DEPENDENCIES
11
13
  activesupport (= 3.0.1)
12
14
  i18n (= 0.4.2)
15
+ unidecoder (= 1.1.1)
@@ -5,8 +5,8 @@ Pickaxe provides a simple way to load, solve and rate tests
5
5
 
6
6
  Documentation can be read [here](http://dejw.github.com/pickaxe/).
7
7
 
8
- **Note:** pickaxe was not tested on Windows yet (and it will not work there
9
- since `Pickaxe::Shell` executes some terminal related code).
8
+ **Note:** if You are Windows user please read
9
+ [Windows section](http://dejw.github.com/pickaxe/#WINDOWS) in manual.
10
10
 
11
11
  ## instalation
12
12
 
@@ -1,16 +1,20 @@
1
1
  require "rubygems"
2
2
  require "bundler/setup"
3
3
  require "active_support/all"
4
+ require "rbconfig"
5
+ require "unidecoder"
4
6
 
5
7
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
6
8
 
7
9
  module Pickaxe
8
- VERSION = "0.5.5"
10
+ VERSION = "0.6.0"
9
11
 
10
12
  class PickaxeError < StandardError; end
11
13
 
12
- autoload :Shell, 'pickaxe/shell'
13
- autoload :Color, 'pickaxe/color'
14
+ WINDOWS_IT_IS = Config::CONFIG['host_os'] =~ /mswin|mingw/
15
+
16
+ autoload :Shell, 'pickaxe/shell'
17
+ autoload :Color, 'pickaxe/color'
14
18
  autoload :Main, 'pickaxe/main'
15
19
  autoload :Test, 'pickaxe/test'
16
20
  autoload :Errors, 'pickaxe/errors'
@@ -60,6 +60,20 @@ end
60
60
 
61
61
  begin
62
62
  parser.parse!
63
+
64
+ Pickaxe::Main.options = options
65
+
66
+ if Pickaxe::WINDOWS_IT_IS
67
+ $stderr.puts <<END_OF_MESSAGE
68
+ ! Hi there Windows user.
69
+
70
+ You will not be able to see colors, all diacritics
71
+ will be transliterated and dynamic console width
72
+ is not available. Sorry for the inconvenience.
73
+ END_OF_MESSAGE
74
+
75
+ end
76
+
63
77
  if options[:full_test] and options[:repeat_incorrect]
64
78
  $stderr.puts(("! --full-test disables the --repeat-incorrect option" ).color(:yellow))
65
79
  options[:repeat_incorrect] = false
@@ -47,7 +47,9 @@ module Pickaxe
47
47
  # of the returned String.
48
48
  #
49
49
  def self.set_color(string, color, bold=false)
50
- unless (Main.options || {})[:no_colors]
50
+ if Pickaxe::WINDOWS_IT_IS
51
+ string
52
+ elsif not (Main.options || {})[:no_colors]
51
53
  color = self.const_get(color.to_s.upcase) if color.is_a?(Symbol)
52
54
  bold = bold ? BOLD : ""
53
55
  "#{bold}#{color}#{string}#{CLEAR}"
@@ -16,7 +16,6 @@ END_OF_TEST
16
16
  def initialize(paths, options = {})
17
17
  raise NoTests, "no tests to run" if paths.empty?
18
18
 
19
- Main.options = options
20
19
  @test = Test.new(*paths)
21
20
  return if options[:syntax_check]
22
21
 
@@ -35,7 +34,12 @@ END_OF_TEST
35
34
  end
36
35
 
37
36
  begin
38
- puts "! Hit Control-D or Control-C to end test.\n\n".color(:green)
37
+ if Pickaxe::WINDOWS_IT_IS
38
+ puts "! Hit Control-Z + [Enter] to end test\n\n"
39
+ else
40
+ puts "! Hit Control-D or Control-C to end test.\n\n".color(:green)
41
+ end
42
+
39
43
  while @current_index < @questions.length + (Main.options[:full_test] ? 1 : 0) do
40
44
  @question = @questions[@current_index]
41
45
 
@@ -2,10 +2,16 @@ module Pickaxe
2
2
  module Shell
3
3
  # Extracted from
4
4
  # https://github.com/wycats/thor/blob/master/lib/thor/shell/basic.rb
5
+ #
6
+ # This is turned off on Windows and returns always 80
5
7
  def self.dynamic_width
6
- (dynamic_width_stty.nonzero? || dynamic_width_tput)
8
+ if Pickaxe::WINDOWS_IT_IS
9
+ 80
10
+ else
11
+ (dynamic_width_stty.nonzero? || dynamic_width_tput)
12
+ end
7
13
  end
8
-
14
+ private
9
15
  def self.dynamic_width_stty
10
16
  %x{stty size 2>/dev/null}.split[1].to_i
11
17
  end
@@ -1,9 +1,13 @@
1
1
  module Pickaxe
2
2
  class TestLine < String
3
3
  attr_accessor :index
4
- def initialize(itself, index)
5
- super(itself)
4
+ def initialize(itself, index)
6
5
  self.index = index + 1
6
+ if Pickaxe::WINDOWS_IT_IS
7
+ replace(itself.to_ascii)
8
+ else
9
+ replace(itself)
10
+ end
7
11
  end
8
12
  end
9
13
 
@@ -15,7 +19,7 @@ module Pickaxe
15
19
  include Enumerable
16
20
 
17
21
  # Ruby-comments and C-comments
18
- COMMENTS_RE = /^\s*#.*|^\/\/.*|^;.*/
22
+ COMMENTS_RE = /^\s*(#|\/\/|;).*/
19
23
 
20
24
  def initialize(*files)
21
25
  @files = files.collect do |file_or_directory|
@@ -26,13 +30,13 @@ module Pickaxe
26
30
  if File.file?(file_or_directory)
27
31
  file_or_directory
28
32
  else
29
- Dir.glob("#{file_or_directory}/*.#{Main.options[:extension]}")
33
+ Dir.glob("#{file_or_directory.gsub("\\", "/")}/*.#{Main.options[:extension]}")
30
34
  end
31
35
  end.flatten.collect { |f| f.squeeze('/') }
32
36
 
33
37
  @questions = []
34
38
  @files.inject(nil) do |last, file|
35
- File.open(file) do |f|
39
+ File.open(file, "r:UTF-8") do |f|
36
40
  lines = f.readlines.collect(&:strip).each_with_index.collect do |l, i|
37
41
  TestLine.new(l, i)
38
42
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Pickaxe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 5
10
- version: 0.5.5
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dawid Fatyga
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-06 00:00:00 +01:00
18
+ date: 2010-12-07 00:00:00 +01:00
19
19
  default_executable: bin/pickaxe
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,22 @@ dependencies:
66
66
  name: i18n
67
67
  prerelease: false
68
68
  type: :runtime
69
+ - !ruby/object:Gem::Dependency
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - "="
74
+ - !ruby/object:Gem::Version
75
+ hash: 17
76
+ segments:
77
+ - 1
78
+ - 1
79
+ - 1
80
+ version: 1.1.1
81
+ requirement: *id004
82
+ name: unidecoder
83
+ prerelease: false
84
+ type: :runtime
69
85
  description: |
70
86
  Pickaxe provides a simple way to load, solve and rate tests (bundle of questions)
71
87
  written in simple text format.