konacha-chai-matchers 0.0.18 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSIONS ADDED
@@ -0,0 +1,15 @@
1
+ chai-spies: 0.5.1
2
+ sinon-chai: 2.3.1
3
+ chai-as-promised: 3.2.5
4
+ chai-jquery: 1.1.1
5
+ chai-timers: 0.2.0
6
+ chai-stats: 0.2.0
7
+ chai-null: 0.1.0
8
+ chai-factories: 0.1.0
9
+ chai-changes: 1.3.0
10
+ chai-backbone: 0.9.2
11
+ js-factories: 0.9.0
12
+ mocha-as-promised: 1.2.1
13
+ chai-things: 0.1.1
14
+ chai-fuzzy: 1.1.1
15
+ sinon: 1.5.2
@@ -1,11 +1,17 @@
1
1
  require "konacha-chai-matchers/version"
2
+ require 'pathname'
3
+ require 'json'
2
4
 
3
5
  module Konacha
4
6
  module Chai
5
7
  module Matchers
6
8
  class Engine < ::Rails::Engine
7
-
8
9
  end
10
+
11
+ autoload :Collector, 'konacha-chai-matchers/collector'
12
+ autoload :Library, 'konacha-chai-matchers/library'
13
+
9
14
  end
10
15
  end
11
16
  end
17
+
@@ -0,0 +1,38 @@
1
+
2
+ module Konacha
3
+ module Chai
4
+ module Matchers
5
+ class Collector
6
+
7
+ def update_libraries
8
+ modules = collect_libraries
9
+
10
+ modules.each(&:update)
11
+ modules.each(&:vendor)
12
+
13
+ File.open('VERSIONS', 'w') do |f|
14
+ modules.each do |m|
15
+ f.puts "#{m.name}: #{m.version}"
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def collect_libraries
23
+ libs = []
24
+ File.open('.gitmodules') do |f|
25
+ contents = f.read
26
+ contents.each_line do |line|
27
+ if matches = /\[submodule "(.*)"\]/.match(line)
28
+ libs << Library.new(matches[1])
29
+ end
30
+ end
31
+ end
32
+ libs
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,75 @@
1
+
2
+ module Konacha
3
+ module Chai
4
+ module Matchers
5
+ class Library
6
+
7
+ attr_reader :name
8
+
9
+ def initialize(name)
10
+ @name = name
11
+ end
12
+
13
+ def update
14
+ `cd ./#@name && git pull origin master`
15
+ `cd ./#@name && ./build` if File.exist? "./#@name/build"
16
+ end
17
+
18
+ def vendor
19
+ file = main_file
20
+ unless file
21
+ puts "Cannot determine library file for #@name"
22
+ return false
23
+ end
24
+
25
+ path = "./vendor/assets/javascripts/"
26
+ Pathname.new(path).mkpath()
27
+ FileUtils.cp(file, "#{path}#{@name}.js")
28
+ return true
29
+ end
30
+
31
+ def main_file
32
+ return @main_file unless @main_file.nil?
33
+ r = determine_file_from_suggestion @name
34
+ r ||= get_main_file_from_package
35
+ @main_file = r
36
+ end
37
+
38
+ def version
39
+ get_value_from_package 'version'
40
+ end
41
+
42
+ private
43
+
44
+ def determine_file_from_suggestion filename
45
+ file_search = filename.downcase
46
+ file_search << '.js' unless file_search =~ /\.js$/
47
+
48
+ path_order = [
49
+ "./#@name/pkg/#{file_search}",
50
+ "./#@name/#{file_search}",
51
+ "./#@name/lib/#{file_search}"
52
+ ]
53
+ path_order.map do |p|
54
+ p if File.exist? p
55
+ end.flatten.compact.first
56
+ end
57
+
58
+ def get_value_from_package key
59
+ filename = "./#@name/package.json"
60
+ return unless File.exist? filename
61
+ json_string = File.open(filename).read
62
+ json = JSON.parse json_string
63
+ return unless json.has_key? "main"
64
+ json[key]
65
+ end
66
+
67
+ def get_main_file_from_package
68
+ main_file = get_value_from_package 'main'
69
+ determine_file_from_suggestion main_file
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+
@@ -1,7 +1,7 @@
1
1
  module Konacha
2
2
  module Chai
3
3
  module Matchers
4
- VERSION = "0.0.18"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
data/tasks/update.rb CHANGED
@@ -1,74 +1,9 @@
1
- require 'pathname'
2
- require 'json'
1
+ require 'rails'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../lib/konacha-chai-matchers')
3
3
 
4
4
  desc 'updates all submodules'
5
5
  task :update do
6
- modules = collect_modules
7
- update_modules modules
8
- vendor_files modules
6
+ collector = Konacha::Chai::Matchers::Collector.new
7
+ collector.update_libraries
9
8
  end
10
9
 
11
- def collect_modules
12
- modules = []
13
- File.open('.gitmodules') do |f|
14
- contents = f.read
15
- contents.each_line do |line|
16
- if matches = /\[submodule "(.*)"\]/.match(line)
17
- modules << matches[1]
18
- end
19
- end
20
- end
21
- modules
22
- end
23
-
24
- def main_files folders
25
- folders.map do |f|
26
- r = determine_file_from_suggestion f
27
- r ||= get_main_file_from_package "./#{f}/package.json", f
28
-
29
- { lib: r, module: f }
30
- end.flatten.compact
31
- end
32
-
33
- def determine_file_from_suggestion filename, folder = filename
34
- file_search = filename.downcase
35
- file_search << '.js' unless file_search =~ /\.js$/
36
-
37
- path_order = [
38
- "./#{folder}/pkg/#{file_search}",
39
- "./#{folder}/#{file_search}",
40
- "./#{folder}/lib/#{file_search}"
41
- ]
42
- path_order.map do |p|
43
- p if File.exist? p
44
- end.flatten.compact.first
45
- end
46
-
47
- def get_main_file_from_package filename, folder
48
- return unless File.exist? filename
49
- json_string = File.open(filename).read
50
- json = JSON.parse json_string
51
- return unless json.has_key? "main"
52
- main_file = json["main"]
53
- determine_file_from_suggestion main_file, folder
54
- end
55
-
56
- def vendor_files modules
57
- files = main_files modules
58
- missing = files.map { |f| f[:lib].nil? ? f[:module] : nil }.compact
59
-
60
- puts "missing #{missing.length} lib files: #{missing.inspect}" unless missing.empty?
61
-
62
- path = "./vendor/assets/javascripts/"
63
- Pathname.new(path).mkpath()
64
- files.each do |info|
65
- FileUtils.cp(info[:lib], "#{path}#{info[:module]}.js") if info[:lib]
66
- end
67
- end
68
-
69
- def update_modules modules
70
- modules.each do |mod|
71
- `cd ./#{mod} && git pull origin master`
72
- `cd ./#{mod} && ./build` if File.exist? "./#{mod}/build"
73
- end
74
- end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: konacha-chai-matchers
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.18
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthijs Groen
@@ -29,8 +29,11 @@ files:
29
29
  - LICENSE
30
30
  - README.md
31
31
  - Rakefile
32
+ - VERSIONS
32
33
  - konacha-chai-matchers.gemspec
33
34
  - lib/konacha-chai-matchers.rb
35
+ - lib/konacha-chai-matchers/collector.rb
36
+ - lib/konacha-chai-matchers/library.rb
34
37
  - lib/konacha-chai-matchers/version.rb
35
38
  - tasks/update.rb
36
39
  - vendor/assets/javascripts/chai-as-promised.js