trojan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 452ab64756c67766e73a0edb6c6b58835e8183c9
4
+ data.tar.gz: 31b709c95b433c68327087c084a6685cddcd2c0c
5
+ SHA512:
6
+ metadata.gz: de618890742e9dc7e851a10a1cecdcba0dc27c483328014650842115a98113b6fd4890b004fa2ca6ea21741ac65614d53647f6f6457dab4c57dc5b675027b8e3
7
+ data.tar.gz: 7a0da0e6b7099a02c32cfb1c5a8e234f8491dbe429ee5c595bf0c8b3a099af92e0aad1cf480a91df6d6f186371357a173bffe4bd628240f728912b03b73334e8
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ *
2
+ !.gitignore
3
+ !lib/
4
+ !lib/**
5
+ !spec/
6
+ !spec/**
7
+ !.travis.yml
8
+ !Gemfile
9
+ !Gemfile.lock
10
+ !Rakefile
11
+ !README.md
12
+ !release
13
+ !trojan.gemspec
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3
4
+ - 2.2
5
+ - 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ trojan (0.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.3.0)
10
+ byebug (9.1.0)
11
+ diff-lcs (1.3)
12
+ parser (2.4.0.0)
13
+ ast (~> 2.2)
14
+ powerpack (0.1.1)
15
+ rainbow (2.2.2)
16
+ rake
17
+ rake (11.3.0)
18
+ rspec (3.7.0)
19
+ rspec-core (~> 3.7.0)
20
+ rspec-expectations (~> 3.7.0)
21
+ rspec-mocks (~> 3.7.0)
22
+ rspec-core (3.7.0)
23
+ rspec-support (~> 3.7.0)
24
+ rspec-expectations (3.7.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.7.0)
27
+ rspec-mocks (3.7.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.7.0)
30
+ rspec-support (3.7.0)
31
+ rubocop (0.45.0)
32
+ parser (>= 2.3.1.1, < 3.0)
33
+ powerpack (~> 0.1)
34
+ rainbow (>= 1.99.1, < 3.0)
35
+ ruby-progressbar (~> 1.7)
36
+ unicode-display_width (~> 1.0, >= 1.0.1)
37
+ ruby-progressbar (1.9.0)
38
+ unicode-display_width (1.3.0)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 1.12)
45
+ byebug
46
+ rake (~> 11.3)
47
+ rspec (~> 3.6)
48
+ rubocop (~> 0.45.0)
49
+ trojan!
50
+
51
+ BUNDLED WITH
52
+ 1.15.3
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
7
+ t.rspec_opts = '--format documentation'
8
+ # t.rspec_opts << ' more options'
9
+ end
10
+
11
+ task default: :spec
data/lib/trojan/spy.rb ADDED
@@ -0,0 +1,50 @@
1
+ module Trojan
2
+ class Spy
3
+ DEFAULT_CALL_STRATEGY_VALUE = [nil]
4
+
5
+ attr_reader :calls
6
+
7
+ def initialize(obj, method_name)
8
+ @hooked = false
9
+ @object = obj
10
+ @method_name = method_name
11
+ @original_method = @object.method(method_name)
12
+ @calls = []
13
+
14
+ @call_strategy = :static_return
15
+ @call_strategy_value = DEFAULT_CALL_STRATEGY_VALUE
16
+ @call_strategy_index = 0
17
+ end
18
+
19
+ def hooked?
20
+ @hooked
21
+ end
22
+
23
+ def hook!
24
+ raise "spy has already been hooked" if hooked?
25
+ @object.define_singleton_method(@method_name, stub_method)
26
+ @hooked = true
27
+ end
28
+
29
+ def unhook!
30
+ raise "spy has not been hooked yet" unless hooked?
31
+ @object.define_singleton_method(@method_name, @original_method)
32
+ @hooked = false
33
+ end
34
+
35
+ private
36
+
37
+ def stub_method
38
+ this = self
39
+ proc { |*args| this.send(:process_call, *args) }
40
+ end
41
+
42
+ def process_call(*args)
43
+ record_call(args)
44
+ end
45
+
46
+ def record_call(args)
47
+ @calls << args
48
+ end
49
+ end
50
+ end
data/lib/trojan.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "trojan/spy"
2
+
3
+ module Trojan
4
+ class << self
5
+ end
6
+ end
data/release ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+ cp trojan.gemspec trojan.gemspec.backup
3
+ sed -i.bak s/0.0.0/$1/g trojan.gemspec
4
+ sed -i.bak s/2001-01-01/`date +%Y-%m-%d`/g trojan.gemspec
5
+ gem build trojan.gemspec
6
+ mv trojan.gemspec.backup trojan.gemspec
7
+ gem push trojan-$1.gem
8
+ git tag -a v$1 -m "Release v$1"
9
+ git push origin --tags
data/trojan.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ Gem::Specification.new do |s|
3
+ s.name = 'trojan'
4
+ s.version = '0.0.1'
5
+ s.date = '2017-10-30'
6
+ s.summary = 'Library of spies, stubs and mocks for Ruby'
7
+ s.description = 'Library of spies, stubs and mocks for Ruby'
8
+ s.homepage = 'https://github.com/Colex/trojan-rb'
9
+ s.authors = ['Alex Correia Santos']
10
+ s.email = ['hello@alexcsantos.com']
11
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
12
+ s.require_paths = ['lib']
13
+ s.license = 'MIT'
14
+
15
+ s.required_ruby_version = '>= 2.2.2'
16
+
17
+ s.add_development_dependency 'bundler', '~> 1.12'
18
+ s.add_development_dependency 'rspec', '~> 3.6'
19
+ s.add_development_dependency 'rake', '~> 11.3'
20
+ s.add_development_dependency 'rubocop', '~> 0.45.0'
21
+ s.add_development_dependency 'byebug'
22
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trojan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Correia Santos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.45.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.45.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Library of spies, stubs and mocks for Ruby
84
+ email:
85
+ - hello@alexcsantos.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - README.md
95
+ - Rakefile
96
+ - lib/trojan.rb
97
+ - lib/trojan/spy.rb
98
+ - release
99
+ - trojan.gemspec
100
+ homepage: https://github.com/Colex/trojan-rb
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 2.2.2
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.5.1
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Library of spies, stubs and mocks for Ruby
124
+ test_files: []