share_to_gplus 0.1.1 → 0.2.0

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
  SHA1:
3
- metadata.gz: c2ea1a71dc8d00508c32d7411a2d6c7f0d93f06f
4
- data.tar.gz: 8e22a1f4121bb6fed526e0f814a24325bd51dee5
3
+ metadata.gz: d5488b75d94fd1438432d15a43d7d3b3f1362e4a
4
+ data.tar.gz: d587ea3985187141bbe1676861c82b5b26d852d1
5
5
  SHA512:
6
- metadata.gz: 908a3c5b1c3186ae3329c7cbe2e837331ae012ce256dadf851f39980ebeb5597cf560a596833b8909182bf964be6d6288fd1019b3fc67cb7cc406dedca4af675
7
- data.tar.gz: b622ddbbd556bca74cfec217b9ea8043b92a1ec5007fc4d61a5fc38cf7383d57f0d6e1f2ec473fe35c22aaa9a669a7f1226f0fc957fcd2ce044a4533c204db16
6
+ metadata.gz: caba26b068e78e3a2e9b26782427b1451dcc483ad3b5b50efb1ae033d7a8411526f8816270527a47a9d1ee0ceff60b62ab55a2552afd494fe3f008e3c4e08ff6
7
+ data.tar.gz: b421145f90bb140c94c02c6fd82395b579090dd6a052e5b3cc2063297b6e68f18d5a7e7f876490743e91a05f9a62dc77ccefdf404ef8d7069c56216b222687ef
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.0
4
+
5
+ * Add `default_gplus_version` option
6
+
3
7
  ## 0.1.1
4
8
 
5
9
  * Set minimal ruby version as 2.3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- share_to_gplus (0.1.1)
4
+ share_to_gplus (0.2.0)
5
5
  capybara (>= 2)
6
6
  poltergeist
7
7
  selenium-webdriver
@@ -10,7 +10,7 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  addressable (2.4.0)
13
- capybara (2.7.1)
13
+ capybara (2.8.1)
14
14
  addressable
15
15
  mime-types (>= 1.16)
16
16
  nokogiri (>= 1.3.3)
@@ -111,4 +111,4 @@ DEPENDENCIES
111
111
  share_to_gplus!
112
112
 
113
113
  BUNDLED WITH
114
- 1.10.6
114
+ 1.12.5
@@ -1,12 +1,6 @@
1
1
  require 'share_to_gplus/version'
2
2
 
3
3
  module ShareToGplus
4
-
5
- require 'share_to_gplus/configuration'
6
- require 'share_to_gplus/it'
7
- require 'share_to_gplus/sharer'
8
- require 'share_to_gplus/executable'
9
-
10
4
  class << self
11
5
  attr_writer :configuration
12
6
  end
@@ -23,3 +17,8 @@ module ShareToGplus
23
17
  yield(configuration)
24
18
  end
25
19
  end
20
+
21
+ require 'share_to_gplus/configuration'
22
+ require 'share_to_gplus/it'
23
+ require 'share_to_gplus/sharer'
24
+ require 'share_to_gplus/executable'
@@ -1,12 +1,13 @@
1
1
  module ShareToGplus
2
2
  class Configuration
3
3
  attr_accessor :login, :password, :text, :link, :category, :url,
4
- :javascript_driver
4
+ :javascript_driver, :default_gplus_version
5
5
 
6
6
  def initialize
7
- %w(login password text link category url javascript_driver).each do |var|
7
+ %w(login password text link category url javascript_driver default_gplus_version).each do |var|
8
8
  instance_variable_set("@#{var}", nil)
9
9
  end
10
+ @default_gplus_version ||= :new # set default Google+ version
10
11
  @javascript_driver ||= :selenium # set default driver
11
12
  end
12
13
  end
@@ -36,6 +36,7 @@ module ShareToGplus
36
36
  config.category = @options[:category]
37
37
  config.link = @options[:link]
38
38
  config.javascript_driver = @options[:javascript_driver] if @options[:javascript_driver]
39
+ config.default_gplus_version = @options[:default_gplus_version] if @options[:default_gplus_version]
39
40
  end
40
41
  share_this.execute
41
42
  end
@@ -84,6 +85,10 @@ module ShareToGplus
84
85
  opts.on('-d', '--javascript_driver DRIVER', 'Javascript Driver. "selenium" by default') do |v|
85
86
  @options[:javascript_driver] = v
86
87
  end
88
+
89
+ opts.on('-gv', '--default_gplus_version VERSION', 'Google+ version. "new" by default') do |v|
90
+ @options[:default_gplus_version] = v
91
+ end
87
92
  end
88
93
  end
89
94
  end
@@ -15,7 +15,7 @@ module ShareToGplus
15
15
  capybara_config.default_max_wait_time = 10
