syntaxer 0.1.1 → 0.2.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
@@ -1,15 +1,15 @@
1
1
  source "http://rubygems.org"
2
- gem "git"
2
+
3
+ #for managing git repos
4
+ gem "git"
5
+
6
+ #for colorizing output
3
7
  gem "rainbow"
4
8
 
5
- # Add dependencies to develop your gem here.
6
- # Include everything needed to run rake, tests, features, etc.
7
9
  group :development do
8
- gem "rspec", "~> 2.3.0"
10
+ gem "rspec", ">= 2.5.0"
9
11
  gem "yard", "~> 0.6.0"
10
- gem "bundler", "~> 1.0.0"
11
12
  gem "jeweler", "~> 1.5.2"
12
- gem "rcov", ">= 0"
13
13
  gem "cucumber"
14
14
  gem "aruba"
15
15
  end
@@ -1,10 +1,10 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- aruba (0.3.2)
5
- childprocess (~> 0.1.6)
6
- cucumber (~> 0.10.0)
7
- rspec (~> 2.3.0)
4
+ aruba (0.3.6)
5
+ childprocess (>= 0.1.7)
6
+ cucumber (>= 0.10.0)
7
+ rspec (>= 2.5.0)
8
8
  builder (3.0.0)
9
9
  childprocess (0.1.8)
10
10
  ffi (~> 1.0.6)
@@ -27,28 +27,25 @@ GEM
27
27
  json (1.5.1)
28
28
  rainbow (1.1.1)
29
29
  rake (0.8.7)
30
- rcov (0.9.9)
31
- rspec (2.3.0)
32
- rspec-core (~> 2.3.0)
33
- rspec-expectations (~> 2.3.0)
34
- rspec-mocks (~> 2.3.0)
35
- rspec-core (2.3.1)
36
- rspec-expectations (2.3.0)
30
+ rspec (2.5.0)
31
+ rspec-core (~> 2.5.0)
32
+ rspec-expectations (~> 2.5.0)
33
+ rspec-mocks (~> 2.5.0)
34
+ rspec-core (2.5.1)
35
+ rspec-expectations (2.5.0)
37
36
  diff-lcs (~> 1.1.2)
38
- rspec-mocks (2.3.0)
37
+ rspec-mocks (2.5.0)
39
38
  term-ansicolor (1.0.5)
40
- yard (0.6.4)
39
+ yard (0.6.8)
41
40
 
42
41
  PLATFORMS
43
42
  ruby
44
43
 
45
44
  DEPENDENCIES
46
45
  aruba
47
- bundler (~> 1.0.0)
48
46
  cucumber
49
47
  git
50
48
  jeweler (~> 1.5.2)
51
49
  rainbow
52
- rcov
53
- rspec (~> 2.3.0)
50
+ rspec (>= 2.5.0)
54
51
  yard (~> 0.6.0)
@@ -9,11 +9,10 @@ When syntaxer is used with git it checks syntax in added and changed files befor
9
9
 
10
10
  To install syntaxer run
11
11
 
12
- sudo gem install syntaxer
12
+ [sudo] gem install syntaxer
13
13
 
14
- == Usage
15
14
 
16
- == Syntaxer with rails
15
+ == Usage
17
16
 
18
17
  Example of usage:
19
18
 
@@ -88,16 +87,20 @@ Options for usage
88
87
 
89
88
  == TODO
90
89
 
91
- * Have to fix the problem with only created repository and initial commit with GIT reposytory
90
+ * Have to fix the problem with only created repository and initial commit with GIT repository
92
91
  * Add SVN support
93
92
 
93
+ == Known problems
94
+ * Git gem doesn't work properly on the very first commit.
95
+
96
+
94
97
  == Author
95
98
 
96
- Artyom Kramarenko (artemk) Svitla Systems Inc (svitla.com)
99
+ Artyom Kramarenko (artemk) Svitla Systems Inc (www.svitla.com)
97
100
 
