fyipe 3.0.11509 → 3.0.11510

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a29095c9180ccf242aa34ad144a6a6b0b96a6faf118373fcf00972b9c949157
4
- data.tar.gz: 87e79478cbdeeba90c1cea327acf5a15123f1e1cf720ce897e7fe22bba654512
3
+ metadata.gz: 4c58a0d79a0b625e24968066aec2937fe208df798a1bf01733b14b6220dde799
4
+ data.tar.gz: 5556acf34847a3178be8b4296324d3ea83ac103d78f9ebc2510f6df79cb027b9
5
5
  SHA512:
6
- metadata.gz: c2617bd4eae203204279eada0e7c499f070342a88b506c3a682c9f4ad15cf41b29f3bb086325b80cff4355aa51add1b59c677622a55384a4b9cce811449d954a
7
- data.tar.gz: 302714f24db9073ee0e94091620e17823198b90fd5da42019090651ad7368ce6ede8fdfad983f196b05a0f7b9749b44914c913ca7d83889cff578f86cd617361
6
+ metadata.gz: 7417a85d51f46489083e528af27b756174b6bb95f7a6be8e9883ec5f305e9d0e152fb4513c406c6d11af57b901afa3876618abcf2dade43e49b9621acd19e006
7
+ data.tar.gz: 84b57be6b5cfba2f6c0106463b72a2b5edafaa4b8ee93e033681da1d7e064b6106c17a94288fc43674e87726fc13f8f9f6762e89976dfc09e1d0f6264bde422f
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ vendor/
2
+ .bundle/
3
+ *.gem
4
+ coverage/*
5
+ Gemfile.lock
6
+ *~
7
+ .rvmrc
8
+ log/*
9
+ measurement/*
10
+ pkg/*
11
+ .DS_Store
12
+ .env
13
+ spec/dummy/tmp/*
14
+ spec/dummy/log/*.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.5
7
+ NewCops: enable
data/RakeFile ADDED
@@ -0,0 +1,6 @@
1
+ require 'rake'
2
+ require 'rubocop/rake_task'
3
+ RuboCop::RakeTask.new do |task|
4
+ task.requires << 'rubocop-performance'
5
+ task.requires << 'rubocop-rspec'
6
+ end
data/demo.rb ADDED
@@ -0,0 +1,25 @@
1
+ require_relative 'lib/fyipe'
2
+
3
+ # instance=Fyipe.config do |c|
4
+ # c.applicationLogId = 'Testing'
5
+ # end
6
+
7
+ # puts Fyipe.applicationLogId
8
+
9
+ obj = FyipeLogger.new(
10
+ 'http://localhost:3002/api',
11
+ '5eeba14a3b0014dfbe07124a',
12
+ '0292c716-089c-491e-8f30-b8a0ce4e0250'
13
+ )
14
+
15
+ obj.display()
16
+
17
+ # obj.log("heyy")
18
+ # obj.log(64)
19
+ # obj.log(['content', 'here'])
20
+ obj.log({'content'=> 'here'})
21
+ obj.warning('heyy')
22
+ obj.error({'content'=> 'another try'})
23
+ # obj.log({:sk => "here"})
24
+
25
+ # puts logger
data/fyipe.gemspec CHANGED
@@ -12,11 +12,11 @@ Gem::Specification.new do |spec|
12
12
  spec.license = 'MIT'
13
13
  spec.platform = Gem::Platform::RUBY
14
14
  spec.required_ruby_version = '>= 2.5.0'
15
- spec.files = Dir['README.md', 'LICENSE',
16
- 'CHANGELOG.md', 'ruby-sdk/**/*.rb',
17
- 'ruby-sdk/**/*.rake',
18
- 'fyipe.gemspec', '.github/*.md',
19
- 'Gemfile', 'Rakefile']
15
+
16
+ all_files = `git ls-files`.split("\n")
17
+ test_files = `git ls-files -- {spec}/*`.split("\n")
18
+
19
+ spec.files = all_files - test_files
20
20
  spec.extra_rdoc_files = ['README.md']
21
21
  spec.add_dependency 'httparty', '~> 0.17'
22
22
  spec.add_dependency 'gem-release'
