ajax_test 1.1.8

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: fba642a19cb75a6e8a3835fb70b00e818bb41a20
4
+ data.tar.gz: 123fead280c8748bce61274aa57bfb5c119a9786
5
+ SHA512:
6
+ metadata.gz: 6f88d38db3edc91bbbe3bdd3f40af18a3413a0f21fc53e47ceec0b3478763ebc163e74898e69ab38f45edbb581cfd921c948b21f665a2ac9689cbef6e187e66a
7
+ data.tar.gz: cc1df62f836fd72c806502367dd666331ee4b483921066bdf38254d02fac45aa5036fac3d244faac7d3ec11e86df0edcc8d7de1a2dbe53f6b344431eedbd8524
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ ajax_test
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build ajax_test-1.1.7.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install ajax_test-1.1.7.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install ajax_test-1.1.7.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v1.1.7 and build and push ajax_test-1.1.7.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
data/.idea/misc.xml ADDED
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectInspectionProfilesVisibleTreeState">
4
+ <entry key="Project Default">
5
+ <profile-state>
6
+ <expanded-state>
7
+ <State>
8
+ <id />
9
+ </State>
10
+ </expanded-state>
11
+ <selected-state>
12
+ <State>
13
+ <id>CoffeeScript</id>
14
+ </State>
15
+ </selected-state>
16
+ </profile-state>
17
+ </entry>
18
+ </component>
19
+ <component name="ProjectLevelVcsManager" settingsEditedManually="false">
20
+ <OptionsSetting value="true" id="Add" />
21
+ <OptionsSetting value="true" id="Remove" />
22
+ <OptionsSetting value="true" id="Checkout" />
23
+ <OptionsSetting value="true" id="Update" />
24
+ <OptionsSetting value="true" id="Status" />
25
+ <OptionsSetting value="true" id="Edit" />
26
+ <ConfirmationsSetting value="0" id="Add" />
27
+ <ConfirmationsSetting value="0" id="Remove" />
28
+ </component>
29
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.0.0-p481" project-jdk-type="RUBY_SDK" />
30
+ <component name="masterDetails">
31
+ <states>
32
+ <state key="ScopeChooserConfigurable.UI">
33
+ <settings>
34
+ <splitter-proportions>
35
+ <option name="proportions">
36
+ <list>
37
+ <option value="0.2" />
38
+ </list>
39
+ </option>
40
+ </splitter-proportions>
41
+ </settings>
42
+ </state>
43
+ </states>
44
+ </component>
45
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/ajax_test.iml" filepath="$PROJECT_DIR$/.idea/ajax_test.iml" />
6
+ <module fileurl="file://$PROJECT_DIR$/.idea/ajax_test.iml" filepath="$PROJECT_DIR$/.idea/ajax_test.iml" />
7
+ </modules>
8
+ </component>
9
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ajax_test.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ben Whittle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # AjaxTest
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ajax_test`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ajax_test'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ajax_test
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ajax_test.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/ajax_test.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ajax_test/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ajax_test"
8
+ spec.version = AjaxTest::VERSION
9
+ spec.authors = ["Ben Whittle"]
10
+ spec.email = ["benwhittle31@gmail.com"]
11
+ spec.summary = "gem to test an ajax request"
12
+ spec.homepage = "https://www.github.com/whittlbc/ajax_test"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency 'rails', '~> 4.2'
21
+ spec.add_development_dependency "bundler", "~> 1.11"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ajax_test"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config.ru ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize! :all
7
+ run Combustion::Application
@@ -0,0 +1,10 @@
1
+ require 'rails'
2
+
3
+ module AjaxTest
4
+ class Railtie < Rails::Railtie
5
+ initializer 'railtie.configure_rails_initialization' do
6
+ AjaxTest.fetch_and_cache_remote_configs
7
+ AjaxTest.create_rake_file
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module AjaxTest
2
+ VERSION = '1.1.8'
3
+ end
data/lib/ajax_test.rb ADDED
@@ -0,0 +1,66 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+ require 'uri'
4
+ require 'json'
5
+ require 'yaml'
6
+ require 'ajax_test/version'
7
+ require 'ajax_test/railtie'
8
+ require 'generators/ajax_test/ajax_test_generator'
9
+
10
+ API_KEY_NAME = 'CONFLUX_API_KEY'
11
+ HOST_URL = 'http://conflux-dev.herokuapp.com'
12
+ CUSTOM_HEADER = 'Conflux-API-Token'
13
+ YAML_HEADER = '# Conflux Config Vars'
14
+
15
+ module AjaxTest
16
+ extend self
17
+
18
+ def fetch_and_cache_remote_configs
19
+ get_api_token_from_app_configs
20
+ fetch_remote_configs if @token.present?
21
+ end
22
+
23
+ def get_api_token_from_app_configs
24
+ @app_configs = YAML::load_file(File.join(Rails.root, 'config', 'application.yml')) || {}
25
+ @token = @app_configs[API_KEY_NAME] || (@app_configs[Rails.env] || {})[API_KEY_NAME]
26
+ end
27
+
28
+ def fetch_remote_configs
29
+ uri = URI.parse("#{HOST_URL}/keys")
30
+ http = Net::HTTP.new(uri.host, uri.port)
31
+ # http.use_ssl = true
32
+ # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
33
+ request = Net::HTTP::Get.new(uri.request_uri)
34
+ request.add_field(CUSTOM_HEADER, @token)
35
+ @response = http.request(request)
36
+ set_config_vars_from_remote_configs
37
+ end
38
+
39
+ def set_config_vars_from_remote_configs
40
+ remote_configs = JSON.parse(@response.body) rescue {}
41
+ conflux_yml = File.open(File.join(Rails.root, 'config', 'conflux.yml'), 'w+')
42
+ conflux_yml.write("\n#{YAML_HEADER}\n\n")
43
+
44
+ remote_configs.each { |key, value|
45
+ if key_already_set?(key)
46
+ line = "# #{key}: \"#{value}\" #Overwritten\n"
47
+ else
48
+ line = "#{key}: \"#{value}\"\n"
49
+ ENV[key] = value
50
+ end
51
+
52
+ conflux_yml.write(line)
53
+ }
54
+
55
+ conflux_yml.close
56
+ end
57
+
58
+ def key_already_set?(key)
59
+ ENV.key?(key) || @app_configs.include?(key) || (@app_configs[Rails.env] || {}).include?(key)
60
+ end
61
+
62
+ def create_rake_file
63
+ AjaxTest::Generators::AjaxTestGenerator.new.create_rake_file
64
+ end
65
+
66
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails/generators'
2
+
3
+ RAKE_PATH = 'lib/tasks/conflux.rake'
4
+
5
+ module AjaxTest
6
+ module Generators
7
+ class AjaxTestGenerator < Rails::Generators::Base
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def create_rake_file
11
+ if !File.exists?(RAKE_PATH)
12
+ copy_file('conflux.rake', RAKE_PATH)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ require 'ajax_test'
2
+
3
+ namespace :ajax_test do
4
+ desc 'Refetch config vars from Conflux'
5
+ task :fetch do
6
+ AjaxTest.fetch_and_cache_remote_configs
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ajax_test
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.8
5
+ platform: ruby
6
+ authors:
7
+ - Ben Whittle
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - benwhittle31@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".idea/.name"
78
+ - ".idea/.rakeTasks"
79
+ - ".idea/misc.xml"
80
+ - ".idea/modules.xml"
81
+ - ".idea/vcs.xml"
82
+ - ".rspec"
83
+ - ".travis.yml"
84
+ - Gemfile
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - ajax_test.gemspec
89
+ - bin/console
90
+ - bin/setup
91
+ - config.ru
92
+ - lib/ajax_test.rb
93
+ - lib/ajax_test/railtie.rb
94
+ - lib/ajax_test/version.rb
95
+ - lib/generators/ajax_test/ajax_test_generator.rb
96
+ - lib/generators/ajax_test/templates/conflux.rake
97
+ homepage: https://www.github.com/whittlbc/ajax_test
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.6.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: gem to test an ajax request
121
+ test_files: []