98
101
  == Contributors
99
102
 
100
- Artem Melnikov (ignar) Svitla Systems Inc (svitla.com)
103
+ Artem Melnikov (ignar) Svitla Systems Inc (www.svitla.com)
101
104
 
102
105
  == Copyright
103
106
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -57,7 +57,7 @@ class SyntaxerCLI
57
57
  end
58
58
 
59
59
  opts.on_tail("--version", "Show version") do
60
- puts Syntaxer::VERSION
60
+ puts IO.readlines('../VERSION','').first.to_s
61
61
  exit
62
62
  end
63
63
  end
@@ -3,11 +3,11 @@ Feature: Check syntax in plain mode
3
3
 
4
4
  In order to check syntax
5
5
  A user who used gem
6
- Should be abble run command
6
+ Should be able run command
7
7
 
8
8
  @plain
9
9
  Scenario: Run checker in directory
10
- Given directory containt two files
10
+ Given directory contains two files
11
11
  When I run `syntaxer` interactively
12
12
  Then the exit status should not be 0
13
13
  And the output should not contain "Syntax OK"
@@ -8,6 +8,6 @@ Feature: Check git repository before commit
8
8
  @repo
9
9
  Scenario: Run "git commit"
10
10
  Given git repository
11
- And some file with worng syntax
11
+ And some file with wrong syntax
12
12
  When run `git commit -m "some message"` interactively
13
13
  Then the syntaxer should stop commit
@@ -1,4 +1,4 @@
1
- Given /^directory containt two files$/ do
1
+ Given /^directory contains two files$/ do
2
2
  create_temp_plain_work_dir
3
3
  end
4
4
 
@@ -6,3 +6,7 @@ When /^I cd to working directory$/ do
6
6
  cd(@tmp_dir)
7
7
  end
8
8
 
9
+ Then /^the output should be the same as in "(.*)" file$/ do |f|
10
+ content = IO.readlines(File.join(SYNTAXER_ROOT_PATH, f),'').first.to_s
11
+ Then %{the output should contain "#{content}"}
12
+ end
@@ -2,7 +2,7 @@ Given /^git repository$/ do
2
2
  create_temp_repo_work_dir
3
3
  end
4
4
 
5
- Given /^some file with worng syntax$/ do
5
+ Given /^some file with wrong syntax$/ do
6
6
  in_current_dir do
7
7
  add_fixtures_files
8
8
  end
@@ -14,5 +14,4 @@ end
14
14
 
15
15
  Then /^the syntaxer should stop commit$/ do
16
16
  lambda{make_git_commit}.should raise_exception
17
- #@last_exit_status.should_not == 0
18
17
  end
@@ -1,3 +1,3 @@
1
1
  require 'aruba/cucumber'
2
2
  require 'fileutils'
3
- require "git"
3
+ require "git"
@@ -1,7 +1,9 @@
1
1
  module PlainHelpers
2
+ SYNTAXER_ROOT_PATH = File.join(File.dirname(__FILE__), '..', '..')
3
+
2
4
  @tmp_dir
3
5
  def temp_dir
4
- tmpdir = File.expand_path current_dir #"#{Time.now.to_i}"
6
+ tmpdir = File.expand_path current_dir
5
7
  @tmp_dir = tmpdir
6
8
  tmpdir
7
9
  end
@@ -31,15 +33,19 @@ module PlainHelpers
31
33
 
32
34
  def create_temp_plain_work_dir
33
35
  tmp = create_tmp_dir
36
+
34
37
  in_current_dir do
35
38
  add_fixtures_files
36
39
  end
40
+
37
41
  end
38
42
 
39
43
  def create_temp_repo_work_dir
40
44
  create_tmp_dir
41
- g = Git.init(File.expand_path(File.join(@tmp_dir)))
45
+
46
+ g = Git.init(File.expand_path(File.join(@tmp_dir)))
42
47
  FileUtils.touch(File.join(@tmp_dir,'README'))