data/lib/fyipe.rb ADDED
@@ -0,0 +1,76 @@
1
+ require 'httparty'
2
+
3
+ class FyipeLogger
4
+
5
+ include HTTParty
6
+ # FyipeLogger constructor.
7
+ # @param string apiUrl
8
+ # @param string applicationLogId
9
+ # @param string applicationLogKey
10
+
11
+ def initialize(apiUrl, applicationLogId, applicationLogKey)
12
+ # instance variable intialzation
13
+ @applicationLogId = applicationLogId
14
+ setApiUrl(apiUrl)
15
+ @applicationLogKey = applicationLogKey
16
+ end
17
+
18
+ def setApiUrl(apiUrl)
19
+ @apiUrl = apiUrl + '/application-log/' + @applicationLogId + '/log';
20
+ end
21
+
22
+ def validateItems(content, tags)
23
+ # get the class of the content and convert to string for comparison
24
+ contentType = content.class.to_s
25
+ tagType = tags != nil ? tags.class.to_s : nil
26
+
27
+ # check if content type is not a string or hash object
28
+ if(!((contentType.eql? "String") || (contentType.eql? "Hash")))
29
+ raise "Invalid Content to be logged"
30
+ end
31
+
32
+ # check if tag type is avialable and its not a string or hash object
33
+ if(tagType != nil && (!((tagType.eql? "String") || (tagType.eql? "Array"))))
34
+ raise "Invalid Content Tags to be logged"
35
+ end
36
+ end
37
+
38
+ def log(content, tags = nil)
39
+ validateItems(content, tags)
40
+
41
+ #set log type
42
+ logType = "info";
43
+ return makeApiRequest(content, logType, tags)
44
+ end
45
+
46
+ def warning(content, tags = nil)
47
+ validateItems(content, tags)
48
+
49
+ #set log type
50
+ logType = "warning";
51
+ return makeApiRequest(content, logType, tags)
52
+ end
53
+
54
+ def error(content, tags = nil)
55
+ validateItems(content, tags)
56
+
57
+ #set log type
58
+ logType = "error";
59
+ return makeApiRequest(content, logType, tags)
60
+ end
61
+
62
+ def makeApiRequest(data, type, tags = nil)
63
+ # make api request and return response
64
+
65
+ body = { content: data, type: type, applicationLogKey: @applicationLogKey }
66
+ if (tags != nil)
67
+ body['tags'] = tags;
68
+ end
69
+ params = { body: body }
70
+
71
+ response = self.class.post(@apiUrl, params).parsed_response
72
+ return response
73
+
74
+ end
75
+
76
+ end
@@ -0,0 +1,3 @@
1
+ module Fyipe
2
+ VERSION = '3.0.11510'
3
+ end
@@ -0,0 +1,148 @@
1
+ # spec/fyipe_logger_spec.rb
2
+ require_relative '../lib/fyipe'
3
+ require_relative 'helper'
4
+
5
+ RSpec.configure do |config|
6
+ config.before(:suite){
7
+ # using $ registers the variable as a global variable
8
+ # ref: https://stackoverflow.com/a/19167379/6800815
9
+ $apiUrl = 'http://localhost:3002/api'
10
+ $helper = Helper.new()
11
+ sampleUser = $helper.getSampleUser()
12
+
13
+ begin
14
+ # create user
15
+ createdUser = $helper.makeApiRequest($apiUrl+"/user/signup", sampleUser)
16
+
17
+ # get token and project
18
+ $token = createdUser['tokens']['jwtAccessToken']
19
+ $project = createdUser['project']
20
+
21
+ # create a component
22
+ component = { 'name' => $helper.getTitle() }
23
+ $createdComponent = $helper.makeApiRequest($apiUrl+"/component/"+$project["_id"], component, $token)
24
+
25
+ # create an applicationlog and set it as the global application Log.
26
+ appLog = { 'name' => $helper.getTitle() }
27
+ $applicationLog = $helper.makeApiRequest($apiUrl+"/application-log/"+$project["_id"]+"/"+$createdComponent["_id"]+"/create", appLog, $token)
28
+ rescue => exception
29
+ puts "Couldnt create an application log to run a test, Error occured: #{exception.message}"
30
+ ensure
31
+ puts "All clear, Tests will commence now"
32
+ end
33
+
34
+ }
35
+ end
36
+
37
+ RSpec.describe FyipeLogger do
38
+ it 'test_application_log_key_is_required' do
39
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], '')
40
+ response = logger.log('test content')
41
+ expect(response['message']).to eql 'Application Log Key is required.'
42
+ end
43
+ it 'test_content_is_required' do
44
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
45
+ response = logger.log('')
46
+ expect(response['message']).to eql 'Content to be logged is required.'
47
+ end
48
+ it 'test_valid_applicaiton_log_id_is_required' do
49
+ logger = FyipeLogger.new($apiUrl, "5eec6f33d7d57033b3a7d502", $applicationLog["key"])
50
+ response = logger.log('test')
51
+ expect(response['message']).to eql 'Application Log does not exist.'
52
+ end
53
+ it 'test_valid_string_content_of_type_info_is_logged' do
54
+ log = "sample content to be logged"
55
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
56
+ response = logger.log(log)
57
+ expect(response['content']).to eql log
58
+ expect(response['content'].class.to_s).to eql "String"
59
+ expect(response['type']).to eql "info"
60
+ end
61
+ it 'test_valid_object_content_of_type_info_is_logged' do
62
+ log = {
63
+ "name" => "Tony Lewinsky",
64
+ "location" => "Liverpool"
65
+ }
66
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
67
+ response = logger.log(log)
68
+ expect(response['content']["location"]).to eql log["location"]
69
+ expect(response['content'].class.to_s).to eql "Hash"
70
+ expect(response['type']).to eql "info"
71
+ end
72
+ it 'test_valid_string_content_of_type_error_is_logged' do
73
+ log = "sample content to be logged"
74
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
75
+ response = logger.error(log)
76
+ expect(response['content']).to eql log
77
+ expect(response['content'].class.to_s).to eql "String"
78
+ expect(response['type']).to eql "error"
79
+ end
80
+ it 'test_valid_object_content_of_type_warning_is_logged' do
81
+ log = {
82
+ "name" => "Tony Lewinsky",
83
+ "location" => "Liverpool"
84
+ }
85
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
86
+ response = logger.warning(log)
87
+ expect(response['content']["location"]).to eql log["location"]
88
+ expect(response['content'].class.to_s).to eql "Hash"
89
+ expect(response['type']).to eql "warning"
90
+ end
91
+ it 'test_valid_object_content_of_type_warning_with_one_tag_is_logged' do
92
+ log = {
93
+ "name" => "Tony Lewinsky",
94
+ "location" => "Liverpool"
95
+ }
96
+ tag = "Famous";
97
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
98
+ response = logger.warning(log, tag)
99
+ expect(response['content']["location"]).to eql log["location"]
100
+ expect(response['content'].class.to_s).to eql "Hash"
101
+ expect(response['type']).to eql "warning"
102
+ expect(response['tags'].class.to_s).to eql "Array"
103
+ expect(response['tags'].find { |item| item == tag }).to_not be_nil
104
+ end
105
+ it 'test_valid_object_content_of_type_error_with_no_tag_is_logged' do
106
+ log = "sample content to be logged"
107
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
108
+ response = logger.error(log)
109
+ expect(response['content']).to eql log
110
+ expect(response['content'].class.to_s).to eql "String"
111
+ expect(response['type']).to eql "error"
112
+ expect(response['tags'].class.to_s).to eql "Array"
113
+ expect(response['tags']).to eql []
114
+ end
115
+ it 'test_valid_object_content_of_type_warning_with_four_tags_is_logged' do
116
+ log = {
117
+ "name" => "Tony Lewinsky",
118
+ "location" => "Liverpool"
119
+ }
120
+ tags = ['testing', 'rubylansh', 'trial', 'correct']
121
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
122
+ response = logger.warning(log, tags)
123
+ expect(response['content']["location"]).to eql log["location"]
124
+ expect(response['content'].class.to_s).to eql "Hash"
125
+ expect(response['type']).to eql "warning"
126
+ expect(response['tags'].class.to_s).to eql "Array"
127
+ tags.each {
128
+ |tag| expect(response['tags'].find { |item| item == tag }).to_not be_nil
129
+ }
130
+
131
+ end
132
+ it 'test_valid_object_content_of_type_warning_return_invalid_tags' do
133
+ log = {
134
+ "name" => "Tony Lewinsky",
135
+ "location" => "Liverpool"
136
+ }
137
+ tags = {"content" => "test"}
138
+ logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"])
139
+ begin
140
+ response = logger.warning(log, tags)
141
+ rescue => exception
142
+ expect(exception.message).to eql 'Invalid Content Tags to be logged'
143
+ ensure
144
+
145
+ end
146
+
147
+ end
148
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'faker'
2
+ require 'httparty'
3
+
4
+ class Helper
5
+ include HTTParty
6
+
7
+ def getTitle()
8
+ return Faker::Movie.title
9
+ end
10
+ def getSampleUser()
11
+ user = {
12
+ 'name'=> Faker::Name.name,
13
+ 'password' => '1234567890',
14
+ 'confirmPassword' => '1234567890',
15
+ 'email' => Faker::Internet.email,
16
+ 'companyName' => Faker::Company.name,
17
+ 'jobTitle' => Faker::Company.profession,
18
+ 'companySize' => Faker::Number.between(from: 1, to: 100),
19
+ 'card' => {
20
+ 'stripeToken' => 'tok_visa'
21
+ },
22
+ 'subscription' => {
23
+ 'stripePlanId' => 0
24
+ },
25
+ 'cardName' => Faker::Stripe.valid_token,
26
+ 'cardNumber' => Faker::Stripe.valid_card,
27
+ 'expiry' => Faker::Stripe.valid_card,
28
+ 'cvv' => 123,
29
+ 'city' => Faker::Address.city,
30
+ 'state' => Faker::Address.state,
31
+ 'zipCode' => Faker::Address.zip_code,
32
+ 'planId' => 'plan_GoWIYiX2L8hwzx',
33
+ 'companyRole' => Faker::Company.profession,
34
+ 'companyPhoneNumber' => Faker::Company.profession,
35
+ 'reference' => 'Github',
36
+ }
37
+ return user
38
+ end
39
+
40
+ def makeApiRequest(url, data, token = nil)
41
+ # make api request and return response
42
+ params = { body: data, headers: token == nil ? nil : {Authorization: 'Basic '+token}}
43
+
44
+
45
+ response = self.class.post(url, params).parsed_response
46
+ return response
47
+
48
+ end
49
+ end
@@ -0,0 +1,101 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
31
+
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
40
+
41
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
42
+ # have no way to turn it off -- the option exists only for backwards
43
+ # compatibility in RSpec 3). It causes shared context metadata to be
44
+ # inherited by the metadata hash of host groups and examples, rather than
45
+ # triggering implicit auto-inclusion in groups with matching metadata.
46
+ config.shared_context_metadata_behavior = :apply_to_host_groups
47
+
48
+ # The settings below are suggested to provide a good initial experience
49
+ # with RSpec, but feel free to customize to your heart's content.
50
+ =begin
51
+ # This allows you to limit a spec run to individual examples or groups
52
+ # you care about by tagging them with `:focus` metadata. When nothing
53
+ # is tagged with `:focus`, all examples get run. RSpec also provides
54
+ # aliases for `it`, `describe`, and `context` that include `:focus`
55
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
+ config.filter_run_when_matching :focus
57
+
58
+ # Allows RSpec to persist some state between runs in order to support
59
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # you configure your source control system to ignore this file.
61
+ config.example_status_persistence_file_path = "spec/examples.txt"
62
+
63
+ # Limits the available syntax to the non-monkey patched syntax that is
64
+ # recommended. For more details, see:
65
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ config.disable_monkey_patching!
69
+
70
+ # This setting enables warnings. It's recommended, but in some cases may
71
+ # be too noisy due to issues in dependencies.
72
+ config.warnings = true
73
+
74
+ # Many RSpec users commonly either run the entire suite or an individual
75
+ # file, and it's useful to allow more verbose output when running an
76
+ # individual spec file.
77
+ if config.files_to_run.one?
78
+ # Use the documentation formatter for detailed output,
79
+ # unless a formatter has already been configured
80
+ # (e.g. via a command-line flag).
81
+ config.default_formatter = "doc"
82
+ end
83
+
84
+ # Print the 10 slowest examples and example groups at the
85
+ # end of the spec run, to help surface which specs are running
86
+ # particularly slow.
87
+ config.profile_examples = 10
88
+
89
+ # Run specs in random order to surface order dependencies. If you find an
90
+ # order dependency and want to debug it, you can fix the order by providing
91
+ # the seed, which is printed after each run.
92
+ # --seed 1234
93
+ config.order = :random
94
+
95
+ # Seed global randomization in this process using the `--seed` CLI option.
96
+ # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # test failures related to randomization by passing the same `--seed` value
98
+ # as the one that triggered the failure.
99
+ Kernel.srand config.seed
100
+ =end
101
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fyipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.11509
4
+ version: 3.0.11510
5
5
  platform: ruby
6
6
  authors:
7
7
  - HackerBay, Inc.
@@ -131,11 +131,21 @@ extensions: []
131
131
  extra_rdoc_files:
132
132
  - README.md
133
133
  files:
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".rubocop.yml"
134
137
  - CHANGELOG.md
135
138
  - Gemfile
136
139
  - LICENSE
137
140
  - README.md
141
+ - RakeFile
142
+ - demo.rb
138
143
  - fyipe.gemspec
144
+ - lib/fyipe.rb
145
+ - lib/fyipe/version.rb
146
+ - spec/fyipe_logger_spec.rb
147
+ - spec/helper.rb
148
+ - spec/spec_helper.rb
139
149
  homepage: https://github.com/Fyipe/ruby-sdk
140
150
  licenses:
141
151
  - MIT