16
16
  capybara_config.raise_server_errors = false
17
17
  end
18
- @google_plus_version = "old" # by default
18
+ @config = config
19
19
  end
20
20
 
21
21
  def visit_community
@@ -34,21 +34,21 @@ module ShareToGplus
34
34
  end
35
35
 
36
36
  def try_new_google_plus
37
- @google_plus_version = "new" if !page.has_selector?("div.Ege.qMc")
38
- if @google_plus_version == "old" && page.has_selector?(".d-k-l.b-c.b-c-Wa")
37
+ return if !page.has_selector?("div.Ege.qMc") && @config.default_gplus_version == :new
38
+ if @config.default_gplus_version == :old && page.has_selector?(".d-k-l.b-c.b-c-Wa")
39
39
  find(".d-k-l.b-c.b-c-Wa", visible: :all).click
40
40
  wait_a_little_bit
41
- @google_plus_version = "new"
41
+ @config.default_gplus_version = :new # We changed version
42
42
  end
43
43
  end
44
44
 
45
45
  def open_share_dialog
46
- find("div.jXDCJf.Tek5Ce.BDrJf").click if @google_plus_version == "new"
47
- find("div.kqa.es").click if @google_plus_version == "old"
46
+ find("div.jXDCJf.Tek5Ce.BDrJf").click if @config.default_gplus_version == :new
47
+ find("div.kqa.es").click if @config.default_gplus_version == :old
48
48
  end
49
49
 
50
50
  def fill_text(text:)
51
- if @google_plus_version == "new"
51
+ if @config.default_gplus_version == :new
52
52
  dialog = find("[role='dialog']")
53
53
  dialog.find("div:nth-child(1) div:nth-child(2) textarea").set(text)
54
54
  else
@@ -57,7 +57,7 @@ module ShareToGplus
57
57
  end
58
58
 
59
59
  def fill_link(link:)
60
- if @google_plus_version == "new"
60
+ if @config.default_gplus_version == :new
61
61
  find(:xpath, '//div[@aria-label="Add link"]').click
62
62
  dialog = find(:xpath, '//div[@role="dialog"]')
63
63
  dialog.find('input').set(link)
@@ -70,12 +70,12 @@ module ShareToGplus
70
70
  end
71
71
 
72
72
  def close_dialog
73
- find(:xpath, '//span[contains(., "Post")]').click if @google_plus_version == "new"
73
+ find(:xpath, '//span[contains(., "Post")]').click if @config.default_gplus_version == :new
74
74
  end
75
75
 
76
76
  def set_category(name:)
77
- find(:xpath, "//div[@data-name='#{name}']").click if @google_plus_version == "new"
78
- if @google_plus_version == "old"
77
+ find(:xpath, "//div[@data-name='#{name}']").click if @config.default_gplus_version == :new
78
+ if @config.default_gplus_version == :old
79
79
  find("div.BA.pi.d-e.d-k-l.d-r-c").click
80
80
  find(:xpath, "//div[@class='An zr d-r']/div[@class='Vm d-A']//span[. = 'Test']/../..").click
81
81
  find("div.d-k-l.b-c.b-c-Ba.qy.jt").click
@@ -87,4 +87,7 @@ module ShareToGplus
87
87
  end
88
88
 
89
89
  end
90
- end
90
+
91
+ #require 'share_to_gplus/sharer/old_g'
92
+ #require 'share_to_gplus/sharer/new_g'
93
+ end
@@ -0,0 +1,5 @@
1
+ class ShareToGplus::Sharer::NewG < ShareToGplus::Sharer
2
+ def try_new_google_plus
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ class ShareToGplus::Sharer::OldG < ShareToGplus::Sharer
2
+
3
+ end
@@ -1,3 +1,3 @@
1
1
  module ShareToGplus
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -9,7 +9,9 @@ Gem::Specification.new do |gem|
9
9
  gem.summary = 'Share text and links to Google+ community'
10
10
  gem.homepage = 'https://github.com/developer88/share_to_google_plus'
11
11
 
12
- gem.files = `git ls-files`.split($\)
12
+ gem.files = `git ls-files -z`.split("\x0").reject do |f|
13
+ f.match(%r{^(test|spec|features)/})
14
+ end
13
15
  gem.executables = ['sharetogplus']
14
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
17
  gem.name = 'share_to_gplus'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: share_to_gplus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Eremin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-30 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -116,14 +116,10 @@ files:
116
116
  - lib/share_to_gplus/executable.rb
117
117
  - lib/share_to_gplus/it.rb
118
118
  - lib/share_to_gplus/sharer.rb
119
+ - lib/share_to_gplus/sharer/new_g.rb
120
+ - lib/share_to_gplus/sharer/old_g.rb
119
121
  - lib/share_to_gplus/version.rb