48
+
43
49
  g.add('.')
44
50
  g.commit('first commit')
45
51
  end
@@ -56,16 +62,11 @@ module PlainHelpers
56
62
  end
57
63
 
58
64
  def make_git_commit
59
- g = Git.open File.expand_path(@tmp_dir) #(File.expand_path(File.join(current_dir)))
65
+ g = Git.open File.expand_path(@tmp_dir)
60
66
  g.add
61
- #pp File.expand_path(current_dir)
62
- #Dir.chdir(File.expand_path(current_dir)) do
63
- #g = Git.open Dir.pwd
64
- #g.add
65
- Dir.chdir(current_dir)
66
- g.commit('second commit')
67
- #end
68
67
 
68
+ Dir.chdir(current_dir)
69
+ g.commit('second commit')
69
70
  end
70
71
 
71
72
  end
@@ -0,0 +1,13 @@
1
+ @announce
2
+ Feature: Test options
3
+
4
+ In order to check syntax
5
+ A user who used gem
6
+ Should be able run command
7
+
8
+ @plain
9
+ Scenario: Run version checking
10
+ When I run `syntaxer -v` interactively
11
+ Then the exit status should not be 0
12
+ And the output should be the same as in "VERSION" file
13
+
@@ -7,7 +7,6 @@ require File.join(%w{syntaxer file_status})
7
7
  require File.join(%w{syntaxer checker})
8
8
  require File.join(%w{syntaxer repository})
9
9
  require File.join(%w{syntaxer language_definition})
10
- require File.join(%w{syntaxer version})
11
10
  require File.join(%w{syntaxer printer})
12
11
 
13
12
  module Syntaxer
@@ -34,11 +33,11 @@ module Syntaxer
34
33
  def check_syntax(options = {})
35
34
  @root_path = options[:root_path]
36
35
  Printer.quite = options[:quite] || false
36
+
37
37
  @reader = Reader::DSLReader.load(options[:config_file])
38
38
  @repository = Repository.factory(@root_path, options[:repository]) if options[:repository]
39
39
 
40
- Checker.process(self)
41
- error_files = Checker.error_files
40
+ error_files = Checker.process(self).error_files
42
41
  Printer.print_result error_files
43
42
  exit(1) unless error_files.empty?
44
43
  end
@@ -5,30 +5,9 @@ module Syntaxer
5
5
  include Open3
6
6
  extend Forwardable
7
7
 
8
- # Does not working
9
8
  def_delegators Syntaxer::FileStatus, :error_files, :fine_files
10
9
 
11
10
  attr_accessor :syntaxer, :reader
12
-
13
- # List of files with correct syntax
14
- #
15
- # @return [Array<FileStatus>, #each] array with files
16
- #
17
- # @see FileStatus#fine_files
18
-
19
- def self.fine_files
20
- FileStatus.fine_files
21
- end
22
-
23
- # List of files with wrong syntax
24
- #
25
- # @return [Array<FileStatus>, #each] array with files
26
- #
27
- # @see FileStatus#fine_files
28
-
29
- def self.error_files
30
- FileStatus.error_files
31
- end
32
11
 
33
12
  def initialize(syntaxer)
34
13
  @syntaxer = syntaxer
@@ -81,7 +60,8 @@ module Syntaxer
81
60
  FileStatus.build(file, errors)
82
61
  end
83
62
  end
84
- FileStatus
63
+
64
+ self
85
65
  end
86
66
 
87
67
  private
@@ -107,7 +87,8 @@ module Syntaxer
107
87
  FileStatus.build(file, errors)
108
88
  end
109
89
  end
110
- FileStatus
90
+
91
+ self
111
92
  end
112
93
 
113
94
  end
@@ -9,8 +9,6 @@ require "tmpdir"
9
9
  # in ./support/ and its subdirectories.
10
10
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
11
 
12
- # RSpec.configure do |config|
13
- # end
14
12
 
15
13
  ROOT = File.join(File.dirname(__FILE__), '..')
16
14
 
@@ -40,6 +38,7 @@ end
40
38
 
41
39
  def make_git_add(ruby_repo_dir)
42
40
  g = Git.open(Dir.new(ruby_repo_dir))
41
+
43
42
  g.chdir do
44
43
  g.add('.')
45
44
  end
@@ -48,23 +47,29 @@ end
48
47
  def make_initial_commit(ruby_repo_dir)
49
48
  g = Git.open(Dir.new(ruby_repo_dir))
50
49
  FileUtils.touch(File.join(ruby_repo_dir, 'README'))
50
+
51
51
  make_git_add(ruby_repo_dir)
52
52
  g.commit('first commit')
53
+
53
54
  end
54
55
 
55
56
  def make_commit(ruby_repo_dir)
56
57
  g = Git.open(Dir.new(ruby_repo_dir))
58
+
57
59
  g.chdir do
58
60
  g.commit('second commit')
59
61
  end
62
+
60
63
  end
61
64
 
62
65
  def add_hook(ruby_repo_dir)
63
- bin_file = File.join(File.expand_path('../'),'syntaxer/bin', 'syntaxer')
66
+ bin_file = File.join(ROOT,'bin', 'syntaxer')
64
67
  hook_file = File.join(ruby_repo_dir,'.git/hooks/pre-commit')
68
+
65
69
  File.open(hook_file, 'w') do |f|
66
70
  f.puts "#{bin_file} -c #{syntaxer_rules_example_file('syntaxer_rules_git')} -r git -p #{ruby_repo_dir}"
67
71
  end
72
+
68
73
  File.chmod(0755, hook_file)
69
74
  end
70
75
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{syntaxer}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["artemk"]
12
- s.date = %q{2011-04-16}
12
+ s.date = %q{2011-04-17}
13
13
  s.default_executable = %q{syntaxer}
14
14
  s.description = %q{Syntax checker for ruby and other languages}
15
15
  s.email = %q{kramarenko.artyom@gmail.com}
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "features/support/env.rb",
34
34
  "features/support/hooks.rb",
35
35
  "features/support/plain_helpers.rb",
36
+ "features/syntaxer_check.feature",
36
37
  "init.rb",
37
38
  "lib/syntaxer.rb",
38
39
  "lib/syntaxer/checker.rb",
@@ -42,7 +43,6 @@ Gem::Specification.new do |s|
42
43
  "lib/syntaxer/railtie.rb",
43
44
  "lib/syntaxer/reader.rb",
44
45
  "lib/syntaxer/repository.rb",
45
- "lib/syntaxer/version.rb",
46
46
  "lib/tasks/syntaxer.rake",
47
47
  "rails/init.rb",
48
48
  "spec/checker_spec.rb",
@@ -84,32 +84,26 @@ Gem::Specification.new do |s|
84
84
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
85
85
  s.add_runtime_dependency(%q<git>, [">= 0"])
86
86
  s.add_runtime_dependency(%q<rainbow>, [">= 0"])
87
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
87
+ s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
88
88
  s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
89
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
90
89
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
91
- s.add_development_dependency(%q<rcov>, [">= 0"])
92
90
  s.add_development_dependency(%q<cucumber>, [">= 0"])
93
91
  s.add_development_dependency(%q<aruba>, [">= 0"])
94
92
  else
95
93
  s.add_dependency(%q<git>, [">= 0"])
96
94
  s.add_dependency(%q<rainbow>, [">= 0"])
97
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
95
+ s.add_dependency(%q<rspec>, [">= 2.5.0"])
98
96
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
99
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
100
97
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
101
- s.add_dependency(%q<rcov>, [">= 0"])
102
98
  s.add_dependency(%q<cucumber>, [">= 0"])
103
99
  s.add_dependency(%q<aruba>, [">= 0"])
104
100
  end
105
101
  else
106
102
  s.add_dependency(%q<git>, [">= 0"])