120
122
  - share_to_gplus.gemspec
121
- - spec/share_to_gplus/configuration_spec.rb
122
- - spec/share_to_gplus/executable_spec.rb
123
- - spec/share_to_gplus/it_spec.rb
124
- - spec/share_to_gplus/sharer_spec.rb
125
- - spec/share_to_gplus_spec.rb
126
- - spec/spec_helper.rb
127
123
  homepage: https://github.com/developer88/share_to_google_plus
128
124
  licenses:
129
125
  - GPL-3.0
@@ -144,14 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
140
  version: '0'
145
141
  requirements: []
146
142
  rubyforge_project:
147
- rubygems_version: 2.4.5.1
143
+ rubygems_version: 2.5.1
148
144
  signing_key:
149
145
  specification_version: 4
150
146
  summary: Share text and links to Google+ community
151
- test_files:
152
- - spec/share_to_gplus/configuration_spec.rb
153
- - spec/share_to_gplus/executable_spec.rb
154
- - spec/share_to_gplus/it_spec.rb
155
- - spec/share_to_gplus/sharer_spec.rb
156
- - spec/share_to_gplus_spec.rb
157
- - spec/spec_helper.rb
147
+ test_files: []
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
- require 'share_to_gplus'
3
-
4
- module ShareToGplus
5
- describe ShareToGplus::Configuration do
6
- subject { Configuration.new }
7
-
8
- describe '#login' do
9
- it 'default value is ""' do
10
- expect(subject.login).to eq(nil)
11
- end
12
-
13
-
14
- end
15
-
16
- describe '#login=' do
17
- it 'can set value' do
18
- subject.login = ''
19
- expect(subject.login).to eq('')
20
- end
21
- end
22
-
23
- context 'defaulte values' do
24
- it 'returns default value' do
25
- expect(subject.javascript_driver).to eq(:selenium)
26
- end
27
- end
28
- end
29
- end
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
- require 'share_to_gplus'
3
-
4
- module ShareToGplus
5
- describe ShareToGplus::Executable do
6
- subject { ShareToGplus::Executable }
7
-
8
- describe 'self.#invoke' do
9
- before do
10
- expect_any_instance_of(subject).to receive(:parse_arguments).and_return(true)
11
- expect_any_instance_of(subject).to receive(:invoke).and_return(false)
12
- end
13
-
14
- it { subject.invoke({}) }
15
- end
16
-
17
- describe '#parse_arguments' do
18
- context 'when no arguments provided' do
19
- let(:arguments) { [] }
20
-
21
- it { expect{ subject.invoke(arguments) }.to raise_exception(RuntimeError) }
22
- end
23
-
24
- context 'when invalid arguments provided' do
25
- let(:arguments) { %w(--login test --password) }
26
-
27
- it { expect{ subject.invoke(arguments) }.to raise_exception(OptionParser::MissingArgument) }
28
- end
29
-
30
- context 'when correct arguments provided' do
31
- let(:arguments) { %w(--login test --password pass --url http://test.com) }
32
- before do
33
- expect_any_instance_of(subject).to receive(:invoke).and_return(true)
34
- end
35
-
36
- it { expect(subject.invoke(arguments)).to be true }
37
- end
38
- end
39
-
40
- describe '#invoke' do
41
- subject { ShareToGplus::Executable.new }
42
- let(:it_class) { ShareToGplus::It }
43
-
44
- before do
45
- expect(it_class).to receive(:new).and_call_original
46
- expect_any_instance_of(it_class).to receive(:execute).and_return(true)
47
- end
48
-
49
- it { subject.invoke }
50
- end
51
- end
52
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
- require 'share_to_gplus'
3
-
4
- module ShareToGplus
5
- describe ShareToGplus::It do
6
- subject { ShareToGplus::It.new }
7
-
8
- describe '#execute' do
9
- let(:it_class) { ShareToGplus::It }
10
- let(:sharer_class) { ShareToGplus::Sharer }
11
-
12
- before do
13
- expect_any_instance_of(it_class).to receive(:navigate).and_return(true)
14
- expect_any_instance_of(it_class).to receive(:share).and_return(true)
15
- expect_any_instance_of(sharer_class).to receive(:wait_a_little_bit).and_return(true)
16
- end
17
-
18
- it 'should return true' do
19
- expect(subject.execute).to be true
20
- end
21
- end
22
-
23
- describe '#initialize' do
24
- before do
25
- expect(Sharer).to receive(:new).and_call_original
26
- expect(ShareToGplus).to receive(:configuration).and_call_original
27
- end
28
-
29
- it { subject }
30
- end
31
- end
32
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'share_to_gplus'
3
-
4
- module ShareToGplus
5
- describe ShareToGplus::Sharer do
6
- subject { ShareToGplus::Sharer }
7
-
8
- describe '#initialize' do
9
- before do
10
- expect(Capybara).to receive(:configure).and_call_original
11
- end
12
-
13
- it { subject.new }
14
- end
15
-
16
- # No additional Capybara tests here.
17
- # Since i use Capybara to browse Google's pages it is quite hard to
18
- # prepare dummy Google-like page for tests and always keep it up to date.
19
- end
20
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
- require 'share_to_gplus'
3
-
4
- describe ShareToGplus do
5
- describe '#configure' do
6
- let(:url) { 'http://someurl.com' }
7
-
8
- before :each do
9
- ShareToGplus.configure do |config|
10
- config.url = url
11
- end
12
- end
13
-
14
- it 'returns an array with 10 elements' do
15
- sharer = ShareToGplus::It.new
16
-
17
- expect(sharer.config.url).to eq(url)
18
- end
19
-
20
- after :each do
21
- ShareToGplus.reset
22
- end
23
- end
24
-
25
- describe '#reset' do
26
- before :each do
27
- ShareToGplus.configure do |config|
28
- config.login = ''
29
- end
30
- end
31
-
32
- it 'resets the configuration' do
33
- ShareToGplus.reset
34
-
35
- config = ShareToGplus.configuration
36
-
37
- expect(config.login).to eq(nil)
38
- end
39
- end
40
- end
@@ -1,96 +0,0 @@
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
- # The `.rspec` file also contains a few flags that are not defaults but that
16
- # users commonly want.
17
- #
18
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
- RSpec.configure do |config|
20
- # rspec-expectations config goes here. You can use an alternate
21
- # assertion/expectation library such as wrong or the stdlib/minitest
22
- # assertions if you prefer.
23
- config.expect_with :rspec do |expectations|
24
- # This option will default to `true` in RSpec 4. It makes the `description`
25
- # and `failure_message` of custom matchers include text for helper methods
26
- # defined using `chain`, e.g.:
27
- # be_bigger_than(2).and_smaller_than(4).description
28
- # # => "be bigger than 2 and smaller than 4"
29
- # ...rather than:
30
- # # => "be bigger than 2"
31
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
- end
33
-
34
- # rspec-mocks config goes here. You can use an alternate test double
35
- # library (such as bogus or mocha) by changing the `mock_with` option here.
36
- config.mock_with :rspec do |mocks|
37
- # Prevents you from mocking or stubbing a method that does not exist on
38
- # a real object. This is generally recommended, and will default to
39
- # `true` in RSpec 4.
40
- mocks.verify_partial_doubles = true
41
- end
42
-
43
- # The settings below are suggested to provide a good initial experience
44
- # with RSpec, but feel free to customize to your heart's content.
45
- =begin
46
- # These two settings work together to allow you to limit a spec run
47
- # to individual examples or groups you care about by tagging them with
48
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
- # get run.
50
- config.filter_run :focus
51
- config.run_all_when_everything_filtered = true
52
-
53
- # Allows RSpec to persist some state between runs in order to support
54
- # the `--only-failures` and `--next-failure` CLI options. We recommend
55
- # you configure your source control system to ignore this file.
56
- config.example_status_persistence_file_path = "spec/examples.txt"
57
-
58
- # Limits the available syntax to the non-monkey patched syntax that is
59
- # recommended. For more details, see:
60
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
61
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
63
- config.disable_monkey_patching!
64
-
65
- # This setting enables warnings. It's recommended, but in some cases may
66
- # be too noisy due to issues in dependencies.
67
- config.warnings = true
68
-
69
- # Many RSpec users commonly either run the entire suite or an individual
70
- # file, and it's useful to allow more verbose output when running an
71
- # individual spec file.
72
- if config.files_to_run.one?
73
- # Use the documentation formatter for detailed output,
74
- # unless a formatter has already been configured
75
- # (e.g. via a command-line flag).
76
- config.default_formatter = 'doc'
77
- end
78
-
79
- # Print the 10 slowest examples and example groups at the
80
- # end of the spec run, to help surface which specs are running
81
- # particularly slow.
82
- config.profile_examples = 10
83
-
84
- # Run specs in random order to surface order dependencies. If you find an
85
- # order dependency and want to debug it, you can fix the order by providing
86
- # the seed, which is printed after each run.
87
- # --seed 1234
88
- config.order = :random
89
-
90
- # Seed global randomization in this process using the `--seed` CLI option.
91
- # Setting this allows you to use `--seed` to deterministically reproduce
92
- # test failures related to randomization by passing the same `--seed` value
93
- # as the one that triggered the failure.
94
- Kernel.srand config.seed
95
- =end
96
- end