107
103
  s.add_dependency(%q<rainbow>, [">= 0"])
108
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
104
+ s.add_dependency(%q<rspec>, [">= 2.5.0"])
109
105
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
110
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
111
106
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
112
- s.add_dependency(%q<rcov>, [">= 0"])
113
107
  s.add_dependency(%q<cucumber>, [">= 0"])
114
108
  s.add_dependency(%q<aruba>, [">= 0"])
115
109
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: syntaxer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - artemk
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-16 00:00:00 +03:00
13
+ date: 2011-04-17 00:00:00 +03:00
14
14
  default_executable: syntaxer
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -40,9 +40,9 @@ dependencies:
40
40
  requirement: &id003 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 2.3.0
45
+ version: 2.5.0
46
46
  type: :development
47
47
  prerelease: false
48
48
  version_requirements: *id003
@@ -57,20 +57,9 @@ dependencies:
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: bundler
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 1.0.0
68
- type: :development
69
- prerelease: false
70
- version_requirements: *id005
71
60
  - !ruby/object:Gem::Dependency
72
61
  name: jeweler
73
- requirement: &id006 !ruby/object:Gem::Requirement
62
+ requirement: &id005 !ruby/object:Gem::Requirement
74
63
  none: false
75
64
  requirements:
76
65
  - - ~>
@@ -78,21 +67,10 @@ dependencies:
78
67
  version: 1.5.2
79
68
  type: :development
80
69
  prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: rcov
84
- requirement: &id007 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
90
- type: :development
91
- prerelease: false
92
- version_requirements: *id007
70
+ version_requirements: *id005
93
71
  - !ruby/object:Gem::Dependency
94
72
  name: cucumber
95
- requirement: &id008 !ruby/object:Gem::Requirement
73
+ requirement: &id006 !ruby/object:Gem::Requirement
96
74
  none: false
97
75
  requirements:
98
76
  - - ">="
@@ -100,10 +78,10 @@ dependencies:
100
78
  version: "0"
101
79
  type: :development
102
80
  prerelease: false
103
- version_requirements: *id008
81
+ version_requirements: *id006
104
82
  - !ruby/object:Gem::Dependency
105
83
  name: aruba
106
- requirement: &id009 !ruby/object:Gem::Requirement
84
+ requirement: &id007 !ruby/object:Gem::Requirement
107
85
  none: false
108
86
  requirements:
109
87
  - - ">="
@@ -111,7 +89,7 @@ dependencies:
111
89
  version: "0"
112
90
  type: :development
113
91
  prerelease: false
114
- version_requirements: *id009
92
+ version_requirements: *id007
115
93
  description: Syntax checker for ruby and other languages
116
94
  email: kramarenko.artyom@gmail.com
117
95
  executables:
@@ -136,6 +114,7 @@ files:
136
114
  - features/support/env.rb
137
115
  - features/support/hooks.rb
138
116
  - features/support/plain_helpers.rb
117
+ - features/syntaxer_check.feature
139
118
  - init.rb
140
119
  - lib/syntaxer.rb
141
120
  - lib/syntaxer/checker.rb
@@ -145,7 +124,6 @@ files:
145
124
  - lib/syntaxer/railtie.rb
146
125
  - lib/syntaxer/reader.rb
147
126
  - lib/syntaxer/repository.rb
148
- - lib/syntaxer/version.rb
149
127
  - lib/tasks/syntaxer.rake
150
128
  - rails/init.rb
151
129
  - spec/checker_spec.rb
@@ -177,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
155
  requirements:
178
156
  - - ">="
179
157
  - !ruby/object:Gem::Version
180
- hash: 846946609352155882
158
+ hash: 3897909288735270095
181
159
  segments:
182
160
  - 0
183
161
  version: "0"
@@ -1,3 +0,0 @@
1
- module Syntaxer
2
- VERSION = "0.0.1" unless defined? Syntaxer::VERSION
3
- end